-
Notifications
You must be signed in to change notification settings - Fork 186
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Don't declare _GNU_SOURCE
on Windows
#551
Comments
great sleuthing! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This issue was spun out of GHC#23309. To summarize that issue,
network
'sHsNet.h
file currently defines the_GNU_SOURCE
macro:network/include/HsNet.h
Line 22 in 8446665
While the comment says that this is meant for Linux, this also takes effect on Windows. One consequence of defining this macro on Windows is that when the
sprintf
function is called later:network/cbits/winSockErr.c
Line 70 in 3ffe896
Then GHC will link against the
mingwex
library. Prior to GHC 9.4.5, GHC would implicitly link againstmingwex
by default, but this is no longer the case with GHC 9.4.5, GHC 9.6.1, or later. This manifests as a linker error when loadingnetwork
with GHC's runtime linker (e.g., when performing a Template Haskell splice involvingnetwork
), as seen in the following places:Cabal
: cabal-testsuite fails early on with linker error on Windows since GHC 9.6 cabal#8858hpack
: Relax upper bound on Cabal dependency sol/hpack#548hakyll
: Fails to build on Windows with GHC 9.6.1 jaspervdj/hakyll#986A simpler way to reproduce the issue is to apply the following patch in
network
:And then run
cabal test
with GHC 9.4.5 or later:Note the mention of
__mingw_vsprintf
in the linker error. The fact that GHC attempts to link against this function is a direct consequence of defining_GNU_SOURCE
, as this is whatsprintf
calls when_GNU_SOURCE
is enabled.Solution
The most direct way to avoid this issue is to avoid defining
_GNU_SOURCE
at all on Windows. There is no particular reason to use_GNU_SOURCE
on Windows, as all of the C code used on Windows is quite standard. I will submit a patch momentarily.The text was updated successfully, but these errors were encountered: