You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
macOS arm64 (Apple Silicon) refuses to exec a non-PIE main executable — proven on
macos-14 in #1718 (the linker even forces PIE: -no_pie ignored for arm64). mach
emits a non-PIE fixed-absolute image (__TEXT at 0xfffff000, empty rebase stream),
so its arm64 darwin binaries are Killed: 9 at exec. This issue makes mach emit a
genuine PIE Mach-O executable so the darwin self-host runs on Apple Silicon.
The investigation (#1718) already prototyped the cheap parts and ruled out the
expensive alternatives — keep raw svc (no libSystem syscall routing), classic LC_DYLD_INFO rebase (no chained fixups), zero dylib dependency. The prototypes live
on branch invel/1718-scope (env-gated LC_MAIN/LC_BUILD_VERSION/LC_UUID/MH_PIE
toggles in emit_dyn_exec); use them as the starting point.
Linker (src/lang/be/linker.mach): collect the in-image absolute relocations
(global pointers, vtable function pointers, absolute data relocs) into rebase
records for the writer. arm64 TEXT is already PC-relative; the rebase work is in
absolute DATA pointers. This is the dominant cost of the issue.
Route the compiler's darwin self-host through this PIE writer (it has no dynamic
imports, so the dynamic path collapses to "PIE + rebase, zero dylibs").
The rebase stream is well-formed (llvm-objdump/otool: MH_PIE, LC_MAIN, LC_DYLD_INFO rebase opcodes resolve to the right addresses); the ad-hoc signature
still validates.
x86_64-darwin, linux, and windows output unaffected; the linux self-host fixpoint
stays byte-identical and mach test . green.
Part of #1718. Blocks the aarch64 leg of #1680.
What
macOS arm64 (Apple Silicon) refuses to exec a non-PIE main executable — proven on
macos-14 in #1718 (the linker even forces PIE:
-no_pie ignored for arm64). machemits a non-PIE fixed-absolute image (
__TEXTat0xfffff000, empty rebase stream),so its arm64 darwin binaries are
Killed: 9at exec. This issue makes mach emit agenuine PIE Mach-O executable so the darwin self-host runs on Apple Silicon.
The investigation (#1718) already prototyped the cheap parts and ruled out the
expensive alternatives — keep raw
svc(no libSystem syscall routing), classicLC_DYLD_INFOrebase (no chained fixups), zero dylib dependency. The prototypes liveon branch
invel/1718-scope(env-gatedLC_MAIN/LC_BUILD_VERSION/LC_UUID/MH_PIEtoggles in
emit_dyn_exec); use them as the starting point.Scope:
src/lang/target/of/macho.mach): emit a position-independent image —MH_PIEheader flag, a relocatable layout (PIE base, not the current fixed0xfffff000), anLC_MAINentry (replacingLC_UNIXTHREADfor the darwin mainexecutable),
LC_BUILD_VERSION,LC_UUID, and anLC_DYLD_INFO(_ONLY)carrying arebase stream — classic rebase opcodes (
REBASE_OPCODE_*) covering everyin-image absolute pointer, so dyld slides them by the load bias. No imports ⇒ no
dylibs / stubs / GOT / bind stream. Keep the ad-hoc
LC_CODE_SIGNATURE(codegen/link: emit ad-hoc Mach-O code signature so Darwin executables run on Apple Silicon #1679) andthe header-in-
__TEXTlayout (codegen/link(macho): static executables map the mach header outside __TEXT → SIGKILL on Apple Silicon #1717).src/lang/be/linker.mach): collect the in-image absolute relocations(global pointers, vtable function pointers, absolute data relocs) into rebase
records for the writer. arm64 TEXT is already PC-relative; the rebase work is in
absolute DATA pointers. This is the dominant cost of the issue.
imports, so the dynamic path collapses to "PIE + rebase, zero dylibs").
LC_MAINentry change (briar-systems/mach-std, the epic: dynamic libSystem-linked darwin executables (Apple Silicon rejects static images) #1718child) — the register-convention entry the PIE
LC_MAINjumps to.Acceptance
aarch64-darwinPIE executable execs on a macos-14 runner (noKilled: 9); the nativea→b→cdarwin fixpoint converges andmach test .passeson Apple Silicon. Validate via infra: CD-authored darwin release build (x86_64 + aarch64, native fixpoint) #1680's
workflow_dispatch.MH_PIE,LC_MAIN,LC_DYLD_INFOrebase opcodes resolve to the right addresses); the ad-hoc signaturestill validates.
x86_64-darwin, linux, and windows output unaffected; the linux self-host fixpointstays byte-identical and
mach test .green.