summaryrefslogtreecommitdiff
path: root/compiler
diff options
context:
space:
mode:
authorSylvain Henry <sylvain@haskus.fr>2020-05-20 18:29:14 +0200
committerMarge Bot <ben+marge-bot@smart-cactus.org>2020-06-13 02:13:03 -0400
commitbfd0a78cdd0287c26998a4d9419174e4dc305c6f (patch)
tree7f864f90f4561782929acee2141385c328ab0aa9 /compiler
parentac964c8350ba41082e9dca9cf1b7ff02aea2a636 (diff)
downloadhaskell-bfd0a78cdd0287c26998a4d9419174e4dc305c6f.tar.gz
Don't return preload units when we set DyNFlags
Preload units can be retrieved in UnitState when needed (i.e. in GHCi)
Diffstat (limited to 'compiler')
-rw-r--r--compiler/GHC.hs22
-rw-r--r--compiler/GHC/Driver/Backpack.hs6
-rw-r--r--compiler/GHC/Driver/MakeFile.hs2
-rw-r--r--compiler/GHC/Runtime/Debugger.hs2
-rw-r--r--compiler/GHC/Unit/State.hs4
5 files changed, 18 insertions, 18 deletions
diff --git a/compiler/GHC.hs b/compiler/GHC.hs
index 9f9f2ad758..b619f0c14c 100644
--- a/compiler/GHC.hs
+++ b/compiler/GHC.hs
@@ -594,10 +594,10 @@ checkBrokenTablesNextToCode' dflags
-- flags. If you are not doing linking or doing static linking, you
-- can ignore the list of packages returned.
--
-setSessionDynFlags :: GhcMonad m => DynFlags -> m [UnitId]
+setSessionDynFlags :: GhcMonad m => DynFlags -> m ()
setSessionDynFlags dflags = do
dflags' <- checkNewDynFlags dflags
- (dflags''', preload) <- liftIO $ initUnits dflags'
+ dflags''' <- liftIO $ initUnits dflags'
-- Interpreter
interp <- if gopt Opt_ExternalInterpreter dflags
@@ -637,12 +637,14 @@ setSessionDynFlags dflags = do
-- already one set up
}
invalidateModSummaryCache
- return preload
-- | Sets the program 'DynFlags'. Note: this invalidates the internal
-- cached module graph, causing more work to be done the next time
-- 'load' is called.
-setProgramDynFlags :: GhcMonad m => DynFlags -> m [UnitId]
+--
+-- Returns a boolean indicating if preload units have changed and need to be
+-- reloaded.
+setProgramDynFlags :: GhcMonad m => DynFlags -> m Bool
setProgramDynFlags dflags = setProgramDynFlags_ True dflags
-- | Set the action taken when the compiler produces a message. This
@@ -654,17 +656,17 @@ setLogAction action = do
void $ setProgramDynFlags_ False $
dflags' { log_action = action }
-setProgramDynFlags_ :: GhcMonad m => Bool -> DynFlags -> m [UnitId]
+setProgramDynFlags_ :: GhcMonad m => Bool -> DynFlags -> m Bool
setProgramDynFlags_ invalidate_needed dflags = do
dflags' <- checkNewDynFlags dflags
dflags_prev <- getProgramDynFlags
- (dflags'', preload) <-
- if (packageFlagsChanged dflags_prev dflags')
- then liftIO $ initUnits dflags'
- else return (dflags', [])
+ let changed = packageFlagsChanged dflags_prev dflags'
+ dflags'' <- if changed
+ then liftIO $ initUnits dflags'
+ else return dflags'
modifySession $ \h -> h{ hsc_dflags = dflags'' }
when invalidate_needed $ invalidateModSummaryCache
- return preload
+ return changed
-- When changing the DynFlags, we want the changes to apply to future
diff --git a/compiler/GHC/Driver/Backpack.hs b/compiler/GHC/Driver/Backpack.hs
index 95005b405e..f798051a56 100644
--- a/compiler/GHC/Driver/Backpack.hs
+++ b/compiler/GHC/Driver/Backpack.hs
@@ -203,8 +203,7 @@ withBkpSession cid insts deps session_type do_this = do
} )) $ do
dflags <- getSessionDynFlags
-- pprTrace "flags" (ppr insts <> ppr deps) $ return ()
- -- Calls initUnits
- _ <- setSessionDynFlags dflags
+ setSessionDynFlags dflags -- calls initUnits
do_this
withBkpExeSession :: [(Unit, ModRenaming)] -> BkpM a -> BkpM a
@@ -392,8 +391,7 @@ addPackage pkg = do
{ unitDatabasePath = "(in memory " ++ showSDoc dflags (ppr (unitId pkg)) ++ ")"
, unitDatabaseUnits = [pkg]
}
- _ <- GHC.setSessionDynFlags (dflags { unitDatabases = Just (dbs ++ [newdb]) })
- return ()
+ GHC.setSessionDynFlags (dflags { unitDatabases = Just (dbs ++ [newdb]) })
compileInclude :: Int -> (Int, Unit) -> BkpM ()
compileInclude n (i, uid) = do
diff --git a/compiler/GHC/Driver/MakeFile.hs b/compiler/GHC/Driver/MakeFile.hs
index 6a50ec483f..78d030b6dd 100644
--- a/compiler/GHC/Driver/MakeFile.hs
+++ b/compiler/GHC/Driver/MakeFile.hs
@@ -69,7 +69,7 @@ doMkDependHS srcs = do
hiSuf = "hi",
objectSuf = "o"
}
- _ <- GHC.setSessionDynFlags dflags
+ GHC.setSessionDynFlags dflags
when (null (depSuffixes dflags)) $ liftIO $
throwGhcExceptionIO (ProgramError "You must specify at least one -dep-suffix")
diff --git a/compiler/GHC/Runtime/Debugger.hs b/compiler/GHC/Runtime/Debugger.hs
index 93869b35dd..5f7ff50347 100644
--- a/compiler/GHC/Runtime/Debugger.hs
+++ b/compiler/GHC/Runtime/Debugger.hs
@@ -183,7 +183,7 @@ showTerm term = do
showPpr dflags bname ++
") :: Prelude.IO Prelude.String"
dl = hsc_dynLinker hsc_env
- _ <- GHC.setSessionDynFlags dflags{log_action=noop_log}
+ GHC.setSessionDynFlags dflags{log_action=noop_log}
txt_ <- withExtendedLinkEnv dl
[(bname, fhv)]
(GHC.compileExprRemote expr)
diff --git a/compiler/GHC/Unit/State.hs b/compiler/GHC/Unit/State.hs
index 07752cb98d..c4e2d0673a 100644
--- a/compiler/GHC/Unit/State.hs
+++ b/compiler/GHC/Unit/State.hs
@@ -572,7 +572,7 @@ listUnitInfo state = Map.elems (unitInfoMap state)
-- 'packageFlags' field of the 'DynFlags', and it will update the
-- 'unitState' in 'DynFlags' and return a list of packages to
-- link in.
-initUnits :: DynFlags -> IO (DynFlags, [UnitId])
+initUnits :: DynFlags -> IO DynFlags
initUnits dflags = do
let forceUnitInfoMap (state, _) = unitInfoMap state `seq` ()
@@ -592,7 +592,7 @@ initUnits dflags = do
}
dflags'' = upd_wired_in_home_instantiations dflags'
- return (dflags'', preloadUnits state)
+ return dflags''
-- -----------------------------------------------------------------------------
-- Reading the unit database(s)