|
72 | 72 | , shellHook ? "" |
73 | 73 | , coreSetup ? false # Use only core packages to build Setup.hs. |
74 | 74 | , useCpphs ? false |
75 | | -, hardeningDisable ? lib.optional (ghc.isHaLVM or false) "all" |
| 75 | +, hardeningDisable ? null |
76 | 76 | , enableSeparateBinOutput ? false |
77 | 77 | , enableSeparateDataOutput ? false |
78 | 78 | , enableSeparateDocOutput ? doHaddock |
@@ -417,6 +417,17 @@ stdenv.mkDerivation ({ |
417 | 417 | configurePlatforms = []; |
418 | 418 | inherit configureFlags; |
419 | 419 |
|
| 420 | + # Note: the options here must be always added, regardless of whether the |
| 421 | + # package specifies `hardeningDisable`. |
| 422 | + hardeningDisable = lib.optionals (args ? hardeningDisable) hardeningDisable |
| 423 | + ++ lib.optional (ghc.isHaLVM or false) "all" |
| 424 | + # Static libraries (ie. all of pkgsStatic.haskellPackages) fail to build |
| 425 | + # because by default Nix adds `-pie` to the linker flags: this |
| 426 | + # conflicts with the `-r` and `-no-pie` flags added by GHC (see |
| 427 | + # https://gitlab.haskell.org/ghc/ghc/-/issues/19580). hardeningDisable |
| 428 | + # changes the default Nix behavior regarding adding "hardening" flags. |
| 429 | + ++ lib.optional enableStaticLibraries "pie"; |
| 430 | + |
420 | 431 | configurePhase = '' |
421 | 432 | runHook preConfigure |
422 | 433 |
|
@@ -674,7 +685,6 @@ stdenv.mkDerivation ({ |
674 | 685 | // optionalAttrs (args ? preFixup) { inherit preFixup; } |
675 | 686 | // optionalAttrs (args ? postFixup) { inherit postFixup; } |
676 | 687 | // optionalAttrs (args ? dontStrip) { inherit dontStrip; } |
677 | | -// optionalAttrs (args ? hardeningDisable) { inherit hardeningDisable; } |
678 | 688 | // optionalAttrs (stdenv.buildPlatform.libc == "glibc"){ LOCALE_ARCHIVE = "${glibcLocales}/lib/locale/locale-archive"; } |
679 | 689 | ) |
680 | 690 | ) |
0 commit comments