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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkgs/build-support/setup-hooks/separate-debug-info.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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.


# Also a create a symlink <original-name>.debug.
ln -sfn ".build-id/${id:0:2}/${id:2}.debug" "$dst/../$(basename "$i")"
Expand Down
2 changes: 2 additions & 0 deletions pkgs/development/libraries/libpsl/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
, autoreconfHook
, docbook_xsl
, docbook_xml_dtd_43
, glibc
, gtk-doc
, lzip
, libidn2
Expand Down Expand Up @@ -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. 🤷

valgrind
];

Expand Down
31 changes: 31 additions & 0 deletions pkgs/development/tools/analysis/valgrind/debug-info-from-env.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
diff --git a/coregrind/m_debuginfo/readelf.c b/coregrind/m_debuginfo/readelf.c
index c586e3f33..e3bb1717f 100644
--- a/coregrind/m_debuginfo/readelf.c
+++ b/coregrind/m_debuginfo/readelf.c
@@ -1508,13 +1508,25 @@ DiImage* find_debug_file( struct _DebugInfo* di,
HChar* debugpath = NULL; /* where we found it */

if (buildid != NULL) {
+ const HChar *dir = VG_(getenv)("NIX_DEBUG_INFO_DIRS");
debugpath = ML_(dinfo_zalloc)("di.fdf.1",
- VG_(strlen)(buildid) + 33);
+ VG_(strlen)(buildid) + 33 +
+ (dir ? VG_(strlen)(dir) : 0));

VG_(sprintf)(debugpath, "/usr/lib/debug/.build-id/%c%c/%s.debug",
buildid[0], buildid[1], buildid + 2);

dimg = open_debug_file(debugpath, buildid, 0, rel_ok, NULL);
+
+ while (!dimg && dir) {
+ const HChar *sep = VG_(strchr)(dir, ':');
+ Int size = sep ? sep - dir : VG_(strlen)(dir);
+ VG_(sprintf)(debugpath, "%.*s/.build-id/%c%c/%s.debug",
+ size, dir, buildid[0], buildid[1], buildid + 2);
+ dimg = open_debug_file(debugpath, buildid, 0, rel_ok, NULL);
+ dir = sep ? sep + 1 : NULL;
+ }
+
if (!dimg) {
ML_(dinfo_free)(debugpath);
debugpath = NULL;
6 changes: 6 additions & 0 deletions pkgs/development/tools/analysis/valgrind/default.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{ lib, stdenv, fetchurl, fetchpatch
, autoreconfHook, perl
, gdb, cctools, xnu, bootstrap_cmds
, setupDebugInfoDirs
}:

stdenv.mkDerivation rec {
Expand All @@ -19,6 +20,7 @@ stdenv.mkDerivation rec {
url = "https://bugsfiles.kde.org/attachment.cgi?id=143535";
sha256 = "036zyk30rixjvpylw3c7n171n4gpn6zcp7h6ya2dz4h5r478l9i6";
})
./debug-info-from-env.patch
];

outputs = [ "out" "dev" "man" "doc" ];
Expand All @@ -32,6 +34,10 @@ stdenv.mkDerivation rec {
# Perl is also a native build input.
nativeBuildInputs = [ autoreconfHook perl ];

# Not propagatedNativeBuildInputs because of
# https://github.com/NixOS/nixpkgs/issues/64992.
propagatedBuildInputs = [ setupDebugInfoDirs ];

enableParallelBuilding = true;
separateDebugInfo = stdenv.isLinux;

Expand Down