Commit b803c406 authored by Moritz Angermann's avatar Moritz Angermann Committed by Ben Gamari
Browse files

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
parent 52065e95
...@@ -919,16 +919,14 @@ dynLoadObjs hsc_env pls objs = do ...@@ -919,16 +919,14 @@ dynLoadObjs hsc_env pls objs = do
-- can resolve dependencies when it loads this -- can resolve dependencies when it loads this
-- library. -- library.
ldInputs = ldInputs =
concatMap concatMap (\l -> [ Option ("-l" ++ l) ])
(\(lp, l) -> (nub $ snd <$> temp_sos pls)
[ Option ("-L" ++ lp) ++ concatMap (\lp -> [ Option ("-L" ++ lp)
, Option "-Xlinker" , Option "-Xlinker"
, Option "-rpath" , Option "-rpath"
, Option "-Xlinker" , Option "-Xlinker"
, Option lp , Option lp ])
, Option ("-l" ++ l) (nub $ fst <$> temp_sos pls)
])
(temp_sos pls)
++ concatMap ++ concatMap
(\lp -> (\lp ->
[ Option ("-L" ++ lp) [ Option ("-L" ++ lp)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment