On Windows, enabling any plugin drastically worsens compilation time
Summary
On Windows, enabling a GHC plugin in any module increases compilation time by about a minute, regardless of how much is being recompiled - as long as one of the recompiled modules requires the plugin. Aside from that, this added time seems to be independent of how many modules require the plugin.
This appears to be a regression introduced in GHC 9.4.8 (it does not happen in GHC 9.4.7).
Steps to reproduce
Main.hs
:
{-# OPTIONS_GHC -fplugin=Test #-}
module Main where
main :: IO ()
main = putStrLn "Hi"
Test.hs
:
module Test where
import GHC.Driver.Plugins
plugin :: Plugin
plugin = defaultPlugin
In WSL, recompiling yields this (I had to enable -dynamic
for it to work):
[user@Legion plugin-test]$ time ghc Main.hs -dynamic -package ghc
[2 of 3] Compiling Main ( Main.hs, Main.o ) [Impure plugin forced recompilation]
[3 of 3] Linking Main [Objects changed]
real 0m1.943s
user 0m0.939s
sys 0m0.318s
In Windows, recompiling yields this:
$ time ghc Main.hs -package ghc
[2 of 3] Compiling Main ( Main.hs, Main.o ) [Impure plugin forced recompilation]
[3 of 3] Linking Main.exe [Objects changed]
real 0m57.003s
user 0m0.000s
sys 0m0.000s
If the -fplugin
line in Main.hs
is removed, this is the result on Windows instead:
$ time ghc Main.hs -package ghc
[1 of 2] Compiling Main ( Main.hs, Main.o ) [Source file changed]
[2 of 2] Linking Main.exe [Objects changed]
real 0m0.900s
user 0m0.000s
sys 0m0.000s
Expected behavior
The compilation time should not differ significantly between Windows and Linux/WSL.
Environment
- GHC version used: 9.8.1, 9.6.3, 9.4.8
Optional:
- Operating System: Windows 11 (and Arch on WSL)
- System Architecture: x86_64