Mirrored from home-lang/home-os#52 (Raspberry Pi 5 media-center epic home-lang/home-os#113). Compiler work happens here; the OS issue tracks consumption.
Why
src/main.zig picks the backend from the host CPU (builtin.target.cpu.arch == .aarch64 → arm64 path, else x86). --target is parsed (L2895–2909) but the kernel path ignores it. packages/build/src/cross_compilation.zig already models Arch{x86_64, aarch64, …} and Target.parse("aarch64-linux-gnu"), and packages/build/src/linker_arm64.ld exists — none of it is wired to home build --kernel. CI runs on x86 ubuntu-latest, so cross-compilation is mandatory, not optional.
Tasks
- Wire
--target=<arch>-freestandinginto the--kernelpath; default = host; reject unknown. - Emit assembly the assembler for that arch accepts (
zig cc -c -x assembler -target aarch64-freestanding, matching howscripts/build.shalready drives x86) and/or direct ELF64EM_AARCH64objects viapackages/codegen/src/elf.zig(which already has.aarch64), withR_AARCH64_ADR_PREL_PG_HI21/ADD_ABS_LO12_NC/CALL26relocations. - Section discipline the Pi linker script needs:
.text.bootfirst,.rodata,.data,.bsswith__bss_start/__bss_end, 4 KB alignment for page tables (align(4096)in Home →.balign 4096). home build --kernel --target=aarch64-freestanding --emit=asm|objdocumented in the compiler README; addaarch64-freestandingto the compiler's CI matrix (x86 host cross-assembling, no runner change).- Bump
HOME_COMPILER_REFin.github/workflows/ci.ymlonce landed.
Acceptance
On an x86 Linux CI runner and on an Apple-Silicon Mac, the same command produces a byte-identical aarch64 ELF for rung 1 of home-lang/home-os#51, and readelf -h shows AArch64.
Size: M · Depends on: home-lang/home-os#51 (rung 1) · Blocks: home-lang/home-os#54