-
-
Notifications
You must be signed in to change notification settings - Fork 13.7k
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
ghc cross-compilation and ghc-musl: notes, issues encountered, progress #37522
Comments
This is the result of setting stage1Only which we currently set when |
* drop "BuildFlavor", this has no effect here * grab patches from gentoo to fix various cross build system bugs * explicitly set CrossCompilePrefix to the expected targetPrefix -- ensures everything has expected name and location -- fixes lack of prefix'ing when doing glibc -> musl "cross" * Stage1Only: only set if doing "true" cross * don't try to specify include/lib dirs for ncurses -- only used by terminfo which actually removed the include option, and the lib option doesn't seem to do anything other than confuse the situation re:cross. Fixes NixOS#37522
@dtzWill is there a way to get native stdenv with musl (x86_64-linux)? |
There is |
It was my understanding musl-native GHC was blocked on providing a musl-native bootstrap GHC, is that not a problem? (resolving this was primarily why I was looking into cross-compiling GHC to musl) That issue suggests setting |
Could we use cross-compiled musl for bootstrapping native one? |
I expect so, although I think there's some packaging/build options that are used for generating a bootstrap GHC. FWIW various musl-based distributions have bootstrap GHC's we may want to use as a starting point (assuming such things are more or less usable elsewhere) --modulo concerns about "trusting trust". But yes the idea was to explore generating a bootstrap GHC from a cross build, although perhaps upstream can comment on how this is usually done. |
@Ericson2314 hey whatcha doing? Are you intentionally pushing to my branch? Apparently broke some things, but mostly just wanna know what's going on. Rebasing onto latest? |
With that push, GHC 8.2.2 doesn't build any more for me, I get a failure in the
|
Looks like that is the answer, see #37598 (comment) |
@Ericson2314 Should we just rebase it on top of the commit before the broken one ( |
@nh2 I'd merge it in. It's a 100% whole world mass rebuild unfortuantely since it changes cc-wrapper. |
@Ericson2314 However you prefer -- I'm OK with mass rebuilds, better rebuilds than broken builds. |
Definitely keep working on this -- based on this, I now managed to build a Haskell package with lots of dependencies ( |
Notes
Some of this, I just discovered, repeats items from #36200 and its discussion, but including for now while brain-dump things :).
Apologies that at this hour I'm mostly full of issues and not notes.
For now, checkmarks are issues tackled in my branch/efforts, not neccesarily upstream yet.
Issues
BuildFlavour
inmk/build.mk
does nothing by default, inmk/build.mk.sample
(for versions I inspected, and I suspect all) there's code that goes "if buildFlavour != "" then include ./mk/flavours/${buildFlavour}.mk`. I'm not sure what "flavour" we want, this seems like something worth checking out--cross and non-cross-- to ensure we're doing what we want.-cxx
suffix, it should bec++
/nix/store/4yjvzsnk906bm61sk2037bvwbcnlsydg-aarch64-unknown-linux-musl-ghc-8.2.2
(available via cache.nixos.org).Minor?
$out/lib/${targetPrefix}-ghc-${version}
(or so), this is not the case unless ghc "thinks" it is cross-compiling. Which it doesn't when cross-compiling to musl O:). D'oh to hit this after building all the rest, hehe.--with-curses-includes
flag, because of reasons. Anyway only use of setting this is to addncurses.dev
as a build dep of some sort-- which if that is all we want should probably be accomplished more directly.--with-as=/path/to/as
instead of settingAS
, but I'm not sure.Good news / Progress
Aarch64-musl works?!
As linked above.. apparently GHC for aarch64-musl has been working for a while now?!
Forgive the lack of styling, but here's cross-trunk filtered on "musl": https://hydra.nixos.org/jobset/nixpkgs/cross-trunk/jobs-tab?filter=musl
Where you can see 8.2.2 and HEAD are building!
A copy of "hello" built against musl for aarch64 can be obtained and inspected (it's a cross-trunk job) right now:
You can even run it with
qemu-aarch64
! 😁armv6l
Similarly:
/nix/store/83w221rd46wa08ik5gx7g8nw739rmflg-hello-1.0.0.2-armv6l-unknown-linux-musleabihf/bin/hello
is in the nix cache and seems to work viaqemu-arm
!x86_64
I believe I have a somewhat working version, currently iterating on cleanup and investigating/resolving some of the issues mentioned above. Not entirely sure I didn't manage to just build a broken glibc-based GHC though, haha, will report as I work on this further.
EDIT: Yep, works! Largest outstanding problem is that GHC doesn't treat this as a cross-compile, and so doesn't prefix tools. This is a problem because our plumbing expects tools to be prefixed if
host != target
. For now just punting and manually creating links to prefixed versions to get things going :).My dev branch (forgive any rebase/force-pushes please) is here: https://github.com/dtzWill/nixpkgs/tree/fix/ghc-cross-musl
EDIT2: https://github.com/dtzWill/nixpkgs/releases/tag/ghc-cross-musl-works works for x86_64? 😁
The text was updated successfully, but these errors were encountered: