separate-debug-info setup hook: strip debug symbols from static libs#164520
separate-debug-info setup hook: strip debug symbols from static libs#164520risicle wants to merge 3 commits intoNixOS:stagingfrom
Conversation
to allow us to identify AR archives (possibly static libraries)
this should make it less risky to enable separateDebugInfo as otherwise it may result in massive static libraries
this should now be automatically done by separateDebugInfo
| local id="$($READELF -n "$i" | sed 's/.*Build ID: \([0-9a-f]*\).*/\1/; t; d')" | ||
| if [ "${#id}" != 40 ]; then | ||
| echo "could not find build ID of $i, skipping" >&2 | ||
| continue |
There was a problem hiding this comment.
maybe we should strip .so without Build IDs as well, they could be unexpected bloat.
There was a problem hiding this comment.
🤔 Yes, interesting. The more I think about this, the more it feels what we should actually be doing is falling through to allow the regular strip setup hook to do its job afterwards instead of disabling it with dontStrip. Because surely after this hook's run all the outputs other than debug are safe to strip. Should this setup hook perhaps just concern itself with pulling the debug info out to debug and leave the existing stripping mechanisms to continue operating as normal?
Though that would be a bigger change and I'm not confident I'd understand all the ramifications of that.
|
Can I help get this merged? |
|
I think this may have been superseded by #185537 |
|
Reproducer: Resulting drv:
Size of openssl binary (apparently unstripped given After manual stripping using It seems to be working as intended. |
Description of changes
Currently,
separateDebugInfo = truewill cause binaries to be built with debug symbols, before "separating" them in a setup hook. The problem is, this setup hook doesn't take static libraries into account and so they end up retaining their debug info. This often makes them huge and is what caused the reversion of the first attempt at addingseparateDebugInfoto cpython in #93083.This adds the ability to detect AR archives to the generic setup script, then makes the
separate-debug-info.shattempt to strip any likely-static-libraries it finds.Separate debug info for static libraries reportedly doesn't really work and outputting the unstripped version of the library to the debug output is something I don't see as being significantly more useful than making the user do a
dontStripbuild. Though it would significantly increase the size of debug outputs.This PR results in some space savings for packages that output static libraries while using
separateDebugInfo.postgresql'slib/libpgcommon.agoes from ~800KB to ~200KB on x86_64 linux. A static build ofopensslgoes from 24MB to 6.5MB.My hope with this is that people will be less hesitant to enable
separateDebugInfoon packages as it is much less likely to cause unexpected bloat.Things done
sandbox = trueset innix.conf? (See Nix manual)nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/)nixos/doc/manual/md-to-db.shto update generated release notes