Merge pull request #29568 from obsidiansystems/cc-wrapper-32
cc-wrapper: Clean up dynamic linking with x86 multilib
This commit is contained in:
commit
3c3d8710b5
|
@ -61,10 +61,6 @@ while (( "$n" < "$nParams" )); do
|
||||||
cppInclude=0
|
cppInclude=0
|
||||||
elif [ "${p:0:1}" != - ]; then
|
elif [ "${p:0:1}" != - ]; then
|
||||||
nonFlagArgs=1
|
nonFlagArgs=1
|
||||||
elif [ "$p" = -m32 ]; then
|
|
||||||
if [ -e @out@/nix-support/dynamic-linker-m32 ]; then
|
|
||||||
NIX_@infixSalt@_LDFLAGS+=" -dynamic-linker $(< @out@/nix-support/dynamic-linker-m32)"
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
n+=1
|
n+=1
|
||||||
done
|
done
|
||||||
|
|
|
@ -67,12 +67,22 @@ fi
|
||||||
|
|
||||||
extraAfter+=($NIX_@infixSalt@_LDFLAGS_AFTER)
|
extraAfter+=($NIX_@infixSalt@_LDFLAGS_AFTER)
|
||||||
|
|
||||||
|
# Three tasks:
|
||||||
|
#
|
||||||
|
# 1. Find all -L... switches for rpath
|
||||||
|
#
|
||||||
|
# 2. Find relocatable flag for build id.
|
||||||
|
#
|
||||||
|
# 3. Choose 32-bit dynamic linker if needed
|
||||||
declare -a libDirs
|
declare -a libDirs
|
||||||
declare -A libs
|
declare -A libs
|
||||||
relocatable=
|
declare -i relocatable=0 link32=0
|
||||||
|
|
||||||
# Find all -L... switches for rpath, and relocatable flags for build id.
|
if
|
||||||
if [ "$NIX_@infixSalt@_DONT_SET_RPATH" != 1 ] || [ "$NIX_@infixSalt@_SET_BUILD_ID" = 1 ]; then
|
[ "$NIX_@infixSalt@_DONT_SET_RPATH" != 1 ] \
|
||||||
|
|| [ "$NIX_@infixSalt@_SET_BUILD_ID" = 1 ] \
|
||||||
|
|| [ -e @out@/nix-support/dynamic-linker-m32 ]
|
||||||
|
then
|
||||||
prev=
|
prev=
|
||||||
# Old bash thinks empty arrays are undefined, ugh.
|
# Old bash thinks empty arrays are undefined, ugh.
|
||||||
for p in \
|
for p in \
|
||||||
|
@ -87,6 +97,13 @@ if [ "$NIX_@infixSalt@_DONT_SET_RPATH" != 1 ] || [ "$NIX_@infixSalt@_SET_BUILD_I
|
||||||
-l)
|
-l)
|
||||||
libs["lib${p}.so"]=1
|
libs["lib${p}.so"]=1
|
||||||
;;
|
;;
|
||||||
|
-m)
|
||||||
|
# Presumably only the last `-m` flag has any effect.
|
||||||
|
case "$p" in
|
||||||
|
elf_i386) link32=1;;
|
||||||
|
*) link32=0;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
-dynamic-linker | -plugin)
|
-dynamic-linker | -plugin)
|
||||||
# Ignore this argument, or it will match *.so and be added to rpath.
|
# Ignore this argument, or it will match *.so and be added to rpath.
|
||||||
;;
|
;;
|
||||||
|
@ -112,6 +129,14 @@ if [ "$NIX_@infixSalt@_DONT_SET_RPATH" != 1 ] || [ "$NIX_@infixSalt@_SET_BUILD_I
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -e "@out@/nix-support/dynamic-linker-m32" ] && (( "$link32" )); then
|
||||||
|
# We have an alternate 32-bit linker and we're producing a 32-bit ELF, let's
|
||||||
|
# use it.
|
||||||
|
extraAfter+=(
|
||||||
|
'-dynamic-linker'
|
||||||
|
"$(< @out@/nix-support/dynamic-linker-m32)"
|
||||||
|
)
|
||||||
|
fi
|
||||||
|
|
||||||
# Add all used dynamic libraries to the rpath.
|
# Add all used dynamic libraries to the rpath.
|
||||||
if [ "$NIX_@infixSalt@_DONT_SET_RPATH" != 1 ]; then
|
if [ "$NIX_@infixSalt@_DONT_SET_RPATH" != 1 ]; then
|
||||||
|
@ -154,7 +179,7 @@ fi
|
||||||
|
|
||||||
# Only add --build-id if this is a final link. FIXME: should build gcc
|
# Only add --build-id if this is a final link. FIXME: should build gcc
|
||||||
# with --enable-linker-build-id instead?
|
# with --enable-linker-build-id instead?
|
||||||
if [ "$NIX_@infixSalt@_SET_BUILD_ID" = 1 ] && [ ! "$relocatable" ]; then
|
if [ "$NIX_@infixSalt@_SET_BUILD_ID" = 1 ] && ! (( "$relocatable" )); then
|
||||||
extraAfter+=(--build-id)
|
extraAfter+=(--build-id)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue