diff options
author | Austin Seipp <austin@well-typed.com> | 2014-06-30 07:44:31 -0500 |
---|---|---|
committer | Austin Seipp <austin@well-typed.com> | 2014-06-30 07:44:31 -0500 |
commit | aed1723f97e0539d5ab35222b180c1552a5f4cfc (patch) | |
tree | ae3ba54bf08fcef95eadbcf3910ad2f8613df764 /compiler | |
parent | abeb2bbc5f2237783476d53f44e5b7e6490c4e7e (diff) | |
download | haskell-aed1723f97e0539d5ab35222b180c1552a5f4cfc.tar.gz |
Revert "Fix obscure problem with using the system linker (#8935)"
This reverts commit 2f8b4c9330b455d4cb31c186c747a7db12a69251.
Signed-off-by: Austin Seipp <austin@well-typed.com>
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/ghci/Linker.lhs | 72 |
1 files changed, 23 insertions, 49 deletions
diff --git a/compiler/ghci/Linker.lhs b/compiler/ghci/Linker.lhs index 162c349a8d..0b23985be8 100644 --- a/compiler/ghci/Linker.lhs +++ b/compiler/ghci/Linker.lhs @@ -124,12 +124,8 @@ 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 :: ![PackageId], - - -- we need to remember the name of the last temporary DLL/.so - -- so we can link it - last_temp_so :: !(Maybe FilePath) - } + pkgs_loaded :: ![PackageId] + } emptyPLS :: DynFlags -> PersistentLinkerState emptyPLS _ = PersistentLinkerState { @@ -137,8 +133,7 @@ emptyPLS _ = PersistentLinkerState { itbl_env = emptyNameEnv, pkgs_loaded = init_pkgs, bcos_loaded = [], - objs_loaded = [], - last_temp_so = Nothing } + objs_loaded = [] } -- Packages that don't need loading, because the compiler -- shares them with the interpreted program. @@ -320,14 +315,14 @@ reallyInitDynLinker dflags = ; if null cmdline_lib_specs then return pls else do - { pls1 <- foldM (preloadLib dflags lib_paths framework_paths) pls cmdline_lib_specs + { mapM_ (preloadLib dflags lib_paths framework_paths) cmdline_lib_specs ; maybePutStr dflags "final link ... " ; ok <- resolveObjs ; if succeeded ok then maybePutStrLn dflags "done" else throwGhcExceptionIO (ProgramError "linking extra libraries/objects failed") - ; return pls1 + ; return pls }} @@ -366,21 +361,19 @@ classifyLdInput dflags f return Nothing where platform = targetPlatform dflags -preloadLib :: DynFlags -> [String] -> [String] -> PersistentLinkerState -> LibrarySpec -> IO (PersistentLinkerState) -preloadLib dflags lib_paths framework_paths pls lib_spec +preloadLib :: DynFlags -> [String] -> [String] -> LibrarySpec -> IO () +preloadLib dflags lib_paths framework_paths lib_spec = do maybePutStr dflags ("Loading object " ++ showLS lib_spec ++ " ... ") case lib_spec of Object static_ish - -> do (b, pls1) <- preload_static lib_paths static_ish + -> do b <- preload_static lib_paths static_ish maybePutStrLn dflags (if b then "done" else "not found") - return pls1 Archive static_ish -> do b <- preload_static_archive lib_paths static_ish maybePutStrLn dflags (if b then "done" else "not found") - return pls DLL dll_unadorned -> do maybe_errstr <- loadDLL (mkSOName platform dll_unadorned) @@ -396,14 +389,12 @@ preloadLib dflags lib_paths framework_paths pls lib_spec case err2 of Nothing -> maybePutStrLn dflags "done" Just _ -> preloadFailed mm lib_paths lib_spec - return pls DLLPath dll_path -> do maybe_errstr <- loadDLL dll_path case maybe_errstr of Nothing -> maybePutStrLn dflags "done" Just mm -> preloadFailed mm lib_paths lib_spec - return pls Framework framework -> if platformUsesFrameworks (targetPlatform dflags) @@ -411,7 +402,6 @@ preloadLib dflags lib_paths framework_paths pls lib_spec case maybe_errstr of Nothing -> maybePutStrLn dflags "done" Just mm -> preloadFailed mm framework_paths lib_spec - return pls else panic "preloadLib Framework" where @@ -431,13 +421,11 @@ preloadLib dflags lib_paths framework_paths pls lib_spec -- Not interested in the paths in the static case. preload_static _paths name = do b <- doesFileExist name - if not b then return (False, pls) - else if dynamicGhc - then do pls1 <- dynLoadObjs dflags pls [name] - return (True, pls1) - else do loadObj name - return (True, pls) - + if not b then return False + else do if dynamicGhc + then dynLoadObjs dflags [name] + else loadObj name + return True preload_static_archive _paths name = do b <- doesFileExist name if not b then return False @@ -804,8 +792,8 @@ dynLinkObjs dflags pls objs = do wanted_objs = map nameOfObject unlinkeds if dynamicGhc - then do pls2 <- dynLoadObjs dflags pls1 wanted_objs - return (pls2, Succeeded) + then do dynLoadObjs dflags wanted_objs + return (pls1, Succeeded) else do mapM_ loadObj wanted_objs -- Link them all together @@ -819,11 +807,9 @@ dynLinkObjs dflags pls objs = do pls2 <- unload_wkr dflags [] pls1 return (pls2, Failed) - -dynLoadObjs :: DynFlags -> PersistentLinkerState -> [FilePath] - -> IO PersistentLinkerState -dynLoadObjs _ pls [] = return pls -dynLoadObjs dflags pls objs = do +dynLoadObjs :: DynFlags -> [FilePath] -> IO () +dynLoadObjs _ [] = return () +dynLoadObjs dflags objs = do let platform = targetPlatform dflags soFile <- newTempName dflags (soExt platform) let -- When running TH for a non-dynamic way, we still need to make @@ -831,22 +817,10 @@ dynLoadObjs dflags pls objs = do -- Opt_Static off dflags1 = gopt_unset dflags Opt_Static 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 - -- can resolve dependencies when it loads this - -- library. - ldInputs = - case last_temp_so pls of - Nothing -> [] - Just so -> - let (lp, l) = splitFileName so in - [ Option ("-L" ++ lp) - , Option ("-Wl,-rpath") - , Option ("-Wl," ++ lp) - , Option ("-l:" ++ l) - ], + -- We don't want to link the ldInputs in; we'll + -- be calling dynLoadObjs with any objects that + -- need to be linked. + ldInputs = [], -- 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. @@ -858,7 +832,7 @@ dynLoadObjs dflags pls objs = do consIORef (filesToNotIntermediateClean dflags) soFile m <- loadDLL soFile case m of - Nothing -> return pls { last_temp_so = Just soFile } + Nothing -> return () Just err -> panic ("Loading temp shared object failed: " ++ err) rmDupLinkables :: [Linkable] -- Already loaded |