Filter out the FFI library when loading package in ghci
[ghc-hetmet.git] / compiler / ghci / Linker.lhs
index d53d247..9fc22df 100644 (file)
@@ -51,7 +51,6 @@ import ErrUtils
 import SrcLoc
 import qualified Maybes
 import UniqSet
-import FiniteMap
 import Constants
 import FastString
 import Config          ( cProjectVersion )
@@ -62,6 +61,7 @@ import Control.Monad
 import Data.Char
 import Data.IORef
 import Data.List
+import qualified Data.Map as Map
 import Foreign
 import Control.Concurrent.MVar
 
@@ -1001,7 +1001,7 @@ linkPackages' dflags new_pks pls = do
        | Just pkg_cfg <- lookupPackage pkg_map new_pkg
        = do {  -- Link dependents first
                pkgs' <- link pkgs [ Maybes.expectJust "link_one" $
-                                    lookupFM ipid_map ipid
+                                    Map.lookup ipid ipid_map
                                   | ipid <- depends pkg_cfg ]
                -- Now link the package itself
             ; linkPackage dflags pkg_cfg
@@ -1017,6 +1017,12 @@ linkPackage dflags pkg
         let dirs      =  Packages.libraryDirs pkg
 
         let libs      =  Packages.hsLibraries pkg
+            -- The FFI GHCi import lib isn't needed as
+            -- compiler/ghci/Linker.lhs + rts/Linker.c link the
+            -- interpreted references to FFI to the compiled FFI.
+            -- We therefore filter it out so that we don't get
+            -- duplicate symbol errors.
+            libs'     =  filter ("HSffi" /=) libs
         -- Because of slight differences between the GHC dynamic linker and
         -- the native system linker some packages have to link with a
         -- different list of libraries when using GHCi. Examples include: libs
@@ -1028,7 +1034,7 @@ linkPackage dflags pkg
                             then Packages.extraLibraries pkg
                             else Packages.extraGHCiLibraries pkg)
                       ++ [ lib | '-':'l':lib <- Packages.ldOptions pkg ]
-        classifieds   <- mapM (locateOneObj dirs) libs
+        classifieds   <- mapM (locateOneObj dirs) libs'
 
         -- Complication: all the .so's must be loaded before any of the .o's.  
        let dlls = [ dll | DLL dll    <- classifieds ]