Allow reuse of temporary object files which are generated by GHCi in particular circumstances
Motivation
!554 (merged) makes it so that GHCi will be able to load projects which use UnboxedTuples. In order to do this, it enables object code generation for modules which use UnboxedTuples, and every module they depend on. There is existing precedent for transitively enabling object code generation - it's also needed for modules which use TemplateHaskell. For the code handling the TemplateHaskell case, I found a few relevant comments:
We don't want to create .o or .hi files unless we have been asked to by the user. But we need them, so we patch their locations in the ModSummary with temporary files.
And elsewhere a TODO of how to support reuse of these files:
- Offer a -no-codedir command line option, and write what were temporary object files there. This would speed up recompilation.
Proposal
I'm not convinced that an entirely new option is needed, though. What if instead manual specification of -odir
and -hidir
was interpreted as an opt-in to persistent object files? While less explicit than a -no-codedir
option, seems like a fairly reasonable way to opt-in