[commit: ghc] master: linker: Nub rpaths (b803c40)

git at git.haskell.org git at git.haskell.org
Wed Aug 1 23:39:34 UTC 2018


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/b803c40608119469bdda330cb88860be2cbed25b/ghc

>---------------------------------------------------------------

commit b803c40608119469bdda330cb88860be2cbed25b
Author: Moritz Angermann <moritz.angermann at gmail.com>
Date:   Wed Aug 1 14:25:03 2018 -0400

    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


>---------------------------------------------------------------

b803c40608119469bdda330cb88860be2cbed25b
 compiler/ghci/Linker.hs | 18 ++++++++----------
 1 file changed, 8 insertions(+), 10 deletions(-)

diff --git a/compiler/ghci/Linker.hs b/compiler/ghci/Linker.hs
index 2af03dd..286cd0d 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)



More information about the ghc-commits mailing list