mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-02 15:41:48 +00:00
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
|
||||
elif [ "${p:0:1}" != - ]; then
|
||||
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
|
||||
n+=1
|
||||
done
|
||||
|
@ -67,12 +67,22 @@ fi
|
||||
|
||||
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 libs
|
||||
relocatable=
|
||||
declare -i relocatable=0 link32=0
|
||||
|
||||
# Find all -L... switches for rpath, and relocatable flags for build id.
|
||||
if [ "$NIX_@infixSalt@_DONT_SET_RPATH" != 1 ] || [ "$NIX_@infixSalt@_SET_BUILD_ID" = 1 ]; then
|
||||
if
|
||||
[ "$NIX_@infixSalt@_DONT_SET_RPATH" != 1 ] \
|
||||
|| [ "$NIX_@infixSalt@_SET_BUILD_ID" = 1 ] \
|
||||
|| [ -e @out@/nix-support/dynamic-linker-m32 ]
|
||||
then
|
||||
prev=
|
||||
# Old bash thinks empty arrays are undefined, ugh.
|
||||
for p in \
|
||||
@ -87,6 +97,13 @@ if [ "$NIX_@infixSalt@_DONT_SET_RPATH" != 1 ] || [ "$NIX_@infixSalt@_SET_BUILD_I
|
||||
-l)
|
||||
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)
|
||||
# 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
|
||||
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.
|
||||
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
|
||||
# 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)
|
||||
fi
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user