binutils-wrapper: Try to avoid adding unnecessary -L flags

(cherry picked from commit f3758258b8895508475caf83e92bfb236a27ceb9)
Signed-off-by: Domen Kožar <domen@dev.si>
This commit is contained in:
Tuomas Tynkkynen 2018-07-21 16:22:17 +03:00 committed by Domen Kožar
parent 37273afd27
commit 24596d7a4a
No known key found for this signature in database
GPG Key ID: C2FFBCAFD2C24246

View File

@ -20,7 +20,13 @@ bintoolsWrapper_addLDVars () {
fi
if [[ -d "$1/lib" ]]; then
export NIX_${role_pre}LDFLAGS+=" -L$1/lib"
# Don't add the /lib directory if it actually doesn't contain any libraries. For instance,
# Python and Haskell packages often only have directories like $out/lib/ghc-8.4.3/ or
# $out/lib/python3.6/, so having them in LDFLAGS just makes the linker search unnecessary
# directories and bloats the size of the environment variable space.
if [[ -n "$(echo $1/lib/lib*)" ]]; then
export NIX_${role_pre}LDFLAGS+=" -L$1/lib"
fi
fi
}