mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-27 11:36:29 +03:00
setup-hooks/strip.sh: run RANLIB on static archives after stripping
'strip' does not normally preserve archive index in .a files. This usually causes linking failures against static libs like: $ nix build --no-link -f. pkgsCross.mingw32.re2c > ...-i686-w64-mingw32-binutils-2.38/bin/i686-w64-mingw32-ld: /nix/store/...-i686-w64-mingw32-stage-final-gcc-13.0.0-lib/i686-w64-mingw32/lib/libstdc++.dll.a: error adding symbols: archive has no index; run ranlib to add one We restore the index by running ranlib explicitly.
This commit is contained in:
parent
0f45ce6e77
commit
0507725061
1 changed files with 13 additions and 4 deletions
|
@ -10,6 +10,7 @@ _doStrip() {
|
||||||
local -ra debugDirs=(stripDebugList stripDebugListTarget)
|
local -ra debugDirs=(stripDebugList stripDebugListTarget)
|
||||||
local -ra allDirs=(stripAllList stripAllListTarget)
|
local -ra allDirs=(stripAllList stripAllListTarget)
|
||||||
local -ra stripCmds=(STRIP STRIP_FOR_TARGET)
|
local -ra stripCmds=(STRIP STRIP_FOR_TARGET)
|
||||||
|
local -ra ranlibCmds=(RANLIB RANLIB_FOR_TARGET)
|
||||||
|
|
||||||
# Strip only host paths by default. Leave targets as is.
|
# Strip only host paths by default. Leave targets as is.
|
||||||
stripDebugList=${stripDebugList:-lib lib32 lib64 libexec bin sbin}
|
stripDebugList=${stripDebugList:-lib lib32 lib64 libexec bin sbin}
|
||||||
|
@ -23,20 +24,22 @@ _doStrip() {
|
||||||
local -n debugDirList="${debugDirs[$i]}"
|
local -n debugDirList="${debugDirs[$i]}"
|
||||||
local -n allDirList="${allDirs[$i]}"
|
local -n allDirList="${allDirs[$i]}"
|
||||||
local -n stripCmd="${stripCmds[$i]}"
|
local -n stripCmd="${stripCmds[$i]}"
|
||||||
|
local -n ranlibCmd="${ranlibCmds[$i]}"
|
||||||
|
|
||||||
# `dontStrip` disables them all
|
# `dontStrip` disables them all
|
||||||
if [[ "${dontStrip-}" || "${flag-}" ]] || ! type -f "${stripCmd-}" 2>/dev/null
|
if [[ "${dontStrip-}" || "${flag-}" ]] || ! type -f "${stripCmd-}" 2>/dev/null
|
||||||
then continue; fi
|
then continue; fi
|
||||||
|
|
||||||
stripDirs "$stripCmd" "$debugDirList" "${stripDebugFlags:--S}"
|
stripDirs "$stripCmd" "$ranlibCmd" "$debugDirList" "${stripDebugFlags:--S}"
|
||||||
stripDirs "$stripCmd" "$allDirList" "${stripAllFlags:--s}"
|
stripDirs "$stripCmd" "$ranlibCmd" "$allDirList" "${stripAllFlags:--s}"
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
stripDirs() {
|
stripDirs() {
|
||||||
local cmd="$1"
|
local cmd="$1"
|
||||||
local dirs="$2"
|
local ranlibCmd="$2"
|
||||||
local stripFlags="$3"
|
local dirs="$3"
|
||||||
|
local stripFlags="$4"
|
||||||
local dirsNew=
|
local dirsNew=
|
||||||
|
|
||||||
local d
|
local d
|
||||||
|
@ -50,5 +53,11 @@ stripDirs() {
|
||||||
if [ -n "${dirs}" ]; then
|
if [ -n "${dirs}" ]; then
|
||||||
echo "stripping (with command $cmd and flags $stripFlags) in$dirs"
|
echo "stripping (with command $cmd and flags $stripFlags) in$dirs"
|
||||||
find $dirs -type f -exec $cmd $stripFlags '{}' \; 2>/dev/null
|
find $dirs -type f -exec $cmd $stripFlags '{}' \; 2>/dev/null
|
||||||
|
# 'strip' does not normally preserve archive index in .a files.
|
||||||
|
# This usually causes linking failures against static libs like:
|
||||||
|
# ld: ...-i686-w64-mingw32-stage-final-gcc-13.0.0-lib/i686-w64-mingw32/lib/libstdc++.dll.a:
|
||||||
|
# error adding symbols: archive has no index; run ranlib to add one
|
||||||
|
# Restore the index by running 'ranlib'.
|
||||||
|
find $dirs -name '*.a' -type f -exec $ranlibCmd '{}' \; 2>/dev/null
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue