summary refs log tree commit diff
diff options
context:
space:
mode:
authorMaximilian Bosch <maximilian@mbosch.me>2021-11-29 16:18:46 +0100
committerGitHub <noreply@github.com>2021-11-29 16:18:46 +0100
commit8f3eb58a96a4ad09a56bb707da8283825580d859 (patch)
tree1e95df423de56f901d3f11617c093d88be9206cf
parent18c4a0f4ea350b3ed6a6caf99ddbccb1c6b63365 (diff)
parenta0262a08026c7e8fe7ed8acde33b729e73e43208 (diff)
downloadnixpkgs-8f3eb58a96a4ad09a56bb707da8283825580d859.tar
nixpkgs-8f3eb58a96a4ad09a56bb707da8283825580d859.tar.gz
nixpkgs-8f3eb58a96a4ad09a56bb707da8283825580d859.tar.bz2
nixpkgs-8f3eb58a96a4ad09a56bb707da8283825580d859.tar.lz
nixpkgs-8f3eb58a96a4ad09a56bb707da8283825580d859.tar.xz
nixpkgs-8f3eb58a96a4ad09a56bb707da8283825580d859.tar.zst
nixpkgs-8f3eb58a96a4ad09a56bb707da8283825580d859.zip
Merge pull request #146961 from alyssais/qemu-debug
qemu: enable debug info
-rw-r--r--pkgs/applications/virtualization/qemu/default.nix5
-rw-r--r--pkgs/build-support/setup-hooks/separate-debug-info.sh14
2 files changed, 13 insertions, 6 deletions
diff --git a/pkgs/applications/virtualization/qemu/default.nix b/pkgs/applications/virtualization/qemu/default.nix
index 93a215f1003..e229825718c 100644
--- a/pkgs/applications/virtualization/qemu/default.nix
+++ b/pkgs/applications/virtualization/qemu/default.nix
@@ -1,7 +1,7 @@
 { lib, stdenv, fetchurl, fetchpatch, python, zlib, pkg-config, glib
 , perl, pixman, vde2, alsa-lib, texinfo, flex
 , bison, lzo, snappy, libaio, libtasn1, gnutls, nettle, curl, ninja, meson, sigtool
-, makeWrapper, autoPatchelfHook
+, makeWrapper
 , attr, libcap, libcap_ng
 , CoreServices, Cocoa, Hypervisor, rez, setfile
 , numaSupport ? stdenv.isLinux && !stdenv.isAarch32, numactl
@@ -53,7 +53,6 @@ stdenv.mkDerivation rec {
 
   nativeBuildInputs = [ makeWrapper python python.pkgs.sphinx python.pkgs.sphinx_rtd_theme pkg-config flex bison meson ninja ]
     ++ lib.optionals gtkSupport [ wrapGAppsHook ]
-    ++ lib.optionals stdenv.isLinux [ autoPatchelfHook ]
     ++ lib.optionals stdenv.isDarwin [ sigtool ];
 
   buildInputs = [ zlib glib perl pixman
@@ -85,6 +84,7 @@ stdenv.mkDerivation rec {
   dontUseMesonConfigure = true; # meson's configurePhase isn't compatible with qemu build
 
   outputs = [ "out" "ga" ];
+  separateDebugInfo = true;
 
   patches = [
     ./fix-qemu-ga.patch
@@ -174,6 +174,7 @@ stdenv.mkDerivation rec {
 
   configureFlags = [
     "--audio-drv-list=${audio}"
+    "--disable-strip" # We'll strip ourselves after separating debug info.
     "--enable-docs"
     "--enable-tools"
     "--enable-guest-agent"
diff --git a/pkgs/build-support/setup-hooks/separate-debug-info.sh b/pkgs/build-support/setup-hooks/separate-debug-info.sh
index 2481d8f5047..1a23e6b198e 100644
--- a/pkgs/build-support/setup-hooks/separate-debug-info.sh
+++ b/pkgs/build-support/setup-hooks/separate-debug-info.sh
@@ -28,10 +28,16 @@ _separateDebugInfo() {
         # Extract the debug info.
         header "separating debug info from $i (build ID $id)"
         mkdir -p "$dst/${id:0:2}"
-        $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")"
+        # This may fail, e.g. if the binary is for a different
+        # architecture than we're building for.  (This happens with
+        # 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")"
+        ) || rmdir -p "$dst/${id:0:2}"
     done < <(find "$prefix" -type f -print0)
 }