Help wanted: I am lazy to impl.
Discussion needed: some design choices needed.
Rationale
Currently almost all (AFAIK, all) Zig packages (ghostty, ncdu, etc.) are compiled targeting either Zig baseline or build host. We should make them target the baseline of AOSC OS.
Background
- (hint: "Zig" refers to the programming language, "zig" refers to the implementation by Zig Software Foundation)
- By default, Zig build binaries targeting build host. [ref]
- Zig
build-{exe,lib,obj} build target is specified with a target query (i.e. -target <arch><sub>-<os>-<abi>) and a CPU model string (-mcpu [cpu][feature set]).
- Zig
build (Zig Build System) provides a "standard" (sic.) way to specify build target (i.e. -Dtarget=, -Dcpu). Packages may adopt their own way to specify target or disallow specifying build target (Very rarely; I haven't seen any packages doing so; These should be fixed in upstream).
- Some packages (e.g. ncdu) set build target in their own build script. We should override them.
- Note that some packages may want to cross-compile something intentionally. (AFAIK currently there isn't any case in AOSC OS)
- Note that AOSC OS may support more than one CPU feature sets on the same architecture (e.g.
loongarch{,_nosimd}).
Proposal
- Sourcing target queries
- A: Add
ZIG_TARGET and ZIG_CPU variables to Autobuild.
- B: Hard-code the AOSC baseline by patching zig; add special
aosc_xxxx target strings (where xxxx is the Autobuild architecture name).
- Adopting target queries
- A: Update all build scripts manually to use them.
- B: When
ABTARGET environment variable is set, let the standard functions of Zig Build System return the baseline target.
- Idiot-proofing, when
AB environment variable is set
- Reject all ZCU targeting non-AOSC-baseline targets, unless
AOSC_ZIG_UNCHECK_TARGET environment variable is set.
- Reject all ZCU with optimization modes other than ReleaseFast, unless
AOSC_ZIG_UNCHECK_OPT_MODE environment variable is set.
Help wanted: I am lazy to impl.
Discussion needed: some design choices needed.
Rationale
Currently almost all (AFAIK, all) Zig packages (ghostty, ncdu, etc.) are compiled targeting either Zig baseline or build host. We should make them target the baseline of AOSC OS.
Background
build-{exe,lib,obj}build target is specified with a target query (i.e.-target <arch><sub>-<os>-<abi>) and a CPU model string (-mcpu [cpu][feature set]).build(Zig Build System) provides a "standard" (sic.) way to specify build target (i.e.-Dtarget=,-Dcpu). Packages may adopt their own way to specify target or disallow specifying build target (Very rarely; I haven't seen any packages doing so; These should be fixed in upstream).loongarch{,_nosimd}).Proposal
ZIG_TARGETandZIG_CPUvariables to Autobuild.aosc_xxxxtarget strings (wherexxxxis the Autobuild architecture name).ABTARGETenvironment variable is set, let the standard functions of Zig Build System return the baseline target.ABenvironment variable is setAOSC_ZIG_UNCHECK_TARGETenvironment variable is set.AOSC_ZIG_UNCHECK_OPT_MODEenvironment variable is set.