From 4b2eceaa3530e8cc1490d771d64492c4599e51f3 Mon Sep 17 00:00:00 2001 From: Moritz Angermann Date: Mon, 21 May 2018 19:26:25 +0800 Subject: [PATCH] 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. --- pkgs/development/compilers/ghc/8.0.2.nix | 3 ++- pkgs/development/compilers/ghc/8.2.2.nix | 3 ++- pkgs/development/compilers/ghc/8.4.2.nix | 3 ++- .../backport-dylib-command-size-limit.patch | 24 +++++++++++++++++++ 4 files changed, 30 insertions(+), 3 deletions(-) create mode 100644 pkgs/development/compilers/ghc/backport-dylib-command-size-limit.patch diff --git a/pkgs/development/compilers/ghc/8.0.2.nix b/pkgs/development/compilers/ghc/8.0.2.nix index 7d11ffb66c60..4017a01e7027 100644 --- a/pkgs/development/compilers/ghc/8.0.2.nix +++ b/pkgs/development/compilers/ghc/8.0.2.nix @@ -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 = '' diff --git a/pkgs/development/compilers/ghc/8.2.2.nix b/pkgs/development/compilers/ghc/8.2.2.nix index 192ff1ba207d..dcc2852a3413 100644 --- a/pkgs/development/compilers/ghc/8.2.2.nix +++ b/pkgs/development/compilers/ghc/8.2.2.nix @@ -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 ."; diff --git a/pkgs/development/compilers/ghc/8.4.2.nix b/pkgs/development/compilers/ghc/8.4.2.nix index 94555482d28b..5d8adafa9a7f 100644 --- a/pkgs/development/compilers/ghc/8.4.2.nix +++ b/pkgs/development/compilers/ghc/8.4.2.nix @@ -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 ."; diff --git a/pkgs/development/compilers/ghc/backport-dylib-command-size-limit.patch b/pkgs/development/compilers/ghc/backport-dylib-command-size-limit.patch new file mode 100644 index 000000000000..d0d94717d9c4 --- /dev/null +++ b/pkgs/development/compilers/ghc/backport-dylib-command-size-limit.patch @@ -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