bintools-wrapper: skip dynamic linker for static binaries

Currently we set dynamic-linker unconditionally. This breaks
however some static binaries i.e. rust binaries linked against musl.
There is no reason we should set an elf interpreter for static binaries
hence this is skipped if `-static` or `-static-pie` is either passed to
our cc or ld wrapper.
This commit is contained in:
Jörg Thalheim
2020-12-14 15:42:54 +00:00
parent c2842e5ad4
commit ccfd26ef14
5 changed files with 40 additions and 12 deletions
@@ -28,6 +28,7 @@ cc1=0
[[ "@prog@" = *++ ]] && isCpp=1 || isCpp=0
cppInclude=1
cInclude=1
setDynamicLinker=1
expandResponseParams "$@"
declare -i n=0
@@ -58,6 +59,8 @@ while (( "$n" < "$nParams" )); do
cppInclude=0
elif [ "$p" = -nostdinc++ ]; then
cppInclude=0
elif [[ "$p" = -static || "$p" = -static-pie ]]; then
setDynamicLinker=0
elif [[ "$p" != -?* ]]; then
# A dash alone signifies standard input; it is not a flag
nonFlagArgs=1
@@ -152,6 +155,9 @@ if [ "$dontLink" != 1 ]; then
for i in $NIX_LDFLAGS_BEFORE_@suffixSalt@; do
extraBefore+=("-Wl,$i")
done
if [ "$setDynamicLinker" = 1 ]; then
extraBefore+=("-Wl,-dynamic-linker=$NIX_DYNAMIC_LINKER_@suffixSalt@")
fi
for i in $NIX_LDFLAGS_@suffixSalt@; do
if [ "${i:0:3}" = -L/ ]; then
extraAfter+=("$i")