haskell.nix icon indicating copy to clipboard operation
haskell.nix copied to clipboard

Can't enable DWARF in modules, limiting the usefulness of it

Open purefn opened this issue 4 years ago • 6 comments

There are two ways get a build with DWARF debugging built in right now

  1. Using mypkg.components.library.dwarf or mypkg.components.exes.myexe.dwarf. This is of limited use because there is no way to turn enable building with DWARF debug info built into all the libraries your library or exe depend on.
  2. Adding something like this to the project modules list to enable it for all components
({ pkgs, ...}: {
  ghcOptions = optional (pkgs.stdenv.hostPlatform.isLinux && !pkgs.haskell-nix.haskellLib.isCrossHost && !pkgs.stdenv.hostPlatform.isMusl) "-g3";
})

Which works fine, but reproduces the checking logic that already exists in comp-builder.nix.

Is there any reason not to add enableDWARF as a component/packge/global parameter, so the above example, to enable it everywhere, would simply become

{
  enableDWARF = true;
}

That way we wouldn't have to worry about checking all the same things that are checked in comp-builder.nix.

Happy to open a PR for this if it is something people would want.

purefn avatar May 27 '21 19:05 purefn

I'd appreciate that, see https://github.com/input-output-hk/haskell.nix/issues/995

domenkozar avatar Sep 14 '21 12:09 domenkozar

There is some logic for profiling which pushed that down, so you get profiling for dependencies as well. I think this could follow a similar pattern.

angerman avatar Sep 14 '21 12:09 angerman

I'm currently using:

cachix-server =
    let
      # the playground uses ghc at runtime so it needs one packaged up with the dependencies it needs in one place
      runtimeGhc = (cachixPkgs.shellFor {
        additional = ps: [ ps.cachix-server ];
        packages = _: [];
        enableDWARF = true;
      }).ghc;
    in
      pkgs.runCommand "cachix-server" { buildInputs = [ pkgs.makeWrapper ]; } ''
        # We need to provide the ghc interpreter with the location of the ghc lib dir and the package db
        mkdir -p $out
        cp -R --no-preserve=mode,ownership ${cachixPkgs.cachix-server.components.exes.cachix-server}/* $out
        chmod +x $out/bin/cachix-server
        wrapProgram $out/bin/cachix-server \
          --set GHC_LIB_DIR "${runtimeGhc}/lib/ghc-${runtimeGhc.version}" \
          --set GHC_BIN_DIR "${runtimeGhc}/bin" \
          --set GHC_PACKAGE_PATH "${runtimeGhc}/lib/ghc-${runtimeGhc.version}/package.conf.d"
      '';

Hacky. The goal is to have cachix-server ghci command on the server, although that bit isn't really working well.

domenkozar avatar Sep 15 '21 07:09 domenkozar

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Sep 28 '22 16:09 stale[bot]

so was this implemented?

spacekitteh avatar Jan 24 '23 21:01 spacekitteh

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar May 25 '23 00:05 stale[bot]