Commit 7c565de
committed
fix: export RTS symbols for GHC API programs in dynamic builds
Programs that link against the ghc package and use features like Template
Haskell or GHCi need to export RTS symbols to dynamically loaded libraries.
When these programs load Haskell shared libraries via dlopen(), those
libraries reference RTS symbols like stg_INTLIKE_closure. Without exporting
these symbols from the executable, dlopen fails with "undefined symbol".
This fix adds platform-specific linker flags to GHC's static linker when
building executables that depend on the ghc package in dynamic mode:
- Linux/FreeBSD: -rdynamic (passes --export-dynamic to ld)
- macOS: -flat_namespace (makes all symbols visible across namespaces)
- Windows: not needed (--enable-auto-import already handles this)
This complements the similar fix for ghc-iserv (f8ca34d) and fixes
testsuite failures for tests like T5313, T8639_api, and dynCompileExpr
that use the GHC API with interpreterBackend.
See Note [Export dynamic symbols for GHC API programs] in
GHC/Linker/Static.hs and Note [ghc-iserv and dynamic symbol export]
in utils/ghc-iserv/ghc-iserv.cabal.in for full details.1 parent f8ca34d commit 7c565de
1 file changed
+28
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
68 | 68 | | |
69 | 69 | | |
70 | 70 | | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
71 | 89 | | |
72 | 90 | | |
73 | 91 | | |
| |||
252 | 270 | | |
253 | 271 | | |
254 | 272 | | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
255 | 283 | | |
256 | 284 | | |
257 | 285 | | |
| |||
0 commit comments