DriverPipeline/HscMain DynFlags mystery

Ben Gamari ben at
Fri Nov 1 00:40:43 UTC 2019

On October 31, 2019 2:45:09 PM EDT, "Ömer Sinan Ağacan" <omeragacan at> wrote:
>We recently did some refactoring in HscMain and DriverPipeline to
>interfaces after final Cmms are generated (previously interfaces would
>generated after the tidying pass). It's mostly done but there's one
>thing that I
>couldn't figure out after two full days of debugging (I also asked a
>few people
>about it on IRC), so I wanted to ask here in case someone here knows.
>Previously the interface value (ModIface) would be generated and
>written to disk
>in `HscMain.finish`. The DynFlags we use to generate the ModIface and
>to write
>it to disk would be the one passed to `HscMain.hscIncrementalCompile`.
>In the new implementation part of the interface is still generated in
>`HscMain.hscIncrementalCompile` (see mkPartialIface), using the same
>DynFlags as
>before. But more stuff is added after the final Cmms are generated (see
>mkFullIface calls in DriverPipeline) using DynFlags in `compileOne'` or
>`runPhase` (called by `runPipeline`). It turns out these DynFlags are
>enough from the one passed to `HscMain.hscIncrementalCompile` that some
>fail (I remember a backpack test, but there may be more).
>("Full" interfaces are written to disk right after generation)
>See [1] for the hack I added as a workaround. Basically I keep the
>passed to hscIncrementalCompile so that I can generate the final
>The question is what's changing in DynFlags that makes things go wrong.
>I tried
>looking at the fields used by mkFullIface and hscMaybeWriteIface, but
>as far as
>I can see none of the fields used by these functions are different from
>DynFlags passed to hscIncrementalCompile.
>If anyone knows what's going on any help would be appreciated.
>ghc-devs mailing list
>ghc-devs at

The question would be easier to answer if it included a bit more context:

- this is in reference to !1304, correct? 
- specifically which tests fail and in which ways?
- what is the "more stuff" that you are adding?

In general when it comes to bugs like this I find it help to reduce the size of the patch as much as possible. In your case, the CAF refactor is probably quite irrelevant to the issue you are seeing. I would try to extract the pipeline refactor that is triggering your bug into a separate MR which can be assessed independently from the CAF business.

This may take a few minutes but in my experience this sort of exercise is almost always worth the effort. Even if you don't find the bug while splitting up the patch it will be significantly easier for others to help with the result. 


- Ben 

More information about the ghc-devs mailing list