Open
Description
When a save a file, recompilation is triggered for all the files which depend on the file I saved.
I tracked down the bug to the fact that
- Interfaces are created with
-haddock
option set. - Recompilation checking is run in a context where
-haddock
is not set.
This seems to be complicated with all the logic with turning -haddock on in some situations and not in others.
The following diff "fixes" the immediate problem for me, but I don't know if there are some situations where interfaces are created without -haddock
being enabled.
--- a/ghcide/src/Development/IDE/Core/Compile.hs
+++ b/ghcide/src/Development/IDE/Core/Compile.hs
@@ -1275,7 +1275,7 @@ loadInterface
-> RecompilationInfo m
-> m ([FileDiagnostic], Maybe HiFileResult)
loadInterface session ms linkableNeeded RecompilationInfo{..} = do
- let sessionWithMsDynFlags = hscSetFlags (ms_hspp_opts ms) session
+ let sessionWithMsDynFlags = hscSetFlags (gopt_set (ms_hspp_opts ms) Opt_Haddock) session
mb_old_iface = hirModIface . fst <$> old_value
mb_old_version = snd <$> old_value
It would be simpler if the options chosen to compile a file were fixed at the start of compilation and not modified in ad-hoc places later on.
In my opinion this is a serious bug.
Activity
All dependent files are recompiled on a save haskell#4511
guibou commentedon May 19, 2025
@mpickering how did you diagnosticed that the rebuild was due to an haddock flag?
Context: I'm having a lot of rebuild. I've documented an analyzed a bit in #4443, but I would like to know more about how you did understood this specific issue so I may apply a similar approach to understand my issues.
mpickering commentedon May 19, 2025
@guibou I turned on
-ddump-hi-diffs -fwrite-if-self-recomp-flags
which needs a GHC which included this patch - https://gitlab.haskell.org/ghc/ghc/-/merge_requests/13792guibou commentedon May 19, 2025
@mpickering Thank you. Indeed, this patch is super interesting. I'll investigate my issues with that.