summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--compiler/ghci/Linker.lhs5
-rw-r--r--compiler/main/DriverPipeline.hs9
-rw-r--r--compiler/main/DynFlags.hs3
-rw-r--r--compiler/main/StaticFlags.hs12
-rw-r--r--ghc/Main.hs20
5 files changed, 19 insertions, 30 deletions
diff --git a/compiler/ghci/Linker.lhs b/compiler/ghci/Linker.lhs
index 7a5ca901bc..2607ca0449 100644
--- a/compiler/ghci/Linker.lhs
+++ b/compiler/ghci/Linker.lhs
@@ -44,7 +44,6 @@ import BasicTypes
import Outputable
import Panic
import Util
-import StaticFlags
import ErrUtils
import SrcLoc
import qualified Maybes
@@ -264,7 +263,7 @@ showLinkerState dflags
-- @-l@ options in @v_Opt_l@,
--
-- d) Loading any @.o\/.dll@ files specified on the command line, now held
--- in @v_Ld_inputs@,
+-- in @ldInputs@,
--
-- e) Loading any MacOS frameworks.
--
@@ -298,7 +297,7 @@ reallyInitDynLinker dflags =
; libspecs <- mapM (locateLib dflags False lib_paths) minus_ls
-- (d) Link .o files from the command-line
- ; cmdline_ld_inputs <- readIORef v_Ld_inputs
+ ; let cmdline_ld_inputs = ldInputs dflags
; classified_ld_inputs <- mapM (classifyLdInput dflags) cmdline_ld_inputs
diff --git a/compiler/main/DriverPipeline.hs b/compiler/main/DriverPipeline.hs
index a579519ae6..4db4245f0a 100644
--- a/compiler/main/DriverPipeline.hs
+++ b/compiler/main/DriverPipeline.hs
@@ -39,7 +39,6 @@ import Module
import UniqFM ( eltsUFM )
import ErrUtils
import DynFlags
-import StaticFlags ( v_Ld_inputs )
import Config
import Panic
import Util
@@ -357,7 +356,7 @@ linkingNeeded dflags linkables pkg_deps = do
Left _ -> return True
Right t -> do
-- first check object files and extra_ld_inputs
- extra_ld_inputs <- readIORef v_Ld_inputs
+ let extra_ld_inputs = ldInputs dflags
e_extra_times <- mapM (tryIO . getModificationUTCTime) extra_ld_inputs
let (errs,extra_times) = splitEithers e_extra_times
let obj_times = map linkableTime linkables ++ extra_times
@@ -1557,7 +1556,7 @@ getLinkInfo dflags dep_packages = do
pkg_frameworks <- case platformOS (targetPlatform dflags) of
OSDarwin -> getPackageFrameworks dflags dep_packages
_ -> return []
- extra_ld_inputs <- readIORef v_Ld_inputs
+ let extra_ld_inputs = ldInputs dflags
let
link_info = (package_link_opts,
pkg_frameworks,
@@ -1715,7 +1714,7 @@ linkBinary dflags o_files dep_packages = do
return []
-- probably _stub.o files
- extra_ld_inputs <- readIORef v_Ld_inputs
+ let extra_ld_inputs = ldInputs dflags
-- opts from -optl-<blah> (including -l<blah> options)
let extra_ld_opts = getOpts dflags opt_l
@@ -1913,7 +1912,7 @@ linkDynLib dflags o_files dep_packages
let pkg_link_opts = collectLinkOpts dflags pkgs_no_rts
-- probably _stub.o files
- extra_ld_inputs <- readIORef v_Ld_inputs
+ let extra_ld_inputs = ldInputs dflags
let extra_ld_opts = getOpts dflags opt_l
diff --git a/compiler/main/DynFlags.hs b/compiler/main/DynFlags.hs
index 3f8ed450eb..b5d17ca195 100644
--- a/compiler/main/DynFlags.hs
+++ b/compiler/main/DynFlags.hs
@@ -563,6 +563,8 @@ data DynFlags = DynFlags {
-- Set by @-ddump-file-prefix@
dumpPrefixForce :: Maybe FilePath,
+ ldInputs :: [String],
+
includePaths :: [String],
libraryPaths :: [String],
frameworkPaths :: [String], -- used on darwin only
@@ -1130,6 +1132,7 @@ defaultDynFlags mySettings =
dynLibLoader = SystemDependent,
dumpPrefix = Nothing,
dumpPrefixForce = Nothing,
+ ldInputs = [],
includePaths = [],
libraryPaths = [],
frameworkPaths = [],
diff --git a/compiler/main/StaticFlags.hs b/compiler/main/StaticFlags.hs
index 34acd98b8a..7b89db8b52 100644
--- a/compiler/main/StaticFlags.hs
+++ b/compiler/main/StaticFlags.hs
@@ -66,7 +66,6 @@ module StaticFlags (
-- misc opts
opt_ErrorSpans,
opt_HistorySize,
- v_Ld_inputs,
opt_StubDeadValues,
-- For the parser
@@ -293,20 +292,9 @@ opt_UF_DearOp = ( 40 :: Int)
opt_ErrorSpans :: Bool
opt_ErrorSpans = lookUp (fsLit "-ferror-spans")
--- object files and libraries to be linked in are collected here.
--- ToDo: perhaps this could be done without a global, it wasn't obvious
--- how to do it though --SDM.
-GLOBAL_VAR(v_Ld_inputs, [], [String])
-
-----------------------------------------------------------------------------
-- Tunneling our global variables into a new instance of the GHC library
--- Ignore the v_Ld_inputs global because:
--- a) It is mutated even once GHC has been initialised, which means that I'd
--- have to add another layer of indirection to truly share the value
--- b) We can get away without sharing it because it only affects the link,
--- and is mutated by the GHC exe. Users who load up a new copy of the GHC
--- library while another is running almost certainly won't actually access it.
saveStaticFlagGlobals :: IO (Bool, [String])
saveStaticFlagGlobals = liftM2 (,) (readIORef v_opt_C_ready) (readIORef v_opt_C)
diff --git a/ghc/Main.hs b/ghc/Main.hs
index 53ca70e296..2cf50818ba 100644
--- a/ghc/Main.hs
+++ b/ghc/Main.hs
@@ -182,11 +182,6 @@ main' postLoadMode dflags0 args flagWarnings = do
liftIO $ showBanner postLoadMode dflags2
- -- we've finished manipulating the DynFlags, update the session
- _ <- GHC.setSessionDynFlags dflags2
- dflags3 <- GHC.getSessionDynFlags
- hsc_env <- GHC.getSession
-
let
-- To simplify the handling of filepaths, we normalise all filepaths right
-- away - e.g., for win32 platforms, backslashes are converted
@@ -194,9 +189,12 @@ main' postLoadMode dflags0 args flagWarnings = do
normal_fileish_paths = map (normalise . unLoc) fileish_args
(srcs, objs) = partition_args normal_fileish_paths [] []
- -- Note: have v_Ld_inputs maintain the order in which 'objs' occurred on
- -- the command-line.
- liftIO $ mapM_ (consIORef v_Ld_inputs) (reverse objs)
+ dflags2a = dflags2 { ldInputs = objs ++ ldInputs dflags2 }
+
+ -- we've finished manipulating the DynFlags, update the session
+ _ <- GHC.setSessionDynFlags dflags2a
+ dflags3 <- GHC.getSessionDynFlags
+ hsc_env <- GHC.getSession
---------------- Display configuration -----------
when (verbosity dflags3 >= 4) $
@@ -251,7 +249,7 @@ partition_args (arg:args) srcs objs
{-
We split out the object files (.o, .dll) and add them
- to v_Ld_inputs for use by the linker.
+ to ldInputs for use by the linker.
The following things should be considered compilation manager inputs:
@@ -639,7 +637,9 @@ doMake srcs = do
o_files <- mapM (\x -> liftIO $ compileFile hsc_env StopLn x)
non_hs_srcs
- liftIO $ mapM_ (consIORef v_Ld_inputs) (reverse o_files)
+ dflags <- GHC.getSessionDynFlags
+ let dflags' = dflags { ldInputs = o_files ++ ldInputs dflags }
+ _ <- GHC.setSessionDynFlags dflags'
targets <- mapM (uncurry GHC.guessTarget) hs_srcs
GHC.setTargets targets