summary refs log tree commit diff
diff options
context:
space:
mode:
authorDomen Kožar <domen@dev.si>2017-09-01 16:49:50 +0200
committerDomen Kožar <domen@enlambda.com>2017-09-02 11:25:50 +0100
commit991654fa4ab7be07ce70b02bcc935491239a52c5 (patch)
treecb0cdee8026ddaab547fd12dd0b81bc0f1e4bf75
parentb7d257a5207f3b7e9cfe002e8b77853c97d5b697 (diff)
downloadnixpkgs-991654fa4ab7be07ce70b02bcc935491239a52c5.tar
nixpkgs-991654fa4ab7be07ce70b02bcc935491239a52c5.tar.gz
nixpkgs-991654fa4ab7be07ce70b02bcc935491239a52c5.tar.bz2
nixpkgs-991654fa4ab7be07ce70b02bcc935491239a52c5.tar.lz
nixpkgs-991654fa4ab7be07ce70b02bcc935491239a52c5.tar.xz
nixpkgs-991654fa4ab7be07ce70b02bcc935491239a52c5.tar.zst
nixpkgs-991654fa4ab7be07ce70b02bcc935491239a52c5.zip
haskell: add combinator to enable DWARF debugging
Tested using:

$ cat test-strip.nix
with (import ./. {});
with haskell.lib;

haskell.packages.ghc802.override {
  overrides = self: super: {
    microlens = enableDWARFDebugging super.microlens;
  };
}

$ nix-build -A microlens test-strip.nix
$ objdump -t <path-to-so-file>
-rw-r--r--pkgs/development/haskell-modules/lib.nix11
1 files changed, 11 insertions, 0 deletions
diff --git a/pkgs/development/haskell-modules/lib.nix b/pkgs/development/haskell-modules/lib.nix
index 6da19794f6f..48110cffabf 100644
--- a/pkgs/development/haskell-modules/lib.nix
+++ b/pkgs/development/haskell-modules/lib.nix
@@ -73,6 +73,17 @@ rec {
 
   disableHardening = drv: flags: overrideCabal drv (drv: { hardeningDisable = flags; });
 
+  # Controls if Nix should strip the binary files (removes debug symbols)
+  doStrip = drv: overrideCabal drv (drv: { dontStrip = false; });
+  dontStrip = drv: overrideCabal drv (drv: { dontStrip = true; });
+
+  # Useful for debugging segfaults with gdb. 
+  # -g: enables debugging symbols
+  # --disable-*-stripping: tell GHC not to strip resulting binaries
+  # dontStrip: see above
+  enableDWARFDebugging = drv:
+   appendConfigureFlag (dontStrip drv) "--ghc-options=-g --disable-executable-stripping --disable-library-stripping";
+
   sdistTarball = pkg: lib.overrideDerivation pkg (drv: {
     name = "${drv.pname}-source-${drv.version}";
     # Since we disable the haddock phase, we also need to override the