-
Notifications
You must be signed in to change notification settings - Fork 32
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
Runtime failure on Windows on version 0.7.0.0 #65
Comments
@L0neGamer is it possible to reproduce the issue with other versions of GHC, newer than 9.2.8? We have a CI job for Windows + GHC 9.2.8 which seems to succeed, so I'm at loss what's up. |
Sorry I wasn't clear, when I said 9.2.8+ I meant that version and onwards. Also tested on .4.8 and .6.4 |
That's very weird. Can you contribute a reproducer expressed as a CI job? |
Also, what's the Cabal version you are using? |
I'm not sure how I'd do the CI job thing but I can try look into it? It'd probably be best for someone else to though. |
Looking at the CI jobs, the only two relating to windows I can immediately see is one that builds and one that runs with bundled-c-zlib enabled, which is likely the issue here. Can confirm that running |
Well, but the job without |
True. I don't know enough how this stuff works or what the windows environment looks like; if you've reading material or a suggestion of where to read up I can have a go at some stage. |
The thing is that It might be worth to raise the issue at https://gitlab.haskell.org/ghc/ghc/-/issues: it's GHC's responsibility to link correctly (or abort compilation if it's impossible to do so). |
I'll look into raising it over there soon; at the very least maybe I'll be able to get a reproducer for here from them. |
I was also bitten by this on my windows 10 machine. I was able to reproduce the issue while building cabal HEAD. GHC 9.4.8 and cabal 3.10.2.1. |
@fendor please give me a reproducer in a form of CI job. |
No windows runner supported by github (it is just windows-2019 and windows-2022) seems to be able to reproduce the issue right now. |
@fendor you can also try flipping Otherwise file a GHC issue please. |
With the pkg-config flag: $ cabal repl exes --constraint="zlib +pkg-config" Resolving dependencies...
Error: cabal-3.10.2.1.exe: Could not resolve dependencies:
[__0] trying: zlib-ghc-windows-0.1 (user goal)
[__1] trying: zlib-0.7.0.0 (dependency of zlib-ghc-windows)
[__2] trying: zlib:-bundled-c-zlib
[__3] rejecting: zlib:+pkg-config (conflict: pkg-config package zlib-any, not
found in the pkg-config database)
[__3] rejecting: zlib:-pkg-config (constraint from command line flag requires
opposite flag selection)
[__3] fail (backjumping, conflict set: zlib, zlib:bundled-c-zlib,
zlib:pkg-config)
After searching the rest of the dependency tree exhaustively, these were the
goals I've had most trouble fulfilling: zlib, zlib-ghc-windows,
zlib:bundled-c-zlib, zlib:pkg-config
Try running with --minimize-conflict-set to improve the error message. I will file a ghc issue either way. |
@fendor I think ultimately it's either Cabal or GHC responsibility: if |
I agree. I am looking into it a little bit. |
Tracking this issue in ghc: https://gitlab.haskell.org/ghc/ghc/-/issues/24531 |
From recollection, MSYS2 does not come with
|
@andreasabel I think that one is an orthogonal, Stack-specific issue, not quite related to the error here (which is that |
@Bodigrim, this may be off-topic for this particular issue (EDIT: perhaps on topic for #64), but why has The problem I have is: if I have a dependency on |
As I said commercialhaskell/stack#6557, Stackage snapshots should set |
As noted in https://gitlab.haskell.org/ghc/ghc/-/issues/24531#note_559785, the situation on Windows is a little complicated. GHC always links against Where things go wrong is when you actually run the executable. Due to how dynamic linking works on Windows, the loader can't know ahead of time where Many GHC users also have MinGW-w64 installed (via MSYS2), and when you run something in an MSYS2 shell, it will add a directory to your |
Having said all of that, it's unclear to me what can be done about this on the GHC side. I am not a Windows GHC expert, so I presume that there is a good reason for including A workaround would be to compile |
@RyanGlScott is there any way to force static linking? Or is
Is my understanding correct that we can never trust |
In principle, yes, although I haven't managed to figure out its quirks. GHC accepts the That being said, this appears to be somewhat buggy in practice. I tried modifying diff --git a/zlib.cabal b/zlib.cabal
index 24e2595..22aff8b 100644
--- a/zlib.cabal
+++ b/zlib.cabal
@@ -118,7 +118,7 @@ library
pkgconfig-depends: zlib
else
-- On Windows zlib is shipped with GHC starting from 7.10
- extra-libraries: z
+ extra-libraries: :libz.a
test-suite tests
type: exitcode-stdio-1.0 But that fails with a different linker error when building the executable:
The issue isn't really static vs. dynamic libraries, but rather dynamic libraries that are on your runtime search path (e.g., MinGW-w64 libraries) versus ones that aren't (e.g., libraries that are bundled with GHC). Using a dynamically linked |
On Windows, in the Stack environment, I think the GHC-supplied
As indicated above, a number of applications that I use put a copy of |
Thanks for the investigation @RyanGlScott! |
To observe the issue, do the following on Windows (having installed GHC 9.2.8+).
Have an
example.cabal
with the following contents:Have a file
Main.hs
with the following contents:run
cabal build
, thencabal exec example
. For some reason,Test
is not printed to stdout. Runningecho $lastexitcode
shows that the exit code given is-1073741701
, which from a quick google is typically related to incorrect linkings. Note that this is a runtime failure, not a build failure.Changing the zlib version to 0.6.3.0 (which is the previous version) means that this program works.
This is probably related to
Do not force bundled-c-zlib on Windows, but force it for WASM.
in the previous release, if I had to guess.This error arose when similar code was written using a library massively downstream of zlib (
discord-haskell
, with code as below). This is even more surprising, since I'm pretty sure thatrestCall
shouldn't directly referencecompress
or similar valuesOther notes include is that my Windows haskell setup is entirely fresh and made specifically to test this out, so it's unlikely to be an issue with my machine (also considering that someone else brought this issue to me).
The text was updated successfully, but these errors were encountered: