diff options
Diffstat (limited to 'compiler/ghci/Linker.hs')
-rw-r--r-- | compiler/ghci/Linker.hs | 35 |
1 files changed, 19 insertions, 16 deletions
diff --git a/compiler/ghci/Linker.hs b/compiler/ghci/Linker.hs index 8c2a07c07f..f62998ce86 100644 --- a/compiler/ghci/Linker.hs +++ b/compiler/ghci/Linker.hs @@ -117,7 +117,7 @@ data PersistentLinkerState -- The currently-loaded packages; always object code -- Held, as usual, in dependency order; though I am not sure if -- that is really important - pkgs_loaded :: ![PackageKey], + pkgs_loaded :: ![UnitId], -- we need to remember the name of previous temporary DLL/.so -- libraries so we can link them (see #10322) @@ -138,10 +138,10 @@ emptyPLS _ = PersistentLinkerState { -- -- The linker's symbol table is populated with RTS symbols using an -- explicit list. See rts/Linker.c for details. - where init_pkgs = [rtsPackageKey] + where init_pkgs = [rtsUnitId] -extendLoadedPkgs :: [PackageKey] -> IO () +extendLoadedPkgs :: [UnitId] -> IO () extendLoadedPkgs pkgs = modifyPLS_ $ \s -> return s{ pkgs_loaded = pkgs ++ pkgs_loaded s } @@ -540,7 +540,7 @@ getLinkDeps :: HscEnv -> HomePackageTable -> Maybe FilePath -- replace object suffices? -> SrcSpan -- for error messages -> [Module] -- If you need these - -> IO ([Linkable], [PackageKey]) -- ... then link these first + -> IO ([Linkable], [UnitId]) -- ... then link these first -- Fails with an IO exception if it can't find enough files getLinkDeps hsc_env hpt pls replace_osuf span mods @@ -578,8 +578,8 @@ getLinkDeps hsc_env hpt pls replace_osuf span mods -- tree recursively. See bug #936, testcase ghci/prog007. follow_deps :: [Module] -- modules to follow -> UniqSet ModuleName -- accum. module dependencies - -> UniqSet PackageKey -- accum. package dependencies - -> IO ([ModuleName], [PackageKey]) -- result + -> UniqSet UnitId -- accum. package dependencies + -> IO ([ModuleName], [UnitId]) -- result follow_deps [] acc_mods acc_pkgs = return (uniqSetToList acc_mods, uniqSetToList acc_pkgs) follow_deps (mod:mods) acc_mods acc_pkgs @@ -593,7 +593,7 @@ getLinkDeps hsc_env hpt pls replace_osuf span mods when (mi_boot iface) $ link_boot_mod_error mod let - pkg = modulePackageKey mod + pkg = moduleUnitId mod deps = mi_deps iface pkg_deps = dep_pkgs deps @@ -1059,7 +1059,7 @@ showLS (Framework nm) = "(framework) " ++ nm -- automatically, and it doesn't matter what order you specify the input -- packages. -- -linkPackages :: DynFlags -> [PackageKey] -> IO () +linkPackages :: DynFlags -> [UnitId] -> IO () -- NOTE: in fact, since each module tracks all the packages it depends on, -- we don't really need to use the package-config dependencies. -- @@ -1075,13 +1075,13 @@ linkPackages dflags new_pkgs = do modifyPLS_ $ \pls -> do linkPackages' dflags new_pkgs pls -linkPackages' :: DynFlags -> [PackageKey] -> PersistentLinkerState +linkPackages' :: DynFlags -> [UnitId] -> PersistentLinkerState -> IO PersistentLinkerState linkPackages' dflags new_pks pls = do pkgs' <- link (pkgs_loaded pls) new_pks return $! pls { pkgs_loaded = pkgs' } where - link :: [PackageKey] -> [PackageKey] -> IO [PackageKey] + link :: [UnitId] -> [UnitId] -> IO [UnitId] link pkgs new_pkgs = foldM link_one pkgs new_pkgs @@ -1091,14 +1091,13 @@ linkPackages' dflags new_pks pls = do | Just pkg_cfg <- lookupPackage dflags new_pkg = do { -- Link dependents first - pkgs' <- link pkgs [ resolveInstalledPackageId dflags ipid - | ipid <- depends pkg_cfg ] + pkgs' <- link pkgs (depends pkg_cfg) -- Now link the package itself ; linkPackage dflags pkg_cfg ; return (new_pkg : pkgs') } | otherwise - = throwGhcExceptionIO (CmdLineError ("unknown package: " ++ packageKeyString new_pkg)) + = throwGhcExceptionIO (CmdLineError ("unknown package: " ++ unitIdString new_pkg)) linkPackage :: DynFlags -> PackageConfig -> IO () @@ -1200,7 +1199,7 @@ locateLib dflags is_hs dirs lib -- for a dynamic library (#5289) -- otherwise, assume loadDLL can find it -- - = findDll `orElse` findArchive `orElse` tryGcc `orElse` assumeDll + = findDll `orElse` findArchive `orElse` tryGcc `orElse` tryGccPrefixed `orElse` assumeDll | not dynamicGhc -- When the GHC package was not compiled as dynamic library @@ -1221,6 +1220,7 @@ locateLib dflags is_hs dirs lib hs_dyn_lib_file = mkHsSOName platform hs_dyn_lib_name so_name = mkSOName platform lib + lib_so_name = "lib" ++ so_name dyn_lib_file = case (arch, os) of (ArchX86_64, OSSolaris2) -> "64" </> so_name _ -> so_name @@ -1230,7 +1230,8 @@ locateLib dflags is_hs dirs lib findArchive = liftM (fmap Archive) $ findFile dirs arch_file findHSDll = liftM (fmap DLLPath) $ findFile dirs hs_dyn_lib_file findDll = liftM (fmap DLLPath) $ findFile dirs dyn_lib_file - tryGcc = liftM (fmap DLLPath) $ searchForLibUsingGcc dflags so_name dirs + tryGcc = liftM (fmap DLLPath) $ searchForLibUsingGcc dflags so_name dirs + tryGccPrefixed = liftM (fmap DLLPath) $ searchForLibUsingGcc dflags lib_so_name dirs assumeDll = return (DLL lib) infixr `orElse` @@ -1242,7 +1243,9 @@ locateLib dflags is_hs dirs lib searchForLibUsingGcc :: DynFlags -> String -> [FilePath] -> IO (Maybe FilePath) searchForLibUsingGcc dflags so dirs = do - str <- askCc dflags (map (FileOption "-L") dirs + -- GCC does not seem to extend the library search path (using -L) when using + -- --print-file-name. So instead pass it a new base location. + str <- askCc dflags (map (FileOption "-B") dirs ++ [Option "--print-file-name", Option so]) let file = case lines str of [] -> "" |