[WIP] mingw-w64 for haskell cross compilation with ghc.#37254
[WIP] mingw-w64 for haskell cross compilation with ghc.#37254angerman wants to merge 44 commits intoNixOS:masterfrom
Conversation
|
/cc @Ericson2314 |
There was a problem hiding this comment.
While disabling this check, allows most of the cross compilation to succeed on macOS, I believe this is also the reason why we end up with mixed (build and target) packages in the stdenv eventually.
There was a problem hiding this comment.
This change is motivated by the fact that we do not necessarily build haddock with quick flavours. As such we fall over trying to paxmark a file that does not exist.
There was a problem hiding this comment.
Sounds good-- probably can collapse this to just {ghc,haddock} if we check for existence anyway.
There was a problem hiding this comment.
--via-asm is a rather recent feature in hsc2hs that is part of ghc > 8.4
There was a problem hiding this comment.
This could potentially also be the reason for the incorrect package set on darwin.
There was a problem hiding this comment.
Better to do ghcFlavour ? if targetPlatform != hostPlatform then "perf-cros" else ""
c8f682e to
de9b33e
Compare
There was a problem hiding this comment.
Does terminfo/ncurses not work on windows?
If it was failing to find ncurses headers/libs see the fix on my musl PR (remove attempt to specify where to find them).
There was a problem hiding this comment.
In the case of cross compiling to windows, we don't want terminfo, the GHC build system disables terminfoin that case anyway.
There was a problem hiding this comment.
It only disables it in some cross build "flavour"s, which we don't have to use as-is. Works for me building cross-aarch64-musl and such. Anyway sounds like you're saying windows in particular shouldn't use this, which I'll take your word for.
|
If you're touching cctools, #37606 might have some useful bits. |
There was a problem hiding this comment.
I believe that the description of this option is actually quite incorrect and misleading. Setting this to true has no effect on whether ghc builds shared libraries or not. Rather, it affects the code that's used by ghci to load compiled objects for interpretation. There's a good chance that this setting is completely ignored on Windows anyway. Could you please check whether the change you've made here is actually necessary?
There was a problem hiding this comment.
enable* is about how the current package is linked. I think this does just that. That this also affects how GHCi works is just a side affect due to GHCi's fragile interpretation.
|
Beep boop, how's this going? |
|
@dtzWill this does work as-is (I've used this to build So I ended up writing Cabal2Nix, which really needs a better name. I now have hackage.nix, stackage.nix as well as some glue code in haskell.nix. This is pretty much work-in-progress. While it does allow me to build some trivial hs-hello package, it is nowhere near polished yet, and will likely see some additional changes. I believe it will provide a much better basis for cross compilation haskell packages. |
|
@angerman that sounds fascinating but I think your links are broken? |
There was a problem hiding this comment.
Here propagated setup dependencies are not taken into account. That is, your pkgdb will contain only immediate setup dependencies but their transitive dependencies will not be in it, so it won’t compile.
There was a problem hiding this comment.
inherit setupHaskellDepends, I guess.
There was a problem hiding this comment.
I think ghc should go to nativeBuildInputs.
For cross compilation, we don't need it, it's deferred to the Setup derivation. When ghc is th enativeGhc, we don't need to add it to the buildInputs either.
nixpkgs#37012 and nixpkgs#37707 introduces the setup-hooks for libiconv, which inject `-liconv` into the `NIX_LDFLAGS`. This breaks horribly on windows where the linker end up having no idea how to linke `-liconv`. The configure.ac file specifically ignores libiconv on windows.
This reverts commit 7f86470.
98cff92 to
68d2d15
Compare
Nix cc logic relies on passing /lib for each dependency as a library search path. This makes little sense for haskell packages, as their libs are nested deeply in the /lib tree. Also GHC will generate the right library serach paths on its own from the package database entries. The larger issue though is that with one search path entry for each library, and a similar one generated by GHC for each dependency will eventually overflow the command line argument limits. As such we do *not* put haskell libraries into $out anymore.
Motivation for this change
This includes all the necessary changes to nixpkgs, that allow me to cross compile haskell to
windows via mingw-w64. It is not yet sufficient to allow cross compilation of Template Haskell.
Things done
build-use-sandboxinnix.confon non-NixOS)nix-shell -p nox --run "nox-review wip"./result/bin/)