gcc: extend stripping of .a libraries and .o objects

The initial intent was to strip .a and .o files, not .a.o files.
While at it expanded stripping for $lib output as well.

Without the change `libgcc.a` was not stripped and `.debug*` sections
made into final binaries. It's not a problem on it's own, but it's an
unintended side-effect. Noticed on `crystal_1_0` test failure where
`crystal` was not able to handle `dwarf-5`.

While at it allowed absolute file names to be passed to stripDebugList
and friends.
This commit is contained in:
Sergei Trofimovich 2022-08-02 23:02:15 +01:00
parent ba7495e552
commit c817efe660
2 changed files with 27 additions and 12 deletions

View file

@ -44,7 +44,7 @@ stripDirs() {
local d
for d in ${dirs}; do
if [ -d "$prefix/$d" ]; then
if [ -e "$prefix/$d" ]; then
dirsNew="${dirsNew} $prefix/$d "
fi
done

View file

@ -8,7 +8,9 @@
# Example ARM breakage by x86_64 strip: https://bugs.gentoo.org/697428
#
# Let's recap the file layout for directories with object files for a
# cross-compiler (host != target):
# cross-compiler:
#
# $out (host != target)
# `- bin: HOST
# lib/*.{a,o}: HOST
# `- gcc/<TARGET>/<VERSION>/*.{a,o}: TARGET
@ -17,10 +19,16 @@
# `- libexec/: HOST
# `- <TARGET>/: TARGET
#
# (host == target) has identical directory layout.
# $out (host == target) has identical directory layout.
#
# $lib (host != target):
# `- <TARGET>/lib/*.{la,so}: TARGET
#
# $lib (host == target):
# `- lib/*.{la,so}: HOST
# The rest of stripDebugList{Host,Target} will be populated in
# postInstall.
# postInstall to disambiguate lib/ object files.
stripDebugList = [ "bin" "libexec" ];
stripDebugListTarget = [ stdenv.targetPlatform.config ];
@ -32,21 +40,28 @@
shopt -s nullglob
pushd $out
local -ar hostFiles=(
lib{,32,64}/*.{a.o}
local -ar outHostFiles=(
lib{,32,64}/*.{a,o,so*}
lib{,32,64}/gcc/${stdenv.targetPlatform.config}/*/plugin
)
local -ar targetFiles=(
lib{,32,64}/gcc/${stdenv.targetPlatform.config}/*/*.{a.o}
local -ar outTargetFiles=(
lib{,32,64}/gcc/${stdenv.targetPlatform.config}/*/*.{a,o,so*}
)
popd
stripDebugList="$stripDebugList ''${hostFiles[*]}"
stripDebugListTarget="$stripDebugListTarget ''${targetFiles[*]}"
pushd $lib
local -ar libHostFiles=(
lib{,32,64}/*.{a,o,so*}
)
local -ar libTargetFiles=(
lib{,32,64}/${stdenv.targetPlatform.config}/*.{a,o,so*}
)
popd
eval "$oldOpts"
stripDebugList="$stripDebugList ''${outHostFiles[*]} ''${libHostFiles[*]}"
stripDebugListTarget="$stripDebugListTarget ''${outTargetFiles[*]} ''${libTargetFiles[*]}"
}
updateDebugListPaths
'';