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
Provide GHC builds with dwarf support enabled #51202
Comments
Here's an example of how to do it for 8.2.2: diff --git a/pkgs/development/compilers/ghc/8.2.2.nix b/pkgs/development/compilers/ghc/8.2.2.nix
index dcc2852a341..05a483109c3 100644
--- a/pkgs/development/compilers/ghc/8.2.2.nix
+++ b/pkgs/development/compilers/ghc/8.2.2.nix
@@ -3,11 +3,14 @@
# build-tools
, bootPkgs, alex, happy, hscolour
-, autoconf, autoreconfHook, automake, coreutils, fetchurl, fetchpatch, perl, python3, sphinx
+, autoconf, autoreconfHook, automake, coreutils, fetchurl, fetchpatch, perl, python3, sphinx, elfutils
, runCommand
, libffi, libiconv ? null, ncurses
+, enableDwarf ? false
+
, useLLVM ? !targetPlatform.isx86
, # LLVM is conceptually a run-time-only depedendency, but for
# non-x86, we need LLVM to bootstrap later stages, so it becomes a
@@ -61,6 +64,7 @@ let
# Splicer will pull out correct variations
libDeps = platform: [ ncurses ]
++ stdenv.lib.optional (!enableIntegerSimple) gmp
+ ++ stdenv.lib.optional enableDwarf elfutils # elfutils provides libdw
++ stdenv.lib.optional (platform.libc != "glibc") libiconv;
toolsForTarget =
@@ -96,6 +100,11 @@ stdenv.mkDerivation rec {
url = "https://github.com/shlevy/ghc/commit/fec1b8d3555c447c0d8da0e96b659be67c8bb4bc.patch";
sha256 = "1lyysz6hfd1njcigpm8xppbnkadqfs0kvrp7s8vqgb38pjswj5hg";
})
+ ++ stdenv.lib.optional enableDwarf
+ (fetchpatch { # Backport of https://phabricator.haskell.org/D5424 to fail loudly if libdw can't be found
+ url = "https://git.haskell.org/ghc.git/commitdiff_plain/cb882fc993b4972f7f212b291229ef9e9ade0af9";
+ sha256 = "0xmn57fr8cdxvnsc2ykdkcxflz3gkcirih6ca33d4b9hma8nfsrk";
+ })
++ stdenv.lib.optional stdenv.isDarwin ./backport-dylib-command-size-limit.patch;
postPatch = "patchShebangs .";
@@ -135,6 +144,8 @@ stdenv.mkDerivation rec {
"--with-curses-includes=${ncurses.dev}/include" "--with-curses-libraries=${ncurses.out}/lib"
] ++ stdenv.lib.optional (targetPlatform == hostPlatform && ! enableIntegerSimple) [
"--with-gmp-includes=${gmp.dev}/include" "--with-gmp-libraries=${gmp.out}/lib"
+ ] ++ stdenv.lib.optional enableDwarf [
+ "--enable-dwarf-unwind"
] ++ stdenv.lib.optional (targetPlatform == hostPlatform && hostPlatform.libc != "glibc") [
"--with-iconv-includes=${libiconv}/include" "--with-iconv-libraries=${libiconv}/lib"
] ++ stdenv.lib.optionals (targetPlatform != hostPlatform) [ The added |
The fetched patch here is buggy due to See
There's a
|
PR at #52255 |
This issue has been mentioned on NixOS Discourse. There might be relevant details there: |
Also see this new blog post series about DWARF support and usage in GHC by @bgamari: |
This issue has been mentioned on NixOS Discourse. There might be relevant details there: |
Hello, I'm a bot and I thank you in the name of the community for opening this issue. To help our human contributors focus on the most-relevant reports, I check up on old issues to see if they're still relevant. This issue has had no activity for 180 days, and so I marked it as stale, but you can rest assured it will never be closed by a non-human. The community would appreciate your effort in checking if the issue is still valid. If it isn't, please close it. If the issue persists, and you'd like to remove the stale label, you simply need to leave a comment. Your comment can be as simple as "still important to me". If you'd like it to get more attention, you can ask for help by searching for maintainers and people that previously touched related code and @ mention them in a comment. You can use Git blame or GitHub's web interface on the relevant files to find them. Lastly, you can always ask for help at our Discourse Forum or at #nixos' IRC channel. |
Still valid |
Dwarf is now enabled on ghcHEAD, but that needs to be backported to GHC 8.10.x |
I marked this as stale due to inactivity. → More info |
Debugging Haskell programs is much easier when GHC's DWARF support is enabled.
According to @bgamari, this requires
./configure --enable-dwarf-unwind
when building GHC, and alibdw
dependency.For the beginning, this should be an optional setting for nixpkgs's GHCs.
But for later, it may make sense to discuss whether this should be the default.
According to @bgamari, there are no drawbacks beyond larger libraries being installed. There are no run-time overheads when
-g
isn't given for the final linked Haskell program.This means that download size of Haskell development libraries would increase, but the size of Haskell-built executables would not (neither would closure size as statish-built Haskell exes don't depend on GHC or Haskell libraries). Since developers are most likely very interested in the debugging facilities that DWARF support delivers, this is likely something we want to enable by default.
The text was updated successfully, but these errors were encountered: