Skip to content

iserv-proxy: enable --optimistic-linking on GHC ≥ 9.14#2512

Merged
hamishmack merged 1 commit into
masterfrom
hkm/iserv-optimistic-linking
May 24, 2026
Merged

iserv-proxy: enable --optimistic-linking on GHC ≥ 9.14#2512
hamishmack merged 1 commit into
masterfrom
hkm/iserv-optimistic-linking

Conversation

@hamishmack
Copy link
Copy Markdown
Collaborator

Bakes --optimistic-linking into iserv-proxy / iserv-proxy-interpreter at link time via -with-rtsopts for GHC ≥ 9.14.

GHC/Linker/Executable.hs emits this into the generated main.c as __conf.rts_opts, which setupRtsFlags processes with RtsOptsAll — bypassing the OPTION_UNSAFE gate that +RTS --optimistic-linking -RTS on the command line is subject to.

Effect: iserv's runtime linker tolerates undefined symbols when loading object files at TH-eval time. Splices that don't actually reference the missing symbol resolve instead of aborting the whole load. -rtsopts=all is kept so wrapper scripts / GHCRTS can still override at invocation.

--optimistic-linking is only available in GHC's RTS from 9.14 onwards; gated on the Nix side since cabal.project doesn't allow if inside a package stanza.

Drive-by changes

  • Refactored cabalProjectLocal for the iserv-proxy project from //-chained optionalAttrs blocks to a single string built via optionalString concatenation so the new directive composes with the existing aarch64 && <9.8 threaded gate without // clobbering.
  • Dropped the allow-newer: *:base, *:bytestring block on GHC > 9.10. The bounds in iserv-proxy.cabal (base < 5, bytestring < 0.13, etc.) already accommodate current GHCs. Hydra will tell us if a transitive package actually needs relaxation; if so we'll re-add a more targeted allow-newer once we know which one.

Pulled out of #2504 (hkm/builder-v2).

Bake `--optimistic-linking` into iserv-proxy / iserv-proxy-interpreter
at link time via `-with-rtsopts`.  `GHC/Linker/Executable.hs` emits
this into the generated `main.c` as `__conf.rts_opts`, which
`setupRtsFlags` processes with `RtsOptsAll` — bypassing the
`OPTION_UNSAFE` gate that `+RTS --optimistic-linking -RTS` on the
command line is subject to.  Makes the runtime linker tolerate
undefined symbols when loading object files at TH-eval time;
splices that don't actually reference the missing symbol then
resolve fine instead of aborting the load.  `-rtsopts=all` is kept
so wrapper scripts / GHCRTS can still override at invocation.
`--optimistic-linking` is only available in GHC's RTS from 9.14
onwards; gated on the Nix side since cabal.project doesn't allow
`if` inside a `package` stanza.

Refactor `cabalProjectLocal` for the iserv-proxy project from
`//`-chained `optionalAttrs` blocks to a single string built via
`optionalString` concatenation so the new directive can compose
with the existing aarch64+<9.8 threaded gate without the last
`//` clobbering it.

Also drop the previous `allow-newer: *:base, *:bytestring` block
on GHC > 9.10.  The bounds in iserv-proxy.cabal (`base < 5`,
`bytestring < 0.13`, etc.) already accommodate current GHCs; if a
transitive package needs relaxation we'll re-add a more targeted
allow-newer once we know which one.

Pulled out of #2504 (`hkm/builder-v2`).
@hamishmack hamishmack merged commit 7d49098 into master May 24, 2026
6168 of 6799 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant