[commit: ghc] ghc-7.10: In ghci linker, link against all previous temp sos (#10322) (96d4d03)

git at git.haskell.org git at git.haskell.org
Mon Jun 1 15:16:32 UTC 2015


Repository : ssh://git@git.haskell.org/ghc

On branch  : ghc-7.10
Link       : http://ghc.haskell.org/trac/ghc/changeset/96d4d036fadaf5468a63b075ffea848e19d08d34/ghc

>---------------------------------------------------------------

commit 96d4d036fadaf5468a63b075ffea848e19d08d34
Author: Reid Barton <rwbarton at gmail.com>
Date:   Tue May 19 01:23:59 2015 -0500

    In ghci linker, link against all previous temp sos (#10322)
    
    The OS X dlopen() appears to only resolve undefined symbols in
    the direct dependencies of the shared library it is loading.
    
    Reviewed By: trommler, austin
    
    Differential Revision: https://phabricator.haskell.org/D852
    
    GHC Trac Issues: #10322
    
    (cherry picked from commit a52f1444ea4045a2075dc88bb973a9289ee7e2cf)


>---------------------------------------------------------------

96d4d036fadaf5468a63b075ffea848e19d08d34
 compiler/ghci/Linker.hs            | 22 +++++++++++-----------
 testsuite/tests/ghci/scripts/all.T |  3 +--
 2 files changed, 12 insertions(+), 13 deletions(-)

diff --git a/compiler/ghci/Linker.hs b/compiler/ghci/Linker.hs
index f9467e1..b5979e8 100644
--- a/compiler/ghci/Linker.hs
+++ b/compiler/ghci/Linker.hs
@@ -118,9 +118,9 @@ data PersistentLinkerState
         -- 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
@@ -130,7 +130,7 @@ emptyPLS _ = PersistentLinkerState {
                         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.
@@ -826,19 +826,19 @@ dynLoadObjs dflags pls objs = do
         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.
@@ -853,7 +853,7 @@ dynLoadObjs dflags pls objs = do
     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
diff --git a/testsuite/tests/ghci/scripts/all.T b/testsuite/tests/ghci/scripts/all.T
index 631d6dc..686d3bb 100755
--- a/testsuite/tests/ghci/scripts/all.T
+++ b/testsuite/tests/ghci/scripts/all.T
@@ -209,5 +209,4 @@ test('T9878b',
 
 test('T10321', normal, ghci_script, ['T10321.script'])
 test('T10110', normal, ghci_script, ['T10110.script'])
-test('T10322', when(opsys('darwin'), expect_broken(10322)),
-    ghci_script, ['T10322.script'])
+test('T10322', normal, ghci_script, ['T10322.script'])



More information about the ghc-commits mailing list