Skip to content
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

fix(ghc): address cc-wrapper warning on darwin #391975

Draft
wants to merge 1 commit into
base: haskell-updates
Choose a base branch
from

Conversation

cassandracomar
Copy link

@cassandracomar cassandracomar commented Mar 21, 2025

on aarch64-darwin, ghc passes the target flag through as arm64-apple-darwin. this doesn't match the targetPlatform, so the check fails in cc-wrapper. the warning is spammy but of greater note is the indication in these PRs that this check should become a hard error as using cc-wrapper for a cross-compiler causes breakages.

see:

this check is likely to be made into a hard error at some point, so we should address it in the ghc build.

I've fixed this by having hadrian unconditionally set the target (addressing a TODO item in common-hadrian.nix) and modifying the name of the target in llvm-targets when building on aarch64-darwin. we already pass --target to configure if configurePlatforms includes target, so I've also ensured we set it there.

lastly, when useLLVM is set, we additionally need to make sure the LLVM target is configured or GHC ignores the target flags and passes the wrong target through anyway. so I've ensured we set the LlvmTarget and bootstrap_llvm_target configure variables.

this PR does not address the bindists. I don't know if the problem /can/ be solved there as GHC's configuration is set upstream for those -- setting bootPkgs to one of the bindists 1) produces the warning and 2) trying to add the same configuration settings for those compilers makes stage 0 compilation fail as the setting doesn't match the compiler's prebaked configuration. perhaps there's a way around this, I don't know.

I haven't tested yet on linux, will do as soon as I get a chance. I've also only tested this with 9.10.1. I'm not sure compiling literally every haskell package is feasible on my laptop but I will update as I get more tested. I'll switch this to "Ready for Review" when I feel I've tested as much as I can.

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 25.05 Release Notes (or backporting 24.11 and 25.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

on `aarch64-darwin`, ghc passes the target flag through as
`arm64-apple-darwin`. this doesn't match the hostPlatform, so the check
fails in cc-wrapper.

see:
- NixOS#379593
- NixOS#323869

this check is likely to be made into a hard error at some point, so we
should address it in the ghc build.

I've fixed this by having hadrian unconditionally set the
target (addressing a TODO item in `common-hadrian.nix`) and modifying
the name of the target in `llvm-targets` when building on
`aarch64-darwin`. we already pass `--target` to configure if
`configurePlatforms` includes `target`, so I've also ensured we set it
there.

lastly, when `useLLVM` is set, we additionally need to make sure the
LLVM target is configured or GHC ignores the target flags and passes the
wrong target through anyway. so I've ensured we set the `LlvmTarget` and
`bootstrap_llvm_target` configure variables.
@cassandracomar
Copy link
Author

oh, tangential note for anyone building ghc on darwin -- the compiler config in top-level/haskell-packages says the bindists don't work on darwin so it uses a nix-built compiler instead. but for getting up and running faster, I switched bootPkgs to the 9.6.3 bindist and it worked fine. whatever bug led to that choice has apparently been fixed upstream.

@wolfgangwalther
Copy link
Contributor

I've fixed this by having hadrian unconditionally set the target (addressing a TODO item in common-hadrian.nix)

I'm doing something related in 02662cb, which also leads to passing target unconditionally.

Have not tested your approach here, yet - just wanted to mention it for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants