Hi all,
I recently made a refactor to a relatively simple project I’m creating. I hadn’t compiled the project in a while as I was using hls to catch compiler errors, and then some 200 edits later (as measured by git), when the refactor was complete, I found that the project was failing to compile in the linking stage. You can see below for an abridged version of the error message.
In case it’s helpful, the refactor largely involved the creation of a newtype to separate logic to do with that type into its own module.
So far I have tried:
- Compiling on macOS and x86-64 linux.
- Compiling from a “clean” environment, i.e. after running
cabal clean
. - Downgrading ghc, since cabal doesn’t claim to support the version I’ve been developing in (9.4.7).
None of the above changed the error significantly. I thought it might be best to ask here before I go any further: does anyone have any ideas for debugging the error, apart from incrementally rolling back changes? I will do that in the worst case but want to avoid it if possible since the number of edits since the last successful compilation is decently large.
Here’s the error log:
Linking <working dir>/dist-newstyle/build/x86_64-linux/ghc-9.2.8/haculator-0.1.0.0/x/haculator/build/haculator/haculator ...
ld.lld: error: undefined symbol: haculatorzm0zi1zi0zi0zminplace_CalculatorziLinearExpression_expo_closure
>>> referenced by Calculator.o:(haculatorzm0zi1zi0zi0zminplace_Calculator_evalExpo_info) in archive <working dir>/dist-newstyle/build/x86_64-linux/ghc-9.2.8/haculator-0.1.0.0/build/libHShaculator-0.1.0.0-inplace.a
>>> referenced by Calculator.o:(.data+0x188) in archive <working dir>/dist-newstyle/build/x86_64-linux/ghc-9.2.8/haculator-0.1.0.0/build/libHShaculator-0.1.0.0-inplace.a
ld.lld: error: undefined symbol: haculatorzm0zi1zi0zi0zminplace_CalculatorziLinearExpression_expozuzdssingle_closure
>>> referenced by Calculator.o:(.text+0xBF4) in archive <working dir>/dist-newstyle/build/x86_64-linux/ghc-9.2.8/haculator-0.1.0.0/build/libHShaculator-0.1.0.0-inplace.a
>>> referenced by Calculator.o:(.text+0xC34) in archive <working dir>/dist-newstyle/build/x86_64-linux/ghc-9.2.8/haculator-0.1.0.0/build/libHShaculator-0.1.0.0-inplace.a
>>> referenced by Calculator.o:(.data+0x198) in archive <working dir>/dist-newstyle/build/x86_64-linux/ghc-9.2.8/haculator-0.1.0.0/build/libHShaculator-0.1.0.0-inplace.a
<<<more undefined symbols>>>
ld.lld: error: undefined symbol: haculatorzm0zi1zi0zi0zminplace_CalculatorziLinearExpression_addzuzdsunionWithDefault_closure
>>> referenced by Calculator.o:(.data+0x130) in archive <working dir>/dist-newstyle/build/x86_64-linux/ghc-9.2.8/haculator-0.1.0.0/build/libHShaculator-0.1.0.0-inplace.a
>>> referenced by Calculator.o:(.data+0x150) in archive <working dir>/dist-newstyle/build/x86_64-linux/ghc-9.2.8/haculator-0.1.0.0/build/libHShaculator-0.1.0.0-inplace.a
>>> referenced by Calculator.o:(.data+0x278) in archive <working dir>/dist-newstyle/build/x86_64-linux/ghc-9.2.8/haculator-0.1.0.0/build/libHShaculator-0.1.0.0-inplace.a
ld.lld: error: too many errors emitted, stopping now (use --error-limit=0 to see all errors)
collect2: error: ld returned 1 exit status
`gcc' failed in phase `Linker'. (Exit code: 1)
And here’s the offending commit. Thanks very much for any help in advance!