Skip to content
This repository has been archived by the owner on Jan 2, 2021. It is now read-only.

Clarify recompilation logic #891

Closed
wants to merge 1 commit into from
Closed

Clarify recompilation logic #891

wants to merge 1 commit into from

Conversation

wz1000
Copy link
Collaborator

@wz1000 wz1000 commented Oct 31, 2020

Clean up recompilation check - specifically the RecompileRequired result returned by checkOldIface only indicates whether we should recompile the object code. In particular, we don't need to pay attention to it if we aren't generating a Linkable.

The Maybe ModIface field being a Just is sufficient to indicate that we don't need to regenerate the ModIface.

Copy link
Collaborator

@pepeiborra pepeiborra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. But this code is very tricky so I think it's worth adding an extra check.

Comment on lines +705 to +728
Just ObjectLinkable
| not (recompileRequired obj_needs_recomp)
-- If the module used TH splices when it was last
-- compiled, then the recompilation check is not
-- accurate enough (https://gitlab.haskell.org/ghc/ghc/-/issues/481)
-- and we must ignore
-- it. However, if the module is stable (none of
-- the modules it depends on, directly or
-- indirectly, changed), then we *can* skip
-- recompilation. This is why the SourceModified
-- type contains SourceUnmodifiedAndStable, and
-- it's pretty important: otherwise ghc --make
-- would always recompile TH modules, even if
-- nothing at all has changed. Stability is just
-- the same check that make is doing for us in
-- one-shot mode.
, not (mi_used_th iface) || SourceUnmodifiedAndStable == sourceMod
-> do
-- Look for the old obj if we don't need recompilation
mb_linkable <- liftIO $ findObjectLinkableMaybe (ms_mod ms) (ms_location ms)
case mb_linkable of
Just linkable@(LM obj_time _ _) | obj_time > ms_hs_date ms -> liftIO $ do
hmi <- mkDetailsFromIface session iface (Just linkable)
return ([], Just $ HiFileResult ms hmi)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh right, so we do not need to regenerate the iface when TH splices are involved, only recompile. This is great.

src/Development/IDE/Core/Compile.hs Show resolved Hide resolved
@pepeiborra
Copy link
Collaborator

The ghcide Github project is becoming archived and merged into https://github.com/haskell/haskell-language-server

This PR will need to be reopened in the HLS repo. To do that, create a new branch from HLS HEAD in your HLS repo and do:

git remote add ghcide https://github.com/georgefst/ghcide.git
git fetch ghcide
git merge ghcide disable-warnings

Thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants