Skip to content

Enabling a pure Plugin with existing build output never triggers recompilation

Consider the following compilation session:

$ ghc -fplugin ImpurePlugin Foo.hs
<Compiles Foo.hs>
$ ghc Foo.hs

where ImpurePlugin is a Plugin which returns ForceRecompile in pluginRecompile.

The second invocation of GHC doesn't recompile even though ImpurePlugin could have changed the generated build output which would now be out of date.

The same thing happens when switching from an impure/fingerprinted plugin to a pure plugin.

The problem is that pluginRecompileToRecompileRequired just assumes no compilation is required when the current plugin stack is pure, that is either only pure plugins or no plugins at all are registered:

pluginRecompileToRecompileRequired :: Fingerprint -> PluginRecompile -> RecompileRequired
pluginRecompileToRecompileRequired old_fp pr =
  case pr of
    NoForceRecompile -> UpToDate
    ForceRecompile   -> RecompBecause "Plugin forced recompilation"
    MaybeRecompile fp  -> if fp == old_fp then UpToDate

note the UpToDate in the NoForceRecompile case.

Furthermore I would argue that even switching from having no plugin at all active to having a pure plugin active should trigger recompilation, even though the plugin might be pure it could still choose to affect the build output after all.

Trac metadata
Trac field Value
Version 8.7
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information