Skip to content

Commit 830ef64

Browse files
rnhmjojcdepillabout
authored andcommitted
haskell-generic-builder: disable static PIE
1 parent 885573b commit 830ef64

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

pkgs/development/haskell-modules/generic-builder.nix

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ in
7272
, shellHook ? ""
7373
, coreSetup ? false # Use only core packages to build Setup.hs.
7474
, useCpphs ? false
75-
, hardeningDisable ? lib.optional (ghc.isHaLVM or false) "all"
75+
, hardeningDisable ? null
7676
, enableSeparateBinOutput ? false
7777
, enableSeparateDataOutput ? false
7878
, enableSeparateDocOutput ? doHaddock
@@ -417,6 +417,17 @@ stdenv.mkDerivation ({
417417
configurePlatforms = [];
418418
inherit configureFlags;
419419

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+
420431
configurePhase = ''
421432
runHook preConfigure
422433
@@ -674,7 +685,6 @@ stdenv.mkDerivation ({
674685
// optionalAttrs (args ? preFixup) { inherit preFixup; }
675686
// optionalAttrs (args ? postFixup) { inherit postFixup; }
676687
// optionalAttrs (args ? dontStrip) { inherit dontStrip; }
677-
// optionalAttrs (args ? hardeningDisable) { inherit hardeningDisable; }
678688
// optionalAttrs (stdenv.buildPlatform.libc == "glibc"){ LOCALE_ARCHIVE = "${glibcLocales}/lib/locale/locale-archive"; }
679689
)
680690
)

0 commit comments

Comments
 (0)