@@ -1,4 +1,4 @@
1−{ pkgs, stdenv, buildPackages, ghc, lib, gobject-introspection ? null, haskellLib, makeConfigFiles, haddockBuilder, ghcForComponent, hsPkgs, compiler, runCommand, libffi, gmp, zlib, ncurses, numactl, nodejs }:
1+{ pkgs, stdenv, buildPackages, ghc, lib, gobject-introspection ? null, haskellLib, makeConfigFiles, haddockBuilder, ghcForComponent, hsPkgs, compiler, runCommand, libffi, gmp, zlib, ncurses, numactl, nodejs }@defaults:
2lib.makeOverridable (
2lib.makeOverridable (
4{ componentId
4{ componentId
@@ -77,6 +77,16 @@ let self =
80+ # Ignore attempts to include DWARF info when it is not possible
81+ enableDWARF = drvArgs.enableDWARF or false
82+ && stdenv.hostPlatform.isLinux
83+ && !haskellLib.isCrossHost
84+ && !stdenv.hostPlatform.isMusl
85+ && builtins.compareVersions defaults.ghc.version "8.10.2" >= 0;
87+ ghc = if enableDWARF then defaults.ghc.dwarf else defaults.ghc;
88+ setup = if enableDWARF then drvArgs.setup.dwarf else drvArgs.setup;
80 # TODO fix cabal wildcard support so hpack wildcards can be mapped to cabal wildcards
90 # TODO fix cabal wildcard support so hpack wildcards can be mapped to cabal wildcards
81 canCleanSource = !(cabal-generator == "hpack" && !(package.cleanHpack or false));
91 canCleanSource = !(cabal-generator == "hpack" && !(package.cleanHpack or false));
82 # In order to support relative references to other packages we need to use
92 # In order to support relative references to other packages we need to use
@@ -109,7 +119,7 @@ let
110 configFiles = makeConfigFiles {
120 configFiles = makeConfigFiles {
111 inherit (package) identifier;
121 inherit (package) identifier;
112− inherit component fullName flags needsProfiling;
122+ inherit component fullName flags needsProfiling enableDWARF;
115 enableFeature = enable: feature:
125 enableFeature = enable: feature:
@@ -178,7 +188,7 @@ let
178 ++ (ghc.extraConfigureFlags or [])
188 ++ (ghc.extraConfigureFlags or [])
179 ++ lib.optional enableDebugRTS "--ghc-option=-debug"
189 ++ lib.optional enableDebugRTS "--ghc-option=-debug"
180 ++ lib.optional enableTSanRTS "--ghc-option=-tsan"
190 ++ lib.optional enableTSanRTS "--ghc-option=-tsan"
181− ++ lib.optional enableDWARF "--ghc-option=-g"
191+ ++ lib.optional enableDWARF "--ghc-option=-g3"
182 ++ lib.optionals useLLVM [
192 ++ lib.optionals useLLVM [
183 "--ghc-option=-fPIC" "--gcc-option=-fPIC"
193 "--ghc-option=-fPIC" "--gcc-option=-fPIC"
@@ -195,7 +205,7 @@ let
195 # work in the nix-shell. See ../doc/removing-with-package-wrapper.md.
205 # work in the nix-shell. See ../doc/removing-with-package-wrapper.md.
196 shellWrappers = ghcForComponent {
206 shellWrappers = ghcForComponent {
197 componentName = fullName;
207 componentName = fullName;
198− inherit configFiles;
208+ inherit configFiles enableDWARF;
201 # In order to let shell hooks make package-specific things like Hoogle databases
211 # In order to let shell hooks make package-specific things like Hoogle databases
@@ -280,10 +290,11 @@ let
280 config = component;
290 config = component;
281 srcSubDir = cleanSrc.subDir;
291 srcSubDir = cleanSrc.subDir;
282 srcSubDirPath = cleanSrc.root + cleanSrc.subDir;
292 srcSubDirPath = cleanSrc.root + cleanSrc.subDir;
283− inherit configFiles executableToolDepends exeName;
293+ inherit configFiles executableToolDepends exeName enableDWARF;
284 exePath = drv + "/bin/${exeName}";
294 exePath = drv + "/bin/${exeName}";
285 env = shellWrappers;
295 env = shellWrappers;
286 profiled = self (drvArgs // { enableLibraryProfiling = true; });
296 profiled = self (drvArgs // { enableLibraryProfiling = true; });
297+ dwarf = self (drvArgs // { enableDWARF = true; });
287 } // lib.optionalAttrs (haskellLib.isLibrary componentId) ({
298 } // lib.optionalAttrs (haskellLib.isLibrary componentId) ({
288 inherit haddock;
299 inherit haddock;
289 inherit (haddock) haddockDir; # This is null if `doHaddock = false`
300 inherit (haddock) haddockDir; # This is null if `doHaddock = false`