linker: Nub rpaths
authorMoritz Angermann <moritz.angermann@gmail.com>
Wed, 1 Aug 2018 18:25:03 +0000 (14:25 -0400)
committerBen Gamari <ben@smart-cactus.org>
Wed, 1 Aug 2018 23:38:48 +0000 (19:38 -0400)
commitb803c40608119469bdda330cb88860be2cbed25b
tree2c9d5159982135405625536b7b36e86efdaf7fcb
parent52065e95c6df89d0048c6e3f35d6cc26ce8246f9
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
compiler/ghci/Linker.hs