I have a build-type: Hooks cabal package that generates some source files as part of the build by exec-ing some external programs for generating the code. This all works perfectly fine when building with x64 ghc. However, when building against Wasm I get a linker error because cabal is compiling the setup binary with the -threaded flag causing the linker to try to link against the threaded ghc runtime, which IIUC doesn’t exist for Wasm.
[3 of 3] Linking /root/magic-the-haskelling/dist-newstyle/build/wasm32-wasi/ghc-9.12.2.20250327/api-0.1.0.0/setup/setup.wasm
wasm-ld: error: unable to find library -lHSrts-1.0.2_thr
wasm32-wasi-clang: error: linker command failed with exit code 1 (use -v to see invocation)
wasm32-wasi-ghc-9.12.2.20250327: wasm32-wasi-clang' failed in phase Linker’. (Exit code: 1)
HasCallStack backtrace:
bracket, called at compiler/GHC/Driver/Make.hs:2959:3 in ghc-9.12.2.20250327-inplace:GHC.Driver.Make
Error: [Cabal-7125]
Failed to build api-0.1.0.0-inplace. The failure occurred during the configure step.
CallStack (from HasCallStack):
dieWithException, called at src/Distribution/Client/ProjectOrchestration.hs:1241:21 in cabal-install-3.14.1.1-inplace:Distribution.Client.ProjectOrchestration
If I run the command without -threaded then it links successfully.
Is there any way to customize how cabal builds this setup binary, or some other way to get unstuck?