Opened 6 years ago

Closed 5 years ago

Last modified 5 years ago

#9243 closed bug (fixed)

Recompilation avoidance doesn't work for -fno-code/-fwrite-interface

Reported by: ezyang Owned by: ezyang
Priority: high Milestone: 7.10.1
Component: Compiler Version: 7.9
Keywords: backpack Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Compile-time performance bug Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s): Phab:D596
Wiki Page:


With the latest -fwrite-interface enhancements, a build directory can contain interface files independently of object files. In cases like this, we would like to have recompilation avoidance avoid typechecking files whose interface files are up-to-date.

However, this does not currently work: we always re-typecheck:

t-edyang@cam-05-unx:/5playpen/t-edyang/sandbox/q$ /5playpen/t-edyang/ghc-backpack/inplace/bin/ghc-stage2 --make A.hs -fno-code -fwrite-interface
[1 of 1] Compiling A                ( A.hs, nothing )
t-edyang@cam-05-unx:/5playpen/t-edyang/sandbox/q$ /5playpen/t-edyang/ghc-backpack/inplace/bin/ghc-stage2 --make A.hs -fno-code -fwrite-interface
[1 of 1] Compiling A                ( A.hs, nothing )

The reason for this is that recompilation avoidance logic in compileOne (in DriverPipeline.hs) seems to rely exclusively on "linkables" in order to figure out if source has been modified or not. We never generate an object file with -fwrite-interface, so the compiler always concludes that we need to retypecheck.

However, recompilation avoidance for hs-boot does work. The reason for this is because we create a dummy o-boot linkable. We can't use this strategy for -fno-code, because the dummy object file would imply that we actually compiled the file (which we didn't).

The upshot is that to fix this problem, it looks like we might have to rejigger all of the logic in compileOne, which why I gave up on this for now.

Related to

Change History (11)

comment:1 Changed 6 years ago by ezyang

Keywords: backpack added

comment:2 Changed 5 years ago by ezyang

Differential Rev(s): D596
Owner: set to ezyang
Priority: normalhigh

comment:3 Changed 5 years ago by ezyang

Milestone: 7.10.1

comment:4 Changed 5 years ago by ezyang

Summary: Recompilation avoidance works imperfectly with -fno-code/-fwrite-interfaceRecompilation avoidance doesn't work for -fno-code/-fwrite-interface

comment:5 Changed 5 years ago by ezyang

Status: newpatch

comment:6 Changed 5 years ago by simonpj

Differential Rev(s): D596Phab:D596

comment:7 Changed 5 years ago by Edward Z. Yang <ezyang@…>

In 2223e196b2dc5340d70e58be011c279d381b4319/ghc:

Fix #9243 so recompilation avoidance works with -fno-code

Where we track timestamps of object files, also track timestamps
for interface files.  When -fno-code -fwrite-interface is enabled, use
the interface file timestamp as an extra check to see if the files are
up-to-date.  We had to apply this logic to one-shot and make modes.

This fix would be good to merge into 7.10; it makes using -fno-code
-fwrite-interface for flywheel type checking usable.

Signed-off-by: Edward Z. Yang <>

Test Plan: validate and new test cases

Reviewers: austin

Subscribers: carter, thomie

Differential Revision:

GHC Trac Issues: #9243

comment:8 Changed 5 years ago by ezyang

Status: patchmerge

comment:9 Changed 5 years ago by ezyang

Oh, to be clear to whoever merges: you probably need the parent commit

comment:10 Changed 5 years ago by thoughtpolice

Resolution: fixed
Status: mergeclosed

Merged into ghc-7.10.

comment:11 Changed 5 years ago by Thomas Miedema <thomasmiedema@…>

In bc604bdb0144010e8582caa6ea159ca0446c04f2/ghc:

Update assert to fix retc001 and retc002 (#9243)

Since 2223e196b2dc5340d70e58be011c279d381b4319, maybe_old_linkable can
be Nothing even with an up-to-date interface file. This happens when
compiling with --make -fno-code -fwrite-interface.

See also Note [Recompilation checking when typechecking only] in

This fixes retc001 and retc002 when ghc_debugged.

Differential Revision:
Note: See TracTickets for help on using tickets.