Runtime linker fails to link an object
In !2231 (closed) we replace integer-gmp with a ghc-bignum package. ghc-bignum implementation uses unboxed sums which GHC implements with unboxed tuples. GHC fills unreachable tuple fields with absentSumFieldError defined in base.
There were some test failures that happened only when we build GHC with the legacy make based build system.
T5313: /builds/hsyl20/ghc/libraries/ghc-bignum/dist-install/build/HSghc-bignum-1.0.o: unknown symbol `base_ControlziExceptionziBase_absentSumFieldError_closure'
T5313: T5313: unable to load package `ghc-bignum-1.0'
-- same error for: T10052 T10508_api T3372 T5313 T8628 T8639_api dynCompileExpr linker_unload linker_unload_multiple_objs static-plugins
I tracked this down to the legacy make build system producing both HSghc-bignum-1.0.o and libHSghc-bignum-1.0.a while Hadrian only produces the latter. I confirmed with strace that the culprit is the .o file. If it isn't present the runtime linker loads the .a and the tests pass.
A workaround is to make the runtime linker looks for archives before objects.
What would be a proper way to fix this?
Possibly related: #13786 (closed)