From 24be3cfcff6d1014e03a902b020675edc1d66d44 Mon Sep 17 00:00:00 2001 From: Joel Taylor Date: Tue, 19 May 2015 00:42:09 -0700 Subject: [PATCH] ghc: add Darwin patch for #10322 --- pkgs/development/compilers/ghc/7.10.1.nix | 3 + .../compilers/ghc/osx-dylib-resolver.patch | 60 +++++++++++++++++++ 2 files changed, 63 insertions(+) create mode 100644 pkgs/development/compilers/ghc/osx-dylib-resolver.patch diff --git a/pkgs/development/compilers/ghc/7.10.1.nix b/pkgs/development/compilers/ghc/7.10.1.nix index 4eb4a501e4e..34c2e3b36b0 100644 --- a/pkgs/development/compilers/ghc/7.10.1.nix +++ b/pkgs/development/compilers/ghc/7.10.1.nix @@ -42,6 +42,9 @@ stdenv.mkDerivation rec { url = "https://git.haskell.org/ghc.git/patch/c46e4b184e0abc158ad8f1eff6b3f0421acaf984"; sha256 = "0fkdyqd4bqp742rydwmqq8d2n7gf61bgdhaiw8xf7jy0ix7lr60w"; }) + # Fix TH + indirect symbol resolution on OSX (or any system using gold linker) + # https://phabricator.haskell.org/D852 + ./osx-dylib-resolver.patch ]; postPatch = '' diff --git a/pkgs/development/compilers/ghc/osx-dylib-resolver.patch b/pkgs/development/compilers/ghc/osx-dylib-resolver.patch new file mode 100644 index 00000000000..50236026031 --- /dev/null +++ b/pkgs/development/compilers/ghc/osx-dylib-resolver.patch @@ -0,0 +1,60 @@ +diff --git a/compiler/ghci/Linker.hs b/compiler/ghci/Linker.hs +--- a/compiler/ghci/Linker.hs ++++ b/compiler/ghci/Linker.hs +@@ -119,9 +119,9 @@ + -- that is really important + pkgs_loaded :: ![PackageKey], + +- -- we need to remember the name of the last temporary DLL/.so +- -- so we can link it +- last_temp_so :: !(Maybe (FilePath, String)) } ++ -- we need to remember the name of previous temporary DLL/.so ++ -- libraries so we can link them (see #10322) ++ temp_sos :: ![(FilePath, String)] } + + + emptyPLS :: DynFlags -> PersistentLinkerState +@@ -131,7 +131,7 @@ + pkgs_loaded = init_pkgs, + bcos_loaded = [], + objs_loaded = [], +- last_temp_so = Nothing } ++ temp_sos = [] } + + -- Packages that don't need loading, because the compiler + -- shares them with the interpreted program. +@@ -841,19 +841,19 @@ + dflags2 = dflags1 { + -- We don't want the original ldInputs in + -- (they're already linked in), but we do want +- -- to link against the previous dynLoadObjs +- -- library if there was one, so that the linker ++ -- to link against previous dynLoadObjs ++ -- libraries if there were any, so that the linker + -- can resolve dependencies when it loads this + -- library. + ldInputs = +- case last_temp_so pls of +- Nothing -> [] +- Just (lp, l) -> ++ concatMap ++ (\(lp, l) -> + [ Option ("-L" ++ lp) + , Option ("-Wl,-rpath") + , Option ("-Wl," ++ lp) + , Option ("-l" ++ l) +- ], ++ ]) ++ (temp_sos pls), + -- Even if we're e.g. profiling, we still want + -- the vanilla dynamic libraries, so we set the + -- ways / build tag to be just WayDyn. +@@ -868,7 +868,7 @@ + consIORef (filesToNotIntermediateClean dflags) soFile + m <- loadDLL soFile + case m of +- Nothing -> return pls { last_temp_so = Just (libPath, libName) } ++ Nothing -> return pls { temp_sos = (libPath, libName) : temp_sos pls } + Just err -> panic ("Loading temp shared object failed: " ++ err) + + rmDupLinkables :: [Linkable] -- Already loaded