`ghci` fails to load shared temp object files in a peculiar way relating to `TemplateHaskell`
Summary
I do not yet have a minimal reproduction because this occurred on our work codebase and involves a bunch of moving parts. Instead I will describe our situation with all the variables that appear to cause it, and I'll hopefully be back soon with a reproduction.
We want to be able to load shared object files in ghci
to get faster boot, so we don't have to re-interpret everything. We do this with cabal repl lib:$(package) --ghc-options "-osuf dyn_o -hisuf dyn_hi"
.
We recently had TemplateHaskell
enabled globally, but we're trying to cut down our usage, so we made it an explicit pragma on the modules that use it.
Once this happened, some folks started having problems with our make ghci
command as above. We'd get errors like this:
<no location info>: error:
ghc: panic! (the 'impossible' happened)
(GHC version 8.10.7:
Loading temp shared object failed: /run/user/1000/ghc272396_0/libghc_551.so: undefined symbol: mwbzm0zminplace_ModelziAlphanumericText_genAlphaNumericText_closure
But running cabal repl lib:$(package)
worked totally fine. So the problem definitely seemed like it was related to loading shared object files. Unfortunately, removing the loading of shared object files is usually a huge hit to initial load with ghci
since we need to interpret like 1600 modules.
What was worse is that some people had the problem and some did not! What was especially bad is that I wasn't getting the problem at all, and it was my team's job to fix it
After a while of suffering with it, I noticed something when I was firing up ghci
, trying to reproduce it. I wasn't loading my .ghci
file because the repository directory was writable. This is not something that would be controlled by our build system (nix
), nor would it be controlled by git
- which would explain why some folks were getting it and some folks were not.
Once I made the directory safe with the suggested chmod go-w .
, ghci
happily loaded the .ghci
file and started crashing.
well i'll be danged
I took a peek at the .ghci
file and saw that it had two lines, :set -XTemplateHaskell
and :set -XQuasiQuotes
. Removing these two lines in .ghci
has completely fixed the problem.
With that big exposition out of the way, I'm going to go and try and make a minimal reproduction.
Steps to reproduce
Please provide a set of concrete steps to reproduce the issue.
Expected behavior
What do you expect the reproducer described above to do?
Environment
- GHC version used: 8.10.7
Optional:
- Operating System: Ubuntu/OSX
- System Architecture: Intel/AMD and Apple M1