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
ghc: Add enableDwarf
flag, off by default.
#52255
Conversation
+1 |
accabdf
to
75301c8
Compare
this wont work on darwin fyi :( |
@@ -17,6 +18,9 @@ | |||
# library instead of the faster but GPLed integer-gmp library. | |||
enableIntegerSimple ? !(stdenv.lib.any (stdenv.lib.meta.platformMatch stdenv.hostPlatform) gmp.meta.platforms), gmp | |||
|
|||
, # Allows this GHC to produce binaries that have DWARF debug symbols. | |||
enableDwarf ? (!stdenv.isDarwin) # elfutils libdw supports only ELF |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a better expression than !stdenv.isDarwin
I could use that gives me "all ELF platforms"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@angerman on #ghc
chat said:
I doubt there is any consumer of Mach-o that is not macOS or iOS or really exotic. Same for Windows. Everyone else just uses elf.
Yes just did a force push to correct that and updated the PR description. |
additionally, theres some sort limit that building base with -g tickles in the macho format (at least when i tried to ) |
It seems to me that this would go nicely with the DWARF-enabled package set I proposed in #51987. |
Are ghc binaries built with debugging information by default? How does this interact with cabal's -O1 setting? |
Do you mean in general, or with this PR? In general, GHC HQ provides bindists in both a normal and a For this PR:
Cabal may decide to not pass That is controlled by the
This PR is only about providing GHC and its bundled libraries with Edit: I've added much of this information to a new |
I just learned from @bgamari of a new GHC bug that shows that
In the face of this, I'll change this to But I'd really like to have this built by Hydra as well. Can anybody instruct me how to achive that? |
enableDwarf
flag, on by default.enableDwarf
flag, off by default.
47a4d99
to
9b1b37e
Compare
After having added the forgotten
|
@bgamari said:
nh2:
I think the issue is https://ghc.haskell.org/trac/ghc/ticket/15068 |
9b1b37e
to
9dc3392
Compare
Hmm, I got the assembler error even when building It looks like I only get it on
8.4.4 and the 8.6.* releases all built. |
Here are some numbers for binary sizes: For the Haskell I've checked the presence of debugging symbols using The program has "statish" linking:
Sizes (normal, with
From this I conclude that the size overhead of full DWARF symbols is very low compared to nixpkgs' default of |
9dc3392
to
7f9f07f
Compare
This is more general, and makes it consistent with the dwarf package set.
341a8a6
to
5899036
Compare
I've for put in a Once cross compilation to Darwin works, those that are experts in that will be able to go the last mile easily by spotting the TODO. This is ready to get merged to staging from my side. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm looking forward to having this. Thanks @nh2!
That being said, I wonder if a note in the users guide is in order? Otherwise I'm a bit worried that the new package set will be quite undiscoverable. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should work out the overriding story before we commit to this since the current situation is unfortunately entirely non-composable. Perhaps instead of adding the dwarf
package sets here we could just expose something like,
let withDwarfEnabled = name: args: packages."${name}".override (args // {
ghc = bh.compiler.dwarf."${name}";
buildHaskellPackages = bh.packages.dwarf."${name}";
overrides =
let
dwarfOverrides =
self : super : {
# Override the mkDerivation function so that the GHC flags that
# are needed for debugging symbols are passed to all Cabal invocations.
mkDerivation = old: super.mkDerivation (old // {
configureFlags = (old.configureFlags or []) ++ [
"--enable-debug-info=3"
"--disable-library-stripping"
"--disable-executable-stripping"
];
# Disable nixpkgs' own stripping.
dontStrip = true;
});
};
in composeExtensions dwarfOverrides args.overrides;
});
This significantly less elegant and less convenient than the current package sets but is nevertheless sufficient and avoids committing us to an approach which is fundamentally inextensible.
Perhaps a more elegant (albeit still not ideomatic) approach would be to expose an attribute set of partial applications of withDwarfEnabled
as defined above:
dwarf = pkgs.lib.genAttrs normalGhcCompilers withDwarfEnabled
The user would then have to apply an empty overrides set to an attribute of dwarf
to get a Haskell packages set.
@nh2 any chance to rebase this? I'd love to have it in 19.03 - even if overriding is broken for now. |
@domenkozar I agree, even if the package set isn't super useful, it's good to be able to have at least the pre-built compiler downloadable from cache.nixos.org, and the ability to build many Haskell executables with DWARF. I think we should put it into 19.03 but put a warning that it may be changed in the future. I just pushed https://github.com/nh2/nixpkgs/tree/ghc-dwarf-19.03 but it's still building, so not sure yet if it works. |
Why not just use enableSeparateDebugInfo for all compilers? That way we don’t have to build every compiler 2 times. Those patches should be okay even when you don’t want dwarf symbols. |
I've built |
@matthewbauer Can you elaborate a bit? I'm not super familiar with how Also, what do you mean with "those patches"? |
My main concern is this doubles the number of GHC compilers we build. I like enabling debug info, but that should be in a separate debug output not a whole new compiler. I would propose doing this:
As a side note, I also really dislike having integer-simple as a separate package set. It has many of the same problems as a "dwarf" package set, but there's not a good alternative available because GHC requires you to choose an integer library at build time . |
We could estimate price for our haskellPackages specifically, if you produce code. See: #18530 (comment) |
@vcunat I left a comment with some basic statistics in #18530 (comment) |
I admit I've read almost nothing from this thread so far :-/ but I tried this PR with |
@vcunat #52255 (comment) shows a nix invocation that should work on the branch here in the PR, which builds one large Haskell executable and its dependency closure (which may be interesting to compare with the dependency closure of the one you get if you leave the I can also offer to collect some info for you, if you let me know what it shall be :) |
That evaluates to the same ghc which fails for me, three times now (two different machines). That is, after merging this PR with my branch discussed on the other thread: 0173520. |
I can confirm on pure commit 5899036 it works for me. |
This pull request has been mentioned on Nix community. There might be relevant details there: https://discourse.nixos.org/t/what-are-your-goals-for-19-09/2875/23 |
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: |
Relevant for GHC 8.10: #69552 |
I believe there has been other PRs adding dwarf support: |
This allows our GHCs to build programs with DWARF debug information when
-g
is passed, see https://ghc.haskell.org/trac/ghc/wiki/DWARF.On by default on non-Darwin only becauseOff by default until GHC ticket #15960 - Using -g causes differences in generated core is fixed.elfutils
(which GHC uses for this) works only for ELF executables.PR is against
staging
so that the impact can be properly evaluated.Motivation for this change
This can make debugging of many Haskell bugs and performance issues significantly easier.
Common use cases are:
perf
andkcachegrind
to debug performance issues but results here are mixed~This change is expected to increase the size of GHC and Haskell libraries, as debugging symbols are added to the object files.
The size of the eventual Haskell binaries that are not explicitly built with
ghc -g
should remain unaffected when the standard statish linking is used (that links Haskell libraries statically, and system libraries dynamically, which is nixpkgs' default).Closure size should rise minimally to the addition of
elfutils
that provideslibdw
.I believe that the slightly increased download size for developers will be tremendously offset by the benefits of being able to trouble-shoot crashes and performance issues without having to recompile the entire ecosystem.
(This is from my own perspective of using Haskell for work every day for many years, but I'm relatively sure that others feel the same.)
CC @bgamari @angerman @Gabriel439 @vaibhavsagar @basvandijk @roelvandijk
Things done
Much of the below isn't ticked yet because building takes a while and I added it for all GHC versions.
I have tested the change on 8.2.2 on top of
release-18.03
so far, where I managed to produce dwarf symbols.sandbox
innix.conf
on non-NixOS)nix-shell -p nox --run "nox-review wip"
./result/bin/
)nix path-info -S
before and after)TODO list
GhcLibHcOpts = -g3
andGhcRtsHcOpts = -g3
entries (same as, from ghc: AddenableDwarf
flag, off by default. #52255 (comment))release.nix
(see e.g. how theinteger-simple
one is built here/here)