summaryrefslogtreecommitdiff
path: root/compiler/ghci
diff options
context:
space:
mode:
authorMoritz Angermann <moritz.angermann@gmail.com>2018-08-01 14:25:03 -0400
committerBen Gamari <ben@smart-cactus.org>2018-08-01 19:38:48 -0400
commitb803c40608119469bdda330cb88860be2cbed25b (patch)
tree2c9d5159982135405625536b7b36e86efdaf7fcb /compiler/ghci
parent52065e95c6df89d0048c6e3f35d6cc26ce8246f9 (diff)
downloadhaskell-b803c40608119469bdda330cb88860be2cbed25b.tar.gz
linker: Nub rpaths
When compiling and linking files in `ghci`, we keep adding rpath arguments to the linker command invoation. If those are identical we should `nub` them out. Otherwise we not only risk overflowing the argument limit, but also embed huge amounts of identical rpath values into the dynamic library, eventually leading to the overflow of the load command size limit, due to the number of rpath entries alone. A further improvement could be to pass `-Xlinker -dead_strip_dylibs`; that however might be stipping too aggressively, and potentially lead to missing symbols? For the time being I suggest to only do the nubbing and if need be to provide -Wl,-dead_strip_dylibs when invoking ghci. Test Plan: ./validate Reviewers: bgamari, hvr Reviewed By: bgamari Subscribers: rwbarton, thomie, carter GHC Trac Issues: #15446 Differential Revision: https://phabricator.haskell.org/D5021
Diffstat (limited to 'compiler/ghci')
-rw-r--r--compiler/ghci/Linker.hs18
1 files changed, 8 insertions, 10 deletions
diff --git a/compiler/ghci/Linker.hs b/compiler/ghci/Linker.hs
index 2af03ddde8..286cd0d23c 100644
--- a/compiler/ghci/Linker.hs
+++ b/compiler/ghci/Linker.hs
@@ -919,16 +919,14 @@ dynLoadObjs hsc_env pls objs = do
-- can resolve dependencies when it loads this
-- library.
ldInputs =
- concatMap
- (\(lp, l) ->
- [ Option ("-L" ++ lp)
- , Option "-Xlinker"
- , Option "-rpath"
- , Option "-Xlinker"
- , Option lp
- , Option ("-l" ++ l)
- ])
- (temp_sos pls)
+ concatMap (\l -> [ Option ("-l" ++ l) ])
+ (nub $ snd <$> temp_sos pls)
+ ++ concatMap (\lp -> [ Option ("-L" ++ lp)
+ , Option "-Xlinker"
+ , Option "-rpath"
+ , Option "-Xlinker"
+ , Option lp ])
+ (nub $ fst <$> temp_sos pls)
++ concatMap
(\lp ->
[ Option ("-L" ++ lp)