-
-
Notifications
You must be signed in to change notification settings - Fork 15.3k
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 >= 9.6 TemplateHaskell doesn't work in pkgsStatic #275304
Comments
My suspicion here is that this is either a |
Of note: something assumes the existence of
however
Maybe someone has an idea where the dyn_hi load comes from. |
ping: @NixOS/static |
Good to know that the hadrian regression from #208959 has been fixed, so we can at least build GHC now. |
My diagnosis is the following:
I can fix that by just disabling haddock in the same way as we do for GHC < 9.6. I'll try doing that later. @bgamari @angerman The question is of course, and you can answer that better than me, has anything changed w.r.t. hadddock and cross with Hadrian? |
Thanks @sternenseemann! Your hypothesis does sound plausible. Recently we did rework Haddock to take documentation from Haskell interface ( |
Seems plausible. I'm personally not too fussed that this change means that haddock is not “retargetable”, i.e. you always need to use the precise haddock bundled with the GHC you are using to compile the documented code. In fact, we probably should explicitly tell Cabal which haddock to use, so this kind of issue doesn't happen or is easier to diagnose. I'll need to investigate, though, under which circumstances we can build haddock with hadrian now. |
The problems seems to be that the haddock package is only built using the stage1 compiler (so as part of stage2) which we necessarily never reach in the case of cross compilation. Presumably we can work around this in UserSettings somehow (although IME you are quite limited if your solution is to be maintainable), but I feel like this is a genuine gap and there ought to be a better way to build a cross-compiler with hadrian… |
I've just skimmed the code, but why do we do this:
what's the rational for adding I guess the proper thing here is to just disable haddocks for cross, and rely on native compilers haddocks. |
Do you mean the native compiler's |
In this situation, haddock would not be built by hadrian, as there is no stage0:exe:haddock target by default. (We should eventually try adding one.) If haddock is enabled and the build->host haddock missing, Cabal tries using the build->build haddock which may fail to load the documentation from the interface files produced by the build->host GHC (e.g. due to a mismatch between dynamic and static linking). Add regression tests to haskell-updates jobset. Resolves NixOS#275304.
This :D |
It's still broken: https://github.com/domenkozar/nixpkgs-static-repo |
Even easier reproducer:
|
That suggests that the GHC was not built as stage2 compiler, or some of the new cross target logic prohibits native codegen now as well. |
Agree with #275304 (comment);
produces the error. Additional example:
produces the error |
This issue has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/build-aarch64-docker-image-on-amd64-machine/55052/5 |
These also produce the error
9.8
|
@bgamari, can we change the title to "GHC 9.6, 9.8, 9.10 TemplateHaskell doesn't work in pkgsStatic, pkgsCross"? |
Namely: * Bump `ghc-wasm` flake to latest, which includes support for Template Haskell and macOS. Note that we now need to pass `-fno-external-interpreter` to GHC; this appears to be related to NixOS/nixpkgs#275304. * Run the Wasm build on macOS in CI, in addition to Linux. * Don't bother building Haddocks in the Wasm build. * Don't use `-fwrite-ide-info` in Wasm build. * `allow-newer` for `time` package. Signed-off-by: Drew Hess <src@drewhess.com>
|
@angerman I don't understand how this works on the haskell.nix side. Even if you manually force the build of iserv and install it, isn't ghc still built without |
Was this just as a reaction to #275304 (comment) or did you intentionally take 9.12 out of this, because it should do better? We currently still get the same error for
Thus, changing back to "GHC >= 9.6". If there is anything that was changed about this in 9.12, please let us know. |
@sternenseemann I'm a bit confused. GHC should always be able to accept |
So does that mean that the I've been able to clear up my question how haskell.nix achieves this since – it just disables the hadrian cross logic altogether. |
@sternenseemann yes, |
I made big progress with one observation: GHC thinks differently about "cross" than nixpkgs does. For nixpkgs, just flipping GHC only considers This can be observed in #383165. With this PR, it's possible to build ...
... just fine. This expression compiles from "musl, shared libs" to "musl, static libs", so is not considered cross by GHC. Thus hadrian builds iserv and the internal-interpreter and whatnot... Template Haskell compiles fine. Now, after fixing #383165, we have multiple options here:
|
@angerman Hm, but the $ /nix/store/dz660y60dym2rvg2d7zvbv2v1r3zpdvz-x86_64-unknown-linux-musl-ghc-native-bignum-9.8.4/bin/x86_64-unknown-linux-musl-ghc --info | grep interpreter
,("Use interpreter","YES")
,("Have interpreter","YES") This is the same as we'd have with GHC 9.4. IIUC, this error message is only generated if |
@sternenseemann are you sure ghc can find iserv? You can pass the full path to |
@angerman So I do need to build iserv? I guess I'll need to have another look at the logic for the make build system. I've noticed that for the static cross compiler (x86_64-unknown-linux -> x86_64-unknown-linux-musl), GHC used to build iserv and GHCi which it won't anymore. hadrian (at least for 9.8) will still set the internal-interpreter flag for the ghc package, but neglect to build iserv and ghci. Unfortunately, I haven't yet figured out how to get it to build them (even with patching hadrian itself). |
I was able to make it build those. Essentially it comes down to: Just tell hadrian that this is not a cross build and everything will fall into place. See last commit in #383165, that I just pushed. Still building for all the different versions, but I had a prototype build |
Hadrian needs to know whether the Stage1 compiler will be able to run on the build machine to determine which libs and tools to build. However, the naive approach of comparing host vs target triple is insufficient for nixpkgs. The most prominent case is pkgsStatic on Linux, where the triple differs because of a different libc (glibc -> musl). But of course, we can still run the Stage1 compiler very well. Thus, we just tell Hadrian that this case is *not* cross, by fixing up configure to always return "no" when asked about cross compilation. Resolves NixOS#275304
@wolfgangwalther Yes, that is essentially what haskell.nix does with a sledge hammer. I'm currently investigating whether we can possibly avoid this since it requires re-implementing parts of the cross logic ourselves or appeasing hadrian/autoconfs incorrect cross detection logic in cases like |
Ha. That's precisely what I do as well...
I don't think we can avoid cross logic entirely on our side. In fact, we have a lot of conditionals already. I think the approach currently taken in #383165 is possibly even cleaner: We always pass |
If you don't have an internal-interperter capable GHC, yes. GHC will not build iserv on its own on-demand. Although hat's something my team is looking at (no timeline or guaranteed outcome yet though). |
Describe the bug
Haskell packages in
nixpkgs.pkgsStatic.haskell.packages.ghc98
are unable to be built.Steps To Reproduce
Steps to reproduce the behavior:
nix build nixpkgs#legacyPackages.x86_64-linux.pkgsStatic.haskell.packages.ghc98.Diff
Expected behavior
Diff
is built, linking againstmusl
.Observed behavior
Additional context
The problem here appears to manifest during building of Haddock documentation. For instance,
Notify maintainers
@nh2
The text was updated successfully, but these errors were encountered: