perf(macos): enable chained fixups to cut pre-main startup (~0.8ms) (#35409)
## Summary
The macOS binary ships with the legacy **`LC_DYLD_INFO_ONLY`** fixup
format. At
launch dyld must eagerly walk a rebase/bind opcode stream and apply
every
internal-pointer relocation in the ~116MB binary — all before `main()`
runs
(pre-main).
Switching to the modern **`LC_DYLD_CHAINED_FIXUPS`** format lets dyld
apply
fixups lazily, per-page, on fault instead of eagerly at launch. This
measurably
cuts pre-main startup time.
The format requires a macOS 12 deployment target (older dyld can't parse
it).
`lld` (which we use via `-fuse-ld=lld`) only emits it automatically at a
min-13.0
target, so we request it explicitly with `-Wl,-fixup_chains` to keep
macOS 12
support rather than dropping to 13.
## Change
```toml
# .cargo/config.toml
[env]
MACOSX_DEPLOYMENT_TARGET = "12.0"
# + `-Wl,-fixup_chains` added to the apple-darwin link args
```
## Results (arm64, release, `deno run hello.js`, warm,
overhead-corrected min of 150 runs)
| build | fixup format | min macOS | startup |
|---|---|---|---|
| before | `LC_DYLD_INFO_ONLY` | 11.0 | ~9.8ms |
| **after** | **`LC_DYLD_CHAINED_FIXUPS`** | **12.0** | **~9.0ms** |
| **delta** | | | **~0.8ms** |
The entire win is pre-main — the in-`main` startup phases are unchanged.
Verified
`otool -l` reports `LC_DYLD_CHAINED_FIXUPS` and `minos 12.0`, and the
binary runs
correctly.
## Notes
- **Drops macOS 11 (Big Sur) support; requires macOS 12 (Monterey, Oct
2021)+.**
This is the only user-visible tradeoff.
- Ruled out as non-factors while investigating: stripping symbols
(116MB→80MB)
has zero startup effect — symbols live in `__LINKEDIT` and are never
mapped for
execution; static initializers are negligible (15 total).