nub rpaths
ClosedPublic

Authored by angerman on Jul 28 2018, 9:49 PM.

Details

Summary

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 sugget to only do the nubbing and if need be to provide
-Wl,-dead_strip_dylibs when invoking ghci.

Test Plan

./validate

Diff Detail

Repository
rGHC Glasgow Haskell Compiler
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
angerman created this revision.Jul 28 2018, 9:49 PM

This changes the order of these arguments, does it not? Does the -l not need to come after the -L?

This changes the order of these arguments, does it not? Does the -l not need to come after the -L?

I'm fairly certain that only the order of the -l and -L flags on their own are important. E.g. -lfoo -lbar != -lbar -lfoo.

All -L options apply to all -l options, regardless of the order in which the options appear.

from https://ftp.gnu.org/old-gnu/Manuals/ld-2.9.1/html_node/ld_3.html

The only caveat is that the nubing of the -l flags could potentially cause issues where we need recursive linking; in the case of ghci's incremental modules, I doubt that that is an issue though.

bgamari accepted this revision.Aug 1 2018, 1:24 PM

Alright, sure. Let's give it a shot.

This revision is now accepted and ready to land.Aug 1 2018, 1:24 PM
Closed by commit rGHCb803c4060811: linker: Nub rpaths (authored by Moritz Angermann <moritz.angermann@gmail.com>, committed by bgamari). · Explain WhyAug 1 2018, 6:39 PM
This revision was automatically updated to reflect the committed changes.