diff options
author | Sergei Trofimovich <slyich@gmail.com> | 2022-08-07 09:05:33 +0100 |
---|---|---|
committer | Sergei Trofimovich <slyich@gmail.com> | 2022-08-07 12:49:37 +0100 |
commit | b3b672d5a16a0e99dc112b9f65436555b11c3ab7 (patch) | |
tree | 0742d0f2240ca07aa5482e6106401b4dce5823c4 /pkgs/build-support/setup-hooks | |
parent | cfd4ea64f48a846525e3b7bc0e2074ffbce6b1ce (diff) |
setup-hooks/separate-debug-info.sh: don't inhibit strip hook
Before the change separate-debug-info.sh did the stripping itself. This scheme has a few problems: 1. Stripping happens only on ELF files. *.a and *.o files are skipped. Derivations have to do it manually. Usually incorrectly as they don't run $RANLIB (true for `glibc` and `musl`). 2. Stripping happens on all paths. Ideally only `stripDebugList` paths should be considered. 3. Host strip is called on Target files. This change offloads stripping logic to strip hook. This strips more files for `glibc` and `musl`. Now we can remove most $STRIP calls from individual derivations. Co-authored-by: Sandro <sandro.jaeckel@gmail.com>
Diffstat (limited to 'pkgs/build-support/setup-hooks')
-rw-r--r-- | pkgs/build-support/setup-hooks/separate-debug-info.sh | 2 | ||||
-rw-r--r-- | pkgs/build-support/setup-hooks/strip.sh | 23 |
2 files changed, 12 insertions, 13 deletions
diff --git a/pkgs/build-support/setup-hooks/separate-debug-info.sh b/pkgs/build-support/setup-hooks/separate-debug-info.sh index 593a5f64862de..be94af545be17 100644 --- a/pkgs/build-support/setup-hooks/separate-debug-info.sh +++ b/pkgs/build-support/setup-hooks/separate-debug-info.sh @@ -2,7 +2,6 @@ export NIX_SET_BUILD_ID=1 export NIX_LDFLAGS+=" --compress-debug-sections=zlib" export NIX_CFLAGS_COMPILE+=" -ggdb -Wa,--compress-debug-sections" export RUSTFLAGS+=" -g" -dontStrip=1 fixupOutputHooks+=(_separateDebugInfo) @@ -35,7 +34,6 @@ _separateDebugInfo() { # firmware blobs in QEMU.) ( $OBJCOPY --only-keep-debug "$i" "$dst/${id:0:2}/${id:2}.debug" - $STRIP --strip-debug "$i" # Also a create a symlink <original-name>.debug. ln -sfn ".build-id/${id:0:2}/${id:2}.debug" "$dst/../$(basename "$i")" diff --git a/pkgs/build-support/setup-hooks/strip.sh b/pkgs/build-support/setup-hooks/strip.sh index b2d0841888fff..9bd7b24cab545 100644 --- a/pkgs/build-support/setup-hooks/strip.sh +++ b/pkgs/build-support/setup-hooks/strip.sh @@ -38,26 +38,27 @@ _doStrip() { stripDirs() { local cmd="$1" local ranlibCmd="$2" - local dirs="$3" + local paths="$3" local stripFlags="$4" - local dirsNew= + local pathsNew= - local d - for d in ${dirs}; do - if [ -e "$prefix/$d" ]; then - dirsNew="${dirsNew} $prefix/$d " + local p + for p in ${paths}; do + if [ -e "$prefix/$p" ]; then + pathsNew="${pathsNew} $prefix/$p" fi done - dirs=${dirsNew} + paths=${pathsNew} - if [ -n "${dirs}" ]; then - echo "stripping (with command $cmd and flags $stripFlags) in$dirs" - find $dirs -type f -exec $cmd $stripFlags '{}' \; 2>/dev/null + if [ -n "${paths}" ]; then + echo "stripping (with command $cmd and flags $stripFlags) in $paths" + # Do not strip lib/debug. This is a directory used by setup-hooks/separate-debug-info.sh. + find $paths -type f -a '!' -wholename "$prefix/lib/debug/*" -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 + find $paths -name '*.a' -type f -exec $ranlibCmd '{}' \; 2>/dev/null fi } |