GHCi linker can't find closure symbol starting with GHC 9.2.6
After upgrading from GHC 9.2.5 to GHC 9.2.7, we (Chordify) have started to get errors when trying to load certain modules in GHCi:1
<no location info>: error:
GHC.ByteCode.Linker.lookupCE
During interactive linking, GHCi couldn't find the following symbol:
base_DataziEither_zdfShowEither2_closure
This may be due to you not asking GHCi to load extra object files,
archives or DLLs needed by your current session. Restart GHCi, specifying
the missing library using the -L/path/to/object/dir and -lmissinglibname
flags, or simply by naming the relevant files on the GHCi command line.
Alternatively, this link failure might indicate a bug in GHCi.
If you suspect the latter, please report this as a GHC bug:
https://www.haskell.org/ghc/reportabug
This error also occurs on 9.2.6, so it was seemingly introduced by that release, and it also occurs on 9.4.5.
It appears to be triggered by TH splices that use code from another module but the same package: one of the offending modules has a top-level splice along the lines of
deriveSqlInstancesFor
[ ''Title
, ''Subtitle
, ''IsSiteWide
-- etc.
]
Commenting this splice out makes the module load fine; replacing the definition of deriveSqlInstancesFor
with const (pure [])
instead doesn't, whereas replacing the call with $(pure [])
is fine again. Invoking GHCi with -fobject-code
also fixes the issue, so the problem apparently occurs only with interpreted, not compiled, TH code. This is confirmed by the fact that the same module calls TH code from an external package fine.
#20244 and #22961 (closed) appear related, though the former appears to be triggered by different circumstances, and the latter is supposed to be fixed in 9.2.7.
Steps to reproduce
I haven't been able to come up with a minimal reproduction yet; the error occurs in our production code so I can't share that either unfortunately.
Environment
- GHC version used: 9.2.6, 9.2.7, 9.4.5 (using Stackage snapshots
lts-20.12
,lts-20.23
,lts-21.0
respectively)
Optional:
- Operating System: Linux, MacOS
-
We've since upgraded to GHC 9.4.5 which is the version I used to copy-paste the error; the errors on 9.2.x mention a different symbol (also mentioning a
Show
instance and ending in_closure
) but are otherwise identical and occur in the same place.↩