005f0dae

By: Tom Sydney Kerckhove <syd@cs-syd.eu>

Only instrument library components, not test-suites/exes/benches

Cabal's --ghc-option=-fplugin=... in Setup build's buildFlags applies
globally to every component compiled in that invocation. For packages
where addManifest wraps a package with both a library and a test-suite
(e.g. opt-env-conf-test), this caused the test-suite modules to be
instrumented too.

Fix: do a two-step build in addManifest's postBuild. Step 1 (main build
phase) scopes Setup build to lib:<pname> with the plugin flags; step 2
re-runs Setup build with the same flags but MUTATION_PLUGIN_SKIP=1, so
remaining components (test-suite, exe, bench) compile without
instrumentation. The plugin honours the env var. Same plugin flags are
required in step 2 to avoid Cabal seeing a package-set change and
rebuilding the already-instrumented library un-instrumented.

Also switch pluginRecompile from impurePlugin to flagRecompile so that
the second invocation does not force-recompile the library.

Suite timing

Time to Start Worker time Duration Time to finish Idle
Config 0s 2s 2s 2s 0s
Eval 2s 51s 51s 54s 0s
Build 6s 20m27s 19m49s 19m55s 0s
Suite 0s 21m22s 19m55s 19m55s 0s

Timeline

0s1m2m3m4m5m6m7m8m9m10m11m12m13m14m15m16m17m18m19m