Skip to content

Cannot build threaded Windows DLL with 9.0.1 and 9.2 RC1

Summary

Starting from GHC 9.0.1 I cannot build a Windows DLL linked against threaded runtime.

Steps to reproduce

Save this as flib-foo.cabal:

cabal-version: 1.16
name: flib-foo
version: 0.1
build-type: Simple

foreign-library flib-foo
  type: native-shared
  options: standalone
  c-sources: flib-foo.c
  ghc-options: -threaded
  build-depends: base
  default-language: Haskell2010

And this is flib-foo.c:

#include <Rts.h>
int foo(){return 1;}

Running cabal build succeeds for Ubuntu + 8.10, Ubuntu + 9.0, Windows + 8.10, but not for Windows + 9.0 (or 9.2 RC1), which fails with

Preprocessing foreign library 'flib-foo' for flib-foo-0.1..
Building foreign library 'flib-foo' for flib-foo-0.1..
C://tools//ghc-9.0.1//mingw//bin/ld.exe: cannot find -lHSrts_thr

I setup a simple project with CI to demonstrate the issue: https://github.com/Bodigrim/flib-foo/runs/3909637479?check_suite_focus=true#step:4:11

Indeed, while 8.10 shipped lib/rts/libHSrts_thr.a, starting from 9.0 there is no such file, because it was renamed to lib/x86_64-windows-ghc-9.0.1/rts-1.0/libHSrts-1.0_thr.a.

Expected behavior

I expect cabal build to succeed in all cases.

Environment

  • GHC version used: 9.0
  • Operating System: Windows
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information