Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

separateDebugInfo: Use --strip-unneeded #160259

Merged
merged 3 commits into from
Mar 23, 2022
Merged

Conversation

andersk
Copy link
Contributor

@andersk andersk commented Feb 16, 2022

Motivation for this change

According to https://stackoverflow.com/q/46197810/115030, --only-keep-debug preserves all the information stripped by --strip-unneeded. This reduces the size of the webkitgtk output by 22% (123 MB → 96 MB).

Inspired by #159612.

Not sure whether to target staging or master. I expect this to touch a lot of packages okay, just about every package (via python, which has separateDebugInfo = true), so I went with staging for now. But on the other hand master is currently blocked from feeding nixos-unstable due to the GNOME ISO size issue.

Things done
  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandbox = true set in nix.conf? (See Nix manual)
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 22.05 Release Notes (or backporting 21.11 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
    • (Release notes changes) Ran nixos/doc/manual/md-to-db.sh to update generated release notes
  • Fits CONTRIBUTING.md.

@andersk andersk requested a review from Ericson2314 as a code owner February 16, 2022 04:08
@andersk andersk requested a review from edolstra February 16, 2022 04:09
@ofborg ofborg bot added 10.rebuild-linux-stdenv This PR causes stdenv to rebuild 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 501+ 10.rebuild-linux: 5001+ labels Feb 16, 2022
@andersk andersk added 11.by: nixpkgs-member 6.topic: closure size The final size of a derivation, including its dependencies 6.topic: stdenv Standard environment labels Feb 16, 2022
@andersk andersk marked this pull request as draft February 16, 2022 22:59
@andersk
Copy link
Contributor Author

andersk commented Feb 16, 2022

This seems to break the Valgrind tests in libpsl, so needs more investigation.

@andersk
Copy link
Contributor Author

andersk commented Feb 16, 2022

That failure can be reproduced with valgrind true. In particular, Valgrind looks for /usr/lib/debug/.build-id/b2/349b9bd14cc4da986c66895d5a6f238e4de2f9.debug, which doesn’t exist, and doesn’t look at /nix/store/zfspvsci7i0a953r7i5b44yfdnwbm0cw-glibc-2.33-108-debug/lib/debug/.build-id/b2/349b9bd14cc4da986c66895d5a6f238e4de2f9.debug even with --extra-debuginfo-path=/nix/store/zfspvsci7i0a953r7i5b44yfdnwbm0cw-glibc-2.33-108-debug/lib/debug. Here’s a matching upstream bug.

@andersk
Copy link
Contributor Author

andersk commented Feb 16, 2022

I guess we’ll need to patch Valgrind to respect NIX_DEBUG_INFO_DIRS, like we did for GDB and elfutils.

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
Signed-off-by: Anders Kaseorg <andersk@mit.edu>
@andersk andersk marked this pull request as ready for review February 17, 2022 07:17
@github-actions github-actions bot removed the 6.topic: stdenv Standard environment label Feb 17, 2022
According to https://stackoverflow.com/q/46197810/115030,
--only-keep-debug preserves all the information stripped by
--strip-unneeded.  This reduces the size of the webkitgtk output by 22%
(123 MB → 96 MB).

Inspired by NixOS#159612.

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
@andersk andersk added the 6.topic: stdenv Standard environment label Feb 17, 2022
Copy link
Contributor Author

@andersk andersk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Patched Valgrind, and now I can build the entire closure of webkitgtk.

@@ -38,6 +39,7 @@ in stdenv.mkDerivation rec {
python3
libxslt
] ++ lib.optionals enableValgrindTests [
glibc.debug
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Should this be in valgrind’s propagatedBuildInputs, or be left up to its users?)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question...!
I'm not sure every use-case of valgrind (in and out of nixpkgs) would expect glibc debug infos to be available. Maybe. 🤷

@ofborg ofborg bot requested a review from c0bw3b February 17, 2022 09:13
@ofborg ofborg bot added 10.rebuild-darwin: 11-100 and removed 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin labels Feb 17, 2022
Copy link
Contributor

@c0bw3b c0bw3b left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok with the change on libpsl

Result of nixpkgs-review pr 160259 run on x86_64-linux 1

1 package built:
  • libpsl

As for --strip-unneeded it seems safe indeed.
Do we have a rough estimate of size difference (and thus the space that will be saved) compared to --strip-debug?

@@ -34,7 +34,7 @@ _separateDebugInfo() {
# firmware blobs in QEMU.)
(
$OBJCOPY --only-keep-debug "$i" "$dst/${id:0:2}/${id:2}.debug"
$STRIP --strip-debug "$i"
$STRIP --strip-unneeded "$i"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this ever be used on macOS? FWIW it supports neither flags.

strip is an area I've noticed where we tend to use non portable flags, maybe it's time to introduce a more bespoke strip wrapper…

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, all this sounds more like future improvements.

@vcunat vcunat merged commit 848091a into NixOS:staging Mar 23, 2022
@andersk andersk deleted the strip-unneeded branch March 23, 2022 08:06
@vcunat
Copy link
Member

vcunat commented Mar 23, 2022

A more interesting thing would be to switch the default strip flag, i.e. even packages not using separateDebugInfo, but right now I didn't feel confident enough to do that. (and there we might really have to do it based on the system, for portability)

@vcunat
Copy link
Member

vcunat commented Mar 23, 2022

Uh, this PR is most likely what broke elfutils test(s). No idea why, but I can reproduce the issue :-/
https://hydra.nixos.org/log/31vfs30d52df2lkfjjd9b048b47f4m60-elfutils-0.186.drv

@flokli flokli mentioned this pull request Mar 23, 2022
13 tasks
@trofi
Copy link
Contributor

trofi commented Mar 23, 2022

Thread iterators rely on superfluous symbols to be retained in libpthread.so.0 (glibc provides the mechanism itself): https://sourceware.org/gdb/wiki/FAQ#GDB_does_not_see_any_threads_besides_the_thread_in_which_crash_occurred.3B_or_SIGTRAP_kills_my_program_when_I_set_a_breakpoint.

I suspect we over-strip glibc.

@vcunat
Copy link
Member

vcunat commented Mar 23, 2022

"unneeded" :-(

So I suppose we'll be reverting this PR, at least for now? (fixing glibc will be a stdenv rebuild anyway)

@trofi
Copy link
Contributor

trofi commented Mar 23, 2022

Also, how should the tests look like in case of separate debug into? Looks like elfutils just tries to get a symbolised backtrace out of crashes binary and expects libc symbols from there. From what I understand debug output is not pulled in by default.

What is the correct way to pull it in in libc-agnostic way? AFAIU glibc.debug import sounds like a very narrow way to do it (does not work for musl alternative), stdenv.libc.debug seems to single out libcs without separate debug output.

@vcunat
Copy link
Member

vcunat commented Mar 23, 2022

I expect you rarely need to pull it into a build. For real-life usage it might be most practical to use dwarffs.

vcunat added a commit that referenced this pull request Mar 23, 2022
This reverts commit 848091a, reversing
changes made to ab0e692.

It caused issues with elfutils tests,
probably through over-stripping of glibc parts.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants