ghc fails to link foreign library
Summary
I was exploring ghc FFI features and got into the following trouble:
The project is building haskell shared lib using cabal foreign library
feature.
Then, this library is linked against C application.
When final executable is invoked, getting this error:
newBoundTask: RTS is not initialised; call hs_init() first
Feels like some linking has gone wrong here. Maybe it is a cabal issue and it doesn't properly link Hs shared libs?
Steps to reproduce
https://github.com/nineonine/foreign-lib-repro
Expected behavior
haskell code can be called from c.
Environment
- GHC version used: 9.0.2
- cabal 3.8.1.0
Optional:
- Operating System: macOS 12.5.1
- System Architecture: arm64