Skip to content

Commit

Permalink
haskell: support enableGoldLinker
Browse files Browse the repository at this point in the history
  • Loading branch information
basvandijk committed Apr 6, 2017
1 parent d3ef8dc commit d8ca3f9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pkgs/development/haskell-modules/generic-builder.nix
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
, withBenchmarkDepends ? false
, doHoogle ? true
, editedCabalFile ? null
, enableGoldLinker ? false
, enableLibraryProfiling ? false
, enableExecutableProfiling ? false
# TODO enable shared libs for cross-compiling
Expand Down Expand Up @@ -106,6 +107,8 @@ let
crossCabalFlagsString =
stdenv.lib.optionalString isCross (" " + stdenv.lib.concatStringsSep " " crossCabalFlags);

linkWithGold = enableGoldLinker && versionOlder "7.8" ghc.version;

defaultConfigureFlags = [
"--verbose" "--prefix=$out" "--libdir=\\$prefix/lib/\\$compiler" "--libsubdir=\\$pkgid"
"--with-gcc=$CC" # Clang won't work without that extra information.
Expand All @@ -122,6 +125,7 @@ let
(optionalString (isGhcjs || versionOlder "7" ghc.version) (enableFeature enableStaticLibraries "library-vanilla"))
(optionalString (isGhcjs || versionOlder "7.4" ghc.version) (enableFeature enableSharedExecutables "executable-dynamic"))
(optionalString (isGhcjs || versionOlder "7" ghc.version) (enableFeature doCheck "tests"))
(optionalString linkWithGold "--ghc-option=-optl-fuse-ld=gold --ld-option=-fuse-ld=gold --with-ld=ld.gold")
] ++ optionals (enableDeadCodeElimination && (stdenv.lib.versionOlder "8.0.1" ghc.version)) [
"--ghc-option=-split-sections"
] ++ optionals isGhcjs [
Expand Down Expand Up @@ -368,4 +372,5 @@ stdenv.mkDerivation ({
// optionalAttrs (dontStrip) { inherit dontStrip; }
// optionalAttrs (hardeningDisable != []) { inherit hardeningDisable; }
// optionalAttrs (stdenv.isLinux) { LOCALE_ARCHIVE = "${glibcLocales}/lib/locale/locale-archive"; }
// optionalAttrs linkWithGold { NIX_CFLAGS_LINK = "-fuse-ld=gold"; }

This comment has been minimized.

Copy link
@basvandijk

basvandijk Apr 7, 2017

Author

This is probably not needed. I added it to work around a bug that in the end was caused by something else.

)
3 changes: 3 additions & 0 deletions pkgs/development/haskell-modules/lib.nix
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ rec {
appendConfigureFlag = drv: x: overrideCabal drv (drv: { configureFlags = (drv.configureFlags or []) ++ [x]; });
removeConfigureFlag = drv: x: overrideCabal drv (drv: { configureFlags = pkgs.stdenv.lib.remove x (drv.configureFlags or []); });

enableGoldLinker = drv: overrideCabal drv (drv: { enableGoldLinker = true; });
disableGoldLinker = drv: overrideCabal drv (drv: { enableGoldLinker = false; });

addBuildTool = drv: x: addBuildTools drv [x];
addBuildTools = drv: xs: overrideCabal drv (drv: { buildTools = (drv.buildTools or []) ++ xs; });

Expand Down

0 comments on commit d8ca3f9

Please sign in to comment.