ghc: fix dylib load command limits in compiler version 8.x

See https://phabricator.haskell.org/D4714 for the full details.
This will be part of ghc 8.6.

Closes https://github.com/NixOS/nixpkgs/pull/40877.
This commit is contained in:
Moritz Angermann 2018-05-21 19:26:25 +08:00 committed by Peter Simons
parent e9d991a938
commit 4b2eceaa35
4 changed files with 30 additions and 3 deletions

View file

@ -84,7 +84,8 @@ stdenv.mkDerivation rec {
extraPrefix = "libraries/Cabal/";
})
] ++ stdenv.lib.optional stdenv.isLinux ./ghc-no-madv-free.patch
++ stdenv.lib.optional stdenv.isDarwin ./ghc-8.0.2-no-cpp-warnings.patch;
++ stdenv.lib.optional stdenv.isDarwin ./ghc-8.0.2-no-cpp-warnings.patch
++ stdenv.lib.optional stdenv.isDarwin ./backport-dylib-command-size-limit.patch;
# GHC is a bit confused on its cross terminology.
preConfigure = ''

View file

@ -95,7 +95,8 @@ stdenv.mkDerivation rec {
(fetchpatch { # Backport of https://phabricator.haskell.org/D4388 for more determinism
url = "https://github.com/shlevy/ghc/commit/fec1b8d3555c447c0d8da0e96b659be67c8bb4bc.patch";
sha256 = "1lyysz6hfd1njcigpm8xppbnkadqfs0kvrp7s8vqgb38pjswj5hg";
});
})
++ stdenv.lib.optional stdenv.isDarwin ./backport-dylib-command-size-limit.patch;
postPatch = "patchShebangs .";

View file

@ -86,7 +86,8 @@ stdenv.mkDerivation rec {
sha256 = "0plzsbfaq6vb1023lsarrjglwgr9chld4q3m99rcfzx0yx5mibp3";
extraPrefix = "utils/hsc2hs/";
stripLen = 1;
})];
})]
++ stdenv.lib.optional stdenv.isDarwin ./backport-dylib-command-size-limit.patch;
postPatch = "patchShebangs .";

View file

@ -0,0 +1,24 @@
diff --git a/compiler/main/DriverPipeline.hs b/compiler/main/DriverPipeline.hs
index acd0d61..3e83c15 100644
--- a/compiler/main/DriverPipeline.hs
+++ b/compiler/main/DriverPipeline.hs
@@ -1916,6 +1916,7 @@ linkBinary' staticLink dflags o_files dep_packages = do
++ pkg_framework_opts
++ debug_opts
++ thread_opts
+ ++ (if (platformOS platform `elem` [OSDarwin]) then [ "-Wl,-dead_strip_dylibs" ] else [])
))
exeFileName :: Bool -> DynFlags -> FilePath
diff --git a/compiler/main/SysTools.hs b/compiler/main/SysTools.hs
index 1ab5b13..2ebbf51 100644
--- a/compiler/main/SysTools.hs
+++ b/compiler/main/SysTools.hs
@@ -1737,6 +1737,7 @@ linkDynLib dflags0 o_files dep_packages
++ map Option pkg_lib_path_opts
++ map Option pkg_link_opts
++ map Option pkg_framework_opts
+ ++ [ Option "-Wl,-dead_strip_dylibs" ]
)
OSiOS -> throwGhcExceptionIO (ProgramError "dynamic libraries are not supported on iOS target")
_ -> do