Starting Clash is really slow on Windows with modern GHC's
## Summary At least GHC 9.4.8, and GHC 9.6.3 up to and including 9.12.2 are very, very slow on Windows when starting up [Clash](https://github.com/clash-lang/clash-compiler). We mainly observe this on Clash but discovered that the same problem occurs with [doctest-parallel](https://github.com/martijnbastiaan/doctest-parallel), which is a much smaller code base so easier to run and debug. This is observed on GitHub Windows runners (`windows-2022`, _Microsoft Windows Server 2022 10.0.20348 Datacenter_) and on our own desktops, at least one of which runs Windows 11 Pro 24H2. If I compile Clash with Stack LTS 23.19 on my old Core i5-4690k and Windows 11 Pro 24H2, and start `clashi` (which is a modification of `ghci`), it will output some text, and then spend 53 seconds before showing the prompt. Of course, this is a rather old machine. ## Steps to reproduce ``` git clone https://github.com/martijnbastiaan/doctest-parallel.git cd doctest-parallel git checkout d3df7aa cabal build doctests cabal run doctests ``` On GHC 9.4.8 and 9.6.3 through 9.8.4, `cabal run doctests` takes 14 seconds (except that 9.8.3 is uninstallable). On newer versions, it's even slower: | GHC | Mean runtime (s) | | ------ | ------ | | 9.12.2 | 18 | | 9.12.1 | 17 | | 9.10.1 | 15 | The test was run on GitHub Actions at [martijnbastiaan/benchmark-ghc:experiments](https://github.com/martijnbastiaan/benchmark-ghc/tree/experiments) and the result is [attached as a CSV file](/uploads/d0941266863d4ed7e10e0ce44bc4efd8/results.csv). Additionally, the results are in this details block: <details><summary>Execution speed</summary> | OS | GHC | Mean runtime (s) | |--|--|--| | windows-latest | 9.12.2 | 18.1 | | windows-latest | 9.12.1 | 17.3 | | windows-latest | 9.10.1 | 14.9 | | windows-latest | 9.8.4 | 13.6 | | windows-latest | 9.8.2 | 13.7 | | windows-latest | 9.8.1 | 14.0 | | windows-latest | 9.6.7 | 14.0 | | windows-latest | 9.6.6 | 14.4 | | windows-latest | 9.6.5 | 13.7 | | windows-latest | 9.6.4 | 14.0 | | windows-latest | 9.6.3 | 14.0 | | windows-latest | 9.6.2 | 4.7 | | windows-latest | 9.6.1 | 4.7 | | windows-latest | 9.4.8 | 13.8 | | windows-latest | 9.4.7 | 4.2 | | windows-latest | 9.4.6 | 4.7 | | windows-latest | 9.4.5 | 4.3 | | windows-latest | 9.4.4 | 4.3 | | windows-latest | 9.4.3 | 4.5 | | windows-latest | 9.4.2 | 4.3 | | windows-latest | 9.4.1 | 4.3 | | windows-latest | 9.2.8 | 3.7 | | windows-latest | 9.2.7 | 3.8 | | windows-latest | 9.2.6 | 3.6 | | windows-latest | 9.2.5 | 3.5 | | windows-latest | 9.2.4 | 3.6 | | windows-latest | 9.2.3 | 3.7 | | windows-latest | 9.2.2 | 3.6 | | windows-latest | 9.2.1 | 3.5 | | windows-latest | 8.10.7 | 3.6 | | windows-latest | 8.10.6 | 3.7 | | windows-latest | 8.10.5 | 3.6 | | windows-latest | 8.10.4 | 3.8 | | windows-latest | 8.10.3 | 3.5 | | windows-latest | 8.10.1 | 3.7 | | ubuntu-24.04 | 9.12.2 | 1.0 | | ubuntu-24.04 | 9.12.1 | 1.0 | | ubuntu-24.04 | 9.10.1 | 0.9 | | ubuntu-24.04 | 9.8.4 | 0.9 | | ubuntu-24.04 | 9.8.2 | 0.9 | | ubuntu-24.04 | 9.8.1 | 0.8 | | ubuntu-24.04 | 9.6.7 | 0.8 | | ubuntu-24.04 | 9.6.6 | 0.9 | | ubuntu-24.04 | 9.6.5 | 0.9 | | ubuntu-24.04 | 9.6.4 | 1.0 | | ubuntu-24.04 | 9.6.3 | 0.9 | | ubuntu-24.04 | 9.6.2 | 0.9 | | ubuntu-24.04 | 9.6.1 | 0.9 | | ubuntu-24.04 | 9.4.8 | 0.9 | | ubuntu-24.04 | 9.4.7 | 0.9 | | ubuntu-24.04 | 9.4.6 | 0.9 | | ubuntu-24.04 | 9.4.5 | 0.9 | | ubuntu-24.04 | 9.4.4 | 0.9 | | ubuntu-24.04 | 9.4.3 | 0.9 | | ubuntu-24.04 | 9.4.2 | 0.9 | | ubuntu-24.04 | 9.4.1 | 0.9 | | ubuntu-24.04 | 9.2.8 | 0.8 | | ubuntu-24.04 | 9.2.7 | 0.9 | | ubuntu-24.04 | 9.2.6 | 0.9 | | ubuntu-24.04 | 9.2.5 | 0.9 | | ubuntu-24.04 | 9.2.4 | 0.9 | | ubuntu-24.04 | 9.2.3 | 0.9 | | ubuntu-24.04 | 9.2.2 | 0.9 | | ubuntu-24.04 | 9.2.1 | 0.9 | | ubuntu-24.04 | 8.10.7 | 0.9 | | ubuntu-24.04 | 8.10.6 | 1.0 | | ubuntu-24.04 | 8.10.5 | 1.0 | | ubuntu-24.04 | 8.10.4 | 1.0 | | ubuntu-24.04 | 8.10.3 | 1.0 | | ubuntu-24.04 | 8.10.2 | 0.9 | | ubuntu-24.04 | 8.10.1 | 1.0 | </details> ## Expected behavior The `run doctests` should take about 4 seconds on a GitHub Actions Windows runner, which it does do for GHC 8.10.1 through 9.4.7 (except that 8.10.2 failed compilation and somehow we forgot to test on 9.0). ## Environment * Operating System: Windows Server 2022 / Windows 11 Pro 24H2 * System Architecture: x86_64
issue