Skip to content

Commit d90f0ec

Browse files
committed
Disable GHC dwarf support
1 parent 9dfc7f2 commit d90f0ec

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

survey/default.nix

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1544,10 +1544,36 @@ let
15441544

15451545
pkgsWithHaskellLibsReadyForStaticLinking = pkgsWithArchiveFiles.extend haskellLibsReadyForStaticLinkingOverlay;
15461546

1547+
fixGhc = ghcPackage0: lib.pipe ghcPackage0 [
1548+
# musl does not support libdw's alleged need for `dlopen()`, see:
1549+
# https://github.com/nh2/static-haskell-nix/pull/116#issuecomment-1585786484
1550+
#
1551+
# Nixpkgs has the `enableDwarf` argument only for GHCs versions that are built
1552+
# with Hadrian (`common-hadrian.nix`), which in nixpkgs is the case for GHC >= 9.6.
1553+
# So set `enableDwarf = true`, but not for older versions known to not use Hadrian.
1554+
(ghcPackage:
1555+
if lib.any (prefix: lib.strings.hasPrefix prefix compiler) ["ghc8" "ghc90" "ghc92" "ghc94"]
1556+
then ghcPackage # GHC < 9.6, no Hadrian
1557+
else ghcPackage.override { enableDwarf = false; }
1558+
)
1559+
];
15471560

15481561
# Overlay all Haskell executables are statically linked.
15491562
staticHaskellBinariesOverlay = final: previous: {
15501563
haskellPackages = previous.haskellPackages.override (old: {
1564+
1565+
# To override GHC, we need to override both `ghc` and the one in
1566+
# `buildHaskellPackages` because otherwise this code in `geneic-builder.nix`
1567+
# will make our package depend on 2 different GHCs:
1568+
# nativeGhc = buildHaskellPackages.ghc;
1569+
# depsBuildBuild = [ nativeGhc ] ...
1570+
# nativeBuildInputs = [ ghc removeReferencesTo ] ...
1571+
#
1572+
ghc = fixGhc old.ghc;
1573+
buildHaskellPackages = old.buildHaskellPackages.override (oldBuildHaskellPackages: {
1574+
ghc = fixGhc oldBuildHaskellPackages.ghc;
1575+
});
1576+
15511577
overrides = final.lib.composeExtensions (old.overrides or (_: _: {})) (self: super:
15521578
let
15531579
# We have to use `useFixedCabal` here, and cannot just rely on the

0 commit comments

Comments
 (0)