Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
GHC
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Alexander Kaznacheev
GHC
Commits
16ba7571
Commit
16ba7571
authored
12 years ago
by
Simon Marlow
Committed by
ian@well-typed.com
12 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Invalidate the ModSummary cache in setSessionDynFlags (#7478)
parent
723570da
Loading
Loading
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
compiler/main/GHC.hs
+27
-0
27 additions, 0 deletions
compiler/main/GHC.hs
with
27 additions
and
0 deletions
compiler/main/GHC.hs
+
27
−
0
View file @
16ba7571
...
...
@@ -498,6 +498,7 @@ setSessionDynFlags dflags = do
(
dflags'
,
preload
)
<-
liftIO
$
initPackages
dflags
modifySession
$
\
h
->
h
{
hsc_dflags
=
dflags'
,
hsc_IC
=
(
hsc_IC
h
){
ic_dflags
=
dflags'
}
}
invalidateModSummaryCache
return
preload
-- | Sets the program 'DynFlags'.
...
...
@@ -505,8 +506,34 @@ setProgramDynFlags :: GhcMonad m => DynFlags -> m [PackageId]
setProgramDynFlags
dflags
=
do
(
dflags'
,
preload
)
<-
liftIO
$
initPackages
dflags
modifySession
$
\
h
->
h
{
hsc_dflags
=
dflags'
}
invalidateModSummaryCache
return
preload
-- When changing the DynFlags, we want the changes to apply to future
-- loads, but without completely discarding the program. But the
-- DynFlags are cached in each ModSummary in the hsc_mod_graph, so
-- after a change to DynFlags, the changes would apply to new modules
-- but not existing modules; this seems undesirable.
--
-- Furthermore, the GHC API client might expect that changing
-- log_action would affect future compilation messages, but for those
-- modules we have cached ModSummaries for, we'll continue to use the
-- old log_action. This is definitely wrong (#7478).
--
-- Hence, we invalidate the ModSummary cache after changing the
-- DynFlags. We do this by tweaking the date on each ModSummary, so
-- that the next downsweep will think that all the files have changed
-- and preprocess them again. This won't necessarily cause everything
-- to be recompiled, because by the time we check whether we need to
-- recopmile a module, we'll have re-summarised the module and have a
-- correct ModSummary.
--
invalidateModSummaryCache
::
GhcMonad
m
=>
m
()
invalidateModSummaryCache
=
modifySession
$
\
h
->
h
{
hsc_mod_graph
=
map
inval
(
hsc_mod_graph
h
)
}
where
inval
ms
=
ms
{
ms_hs_date
=
addUTCTime
(
-
1
)
(
ms_hs_date
ms
)
}
-- | Returns the program 'DynFlags'.
getProgramDynFlags
::
GhcMonad
m
=>
m
DynFlags
getProgramDynFlags
=
getSessionDynFlags
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment