Enabling Qt removes Geant4 debug symbols (was .override breaks .overrideAttrs)

I’m trying to add debug symbols to a customized version of a nixpkgs package, as an output package of a flake. The customization (which I achieve with override) seems to interfere with the debug-symbol-enabling (which I achieve with overrideAttrs).

Steps to reproduce

Note: this takes a non-trivial amount of time to compile (around 45 minutes on a GHA Linux runner; a few minutes on my development machine):

nix build github:jacg/nain4/missing-debug-symbols#my-geant4
gdb result/lib/libG4event.so

and gdb output contains the disappointing line

(No debugging symbols found in result/lib/libG4event.so)

However, repeating the same exercise with

nix build github:jacg/nain4/present-debug-symbols#my-geant4

(instead of missing-debug-symbols) gives a result with debug symbols.

Details

I have a flake which provides a customized version of pkgs.geant4:

let
  ...
  g4 = { thread ? false , qt ? false, ...etc... }:
    (pkgs.geant4.override {
      enableMultiThreading = thread;
      enableQt             = qt;
      ...etc...
    });

  my-geant4 = g4 { qt = true; ...etc... };

in {
    packages.my-geant4 = my-geant4;
}

I want debug symbols to be included, which I try to achieve by overriding the dontStrip and cmakeBuildType attributes:

  g4 = { thread ? false , qt ? false, ...etc... }:
  ...
- });
+ }).overrideAttrs (oldAttrs: {
+      dontStrip = true;
+      cmakeBuildType = "Debug";
+ });

but this produces results without debug symbols. However, if I remove the customization, leaving only
the debug-symbol-enabling overrideAttrs:

  my-geant4 = pkgs.geant4.overrideAttrs (oldAttrs: {
    dontStrip = true;
    cmakeBuildType = "Debug";
  });
in {
    packages.my-geant4 = my-geant4;
  }

then the symbols appear in the result.

FWIW, using an overlay

  add-debug-symbols-to-geant4 = final: previous: {
    geant4 = previous.geant4.overrideAttrs (old: {
      dontStrip = true;
      cmakeBuildType = "RelWithDebInfo";
    });
  };

to add the debug-symbols ‘in-place’, works in isolation, but adding the customization with .override removes them again, just like it did in the original overlay-less approach.

1 Like

I have narrowed it down: enabling Qt is the specific override which kills the debug symbols. So this looks like an upstream problem, and not a Nix one.