Complete the end-to-end FreeBSD cross-compile: `blaise --target freebsd-x86_64`
now emits a static, freestanding FreeBSD ET_EXEC on a Linux host with no
external tools.
Target selection through the linker:
* TargetIsFreestanding(target) — FreeBSD (Strategy B: direct syscalls, no
libc) is always a static ET_EXEC. LinkViaInternalLinker sets dynamic mode
to `not (AOpts.Static or freestanding)`, and EnsureRTLObjects selects the
freestanding kernel-leaf unit list the same way — so a FreeBSD target links
the syscall/libc-shim/thread leaves and no libc, regardless of --static.
Per-target platform layout (dependency injection off --target):
* The concrete TPlatformLayout adapter (rtl.platform.layout.<os>) is selected
and linked by the driver (BuildRTLUnitList), and the compiler injects a
direct call to that unit's initialiser — PlatformLayoutInitSym(target) =
rtl.platform.layout.<os>_init — into main, first, for the compile-time
--target. rtl.platform.posix no longer `uses` a concrete layout, so the
shared POSIX code is OS-agnostic and a FreeBSD build carries no Linux layout.
* Bootstrap fallback: each layout unit also defines a WEAK _BlaisePlatformInit
trampoline that _SetArgs calls, so a binary built by an older codegen (which
does not emit main's by-name call) still initialises GPlatformLayout. Weak
binding lets both layout units coexist in one link (e.g. the TestRunner,
which imports the FreeBSD layout via cp.test.platformlayout.freebsd) without
a duplicate-symbol error — the linker keeps the first-seen (host) copy.
FreeBSD libc-shaped leaf:
* New runtime.libc.freebsd (sibling of runtime.libc.linux): getcwd/getenv/
time/waitpid/execvp/sysconf on the FreeBSD syscall leaf. time() reads
CLOCK_REALTIME (no SYS_time on FreeBSD); sysconf(CPU count) uses
sysctl(hw.ncpu) — new SYS___sysctl=202 leaf, MIB {CTL_HW=6, HW_NCPU=3}.
Tests:
* TTargetToolkitTests.TestTargetIsFreestanding_{FreeBSD_True,Linux_False}.
* TInternalLinkerE2ETests.TestCompile_FreeBSDTarget_EmitsStaticFreeBSDExe —
a full compiler-CLI cross-compile asserting EI_OSABI=9, ET_EXEC, no
PT_INTERP (the binary cannot run on the Linux host, so shape only).
Verified: all four fixpoints green; full suite passes under QBE-built and
native-built test runner (4029 tests); the previously latent TestRunner
GPlatformLayout crash is resolved.