summary refs log tree commit diff
path: root/pkgs/os-specific/linux/musl
diff options
context:
space:
mode:
authorWill Dietz <w@wdtz.org>2018-03-23 12:59:15 -0500
committerWill Dietz <w@wdtz.org>2018-03-23 12:59:15 -0500
commit7b44560aa1843b921c8270185bd2fb81a420ee15 (patch)
treeedc6255242b2a1a48fb1bceca806664dc7f45534 /pkgs/os-specific/linux/musl
parentbab5a0664cfc982bf4915ccb214f4a11a5310cea (diff)
downloadnixlib-7b44560aa1843b921c8270185bd2fb81a420ee15.tar
nixlib-7b44560aa1843b921c8270185bd2fb81a420ee15.tar.gz
nixlib-7b44560aa1843b921c8270185bd2fb81a420ee15.tar.bz2
nixlib-7b44560aa1843b921c8270185bd2fb81a420ee15.tar.lz
nixlib-7b44560aa1843b921c8270185bd2fb81a420ee15.tar.xz
nixlib-7b44560aa1843b921c8270185bd2fb81a420ee15.tar.zst
nixlib-7b44560aa1843b921c8270185bd2fb81a420ee15.zip
musl: provide debug info, separately, don't disable unwind tables
Also by setting --enable-debug, asm is preprocessed with CFI directives.

Keep unwind tables does not increase size by much,
and helps debuggers and similar make sense of things.
Diffstat (limited to 'pkgs/os-specific/linux/musl')
-rw-r--r--pkgs/os-specific/linux/musl/default.nix17
1 files changed, 14 insertions, 3 deletions
diff --git a/pkgs/os-specific/linux/musl/default.nix b/pkgs/os-specific/linux/musl/default.nix
index 0f8f088945aa..005a12f5b94d 100644
--- a/pkgs/os-specific/linux/musl/default.nix
+++ b/pkgs/os-specific/linux/musl/default.nix
@@ -33,6 +33,14 @@ stdenv.mkDerivation rec {
   # so musl can selectively disable as needed
   hardeningDisable = [ "stackprotector" ];
 
+  # Leave these, be friendlier to debuggers/perf tools
+  # Don't force them on, but don't force off either
+  postPatch = ''
+    substituteInPlace configure \
+      --replace -fno-unwind-tables "" \
+      --replace -fno-asynchronous-unwind-tables ""
+  '';
+
   preConfigure = ''
     configureFlagsArray+=("--syslibdir=$out/lib")
   '';
@@ -40,6 +48,7 @@ stdenv.mkDerivation rec {
   configureFlags = [
     "--enable-shared"
     "--enable-static"
+    "--enable-debug"
     "CFLAGS=-fstack-protector-strong"
     # Fix cycle between outputs
     "--disable-wrapper"
@@ -48,15 +57,17 @@ stdenv.mkDerivation rec {
   outputs = [ "out" "dev" ];
 
   dontDisableStatic = true;
-  dontStrip = true;
+  separateDebugInfo = true;
 
   postInstall =
   ''
     # Not sure why, but link in all but scsi directory as that's what uclibc/glibc do.
     # Apparently glibc provides scsi itself?
     (cd $dev/include && ln -s $(ls -d ${linuxHeaders}/include/* | grep -v "scsi$") .)
-  '' +
-  ''
+  '' + ''
+    # Strip debug out of the static library
+    $STRIP -S $out/lib/libc.a
+  '' + ''
     mkdir -p $out/bin
     # Create 'ldd' symlink, builtin
     ln -s $out/lib/libc.so $out/bin/ldd