-
Notifications
You must be signed in to change notification settings - Fork 725
Description
Describe the bug
MODULE1: Uses template haskell. References MODULE2 (e.g. by importing some definition from there)
MODULE2: In addition to the definition needed by MODULE1, it includes a FFI import (of a symbol defined in a .c file).
On Windows, this does not successfully compile. On Mac, this compiles without issue.
Examining -v3 output, the .c file appears to build after the Haskell modules. On Mac this isn't a problem. On Windows, running TH fails when it can't link the symbol that it should eventually find the in the .c file.
To Reproduce
Steps to reproduce the behavior (on windows):
Clone this repo: https://github.com/asivitz/windows_link_error
$ cabal build
Additionally, a build log of a Github action is available here: https://github.com/asivitz/windows_link_error/actions/runs/16758169600/job/47446201028
Expected behavior
Should build without error.
System information
- Windows 10
- GHCs 9.8.4-9.12.2 (and perhaps others).
- cabal-installs 3.10.3-3.16.0.0 (and perhaps others).
Additional context
The following cabal-less one-liner succeeds on both windows and mac, which suggests to me this is a cabal issue:
ghc -package base -package template-haskell -iSmall Small/Dep.hs Small/Foo.hs foreign_fun.c
Is there a reason we wouldn't just build the .c files first, before any haskell modules? Seems like that could be a straightforward fix.
Thank you!