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
llvm for windows cross compiler #59865
Conversation
without this it fails on missing `opt`
without this it fails on missing `opt`
You can just use the NCG for windows cross compilation. We (iohk) are in fact cross compiling to windows successfully using nix. NB: i would advise not to use the LLVM backend on x86_64. (See the GHC Release Notes) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please don't use LLVM for windows. Use the NCG. The GHC LLVM backend has serious flaws on x86_64. See https://downloads.haskell.org/~ghc/8.6.4/docs/html/users_guide/8.6.4-notes.html#known-issues
Use the cross-ncg
flavour, see: https://github.com/ghc/ghc/blob/36e51406eb5c551f6fdc5b2f9e087c1d3a809141/mk/build.mk.sample#L31-L32
Hmm... We are using ncg right now and getting this error:
https://hydra.nixos.org/build/92403485 ghc-8.4.4 should cross compile to windows correct? |
@matthewbauer I think 8.4.4 did work. But you'll need to make sure that your Our ghc is pretty heavily patched, but I believe you'll need at least the |
@angerman |
for windows/x86_64, yes! We have a proper native code generator (ncg) for x86_64, and the llvm one for x86_64 is buggy anyway. For targets for which we don't have an ncg (arm, aarch64, ...) the only option is the llvm backend, but I believe the llvm pipeline for those backends is unaffected from the register confusion that can cause subtle bugs on x86_64 with llvm. |
@tmcl Is this PR still relevant? Can it be closed? If it is still relevant, what is the status of it? |
I think this might be interesting for better windows support, but it doesn't seem like there's much interest from the creator. Please re-open when you still want to work on this, or when someone wants to pick this open, create a new PR :). |
Motivation for this change
Nixpkgs is almost capable of building GHC as an x86-64 Windows cross compiler. It just needs to useLLVM. The resulting binaries are capable of running on Windows 10 and making basic ffi calls. Note that it still fails if targeting 32-bit i686 on a 64 bit machine.
Things done
sandbox
innix.conf
on non-NixOS)nix-shell -p nix-review --run "nix-review wip"
./result/bin/
)nix path-info -S
before and after)Win32 is marked as broken so you probably can't run cabal2nix to make things build. It is built as part of ghc so not a big deal.