Commit a60c134
committed
Add
This matches the behavior of Cabal when linking binaries. Without this
flag, will GHC statically link every implicit dependency provided by the
global package database. I've noticed a few strange behaviors caused by
this, all involving `haskell_prebuilt_library`:
- `examples/with_prelude/haskell` segfaults on macOS. The binary
contains both statically and dynamically linked copies of `rts`, but
only the static copy is initialized. The dynamic copy comes via
`//haskell:library` (`haskell_library` passes `-dynamic`). Linux
symbol namespacing would merge the two, but macOS doesn't.
- if the global package database is limited to only `rts` (GHC is
hard-coded to require this), linking fails on Linux using lld. Linking
the static `rts` against a dynamic `base` would require creating copy
relocations for read-only symbols in `base`.
- if the global package database is limited as above, any resulting
binary would throw a runtime linker error on macOS. On macOS, GHC sets
`-dead_strip_dylibs` to remove unused dylibs. During static linking,
symbols required by `base` are removed and the `rts` dylib is stripped
as dead code.
I can't find a reason for why the flag was originally excluded. Based on
the issues it causes, including it seems like the correct behavior.-dynamic when linking shared haskell_binary1 parent 9e72fd5 commit a60c134
2 files changed
Lines changed: 2 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | | - | |
| 20 | + | |
21 | 21 | | |
22 | | - | |
23 | | - | |
24 | 22 | | |
25 | 23 | | |
26 | 24 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1133 | 1133 | | |
1134 | 1134 | | |
1135 | 1135 | | |
1136 | | - | |
| 1136 | + | |
1137 | 1137 | | |
1138 | 1138 | | |
1139 | 1139 | | |
| |||
0 commit comments