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

haskell.compiler.ghc*: use matching CLANG & CC on Darwin with LLVM #338782

Conversation

sternenseemann
Copy link
Member

@sternenseemann sternenseemann commented Sep 1, 2024

The Darwin LLVM backend of GHC (which is mostly interesting for GHC < 9.2) uses clang as configured via the CLANG environment variable as an assembler. Since it processes outputs of clang as configured via the CC variable, we need to make sure these versions match or risk CLANG clang not understanding the output of CC clang.

In the past this wasn't really a problem as due to the fairly old default clang version in the stdenv, clang 11 would be used for CC. CLANG would always be a newer version and deal with the output without any problems.

Ever since the upgrade of the default clang version for darwin (bcbdb80), CC would often be a newer version of clang than CLANG, causing build problems in some packages like crypton (for GHC 8.10.7 and 9.0.2 on aarch64-darwin where the darwin LLVM backend was actually used).

Description of changes

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/)
  • 24.11 Release Notes (or backporting 23.11 and 24.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.

Add a 👍 reaction to pull requests you find important.

@ofborg ofborg bot added the 6.topic: darwin Running or building packages on Darwin label Sep 1, 2024
@sternenseemann
Copy link
Member Author

The current issue can be observed best when building

with import ./. { localSystem = "aarch64-darwin"; }; haskell.lib.compose.overrideCabal { configureFlags = [ "--ghc-option=-v3" ]; } haskell.packages.ghc8107.crypton

@ofborg ofborg bot added 11.by: package-maintainer This PR was created by the maintainer of the package it changes 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux labels Sep 1, 2024
@sternenseemann
Copy link
Member Author

Verified compilation of crypton with GHC 9.0.2 and 8.10.7. Note that the tests with 9.0.2 still fail due to kazu-yamamoto/crypton#35.

sternenseemann added a commit to sternenseemann/nixpkgs that referenced this pull request Sep 8, 2024
Note that the clang command should be adapted in the future as done for
CLANG in NixOS#338782.
sternenseemann added a commit that referenced this pull request Sep 8, 2024
Note that the clang command should be adapted in the future as done for
CLANG in #338782.
The Darwin LLVM backend of GHC (which is mostly interesting for
GHC < 9.2) uses clang as configured via the CLANG environment variable
as an assembler. Since it processes outputs of clang as configured via
the CC variable, we need to make sure these versions match or risk CLANG
clang not understanding the output of CC clang.

In the past this wasn't really a problem as due to the fairly old
default clang version in the stdenv, clang 11 would be used for CC.
CLANG would always be a newer version and deal with the output without
any problems.

Ever since the upgrade of the default clang version for
darwin (bcbdb80), CC would often be a
newer version of clang than CLANG, causing build problems in some
packages like crypton (for GHC 8.10.7 and 9.0.2 on aarch64-darwin where
the darwin LLVM backend was actually used).
@sternenseemann sternenseemann force-pushed the ghc-llvm-darwin-fix-clang-version branch from 04b3de4 to 19c88fb Compare September 8, 2024 21:57
@sternenseemann sternenseemann merged commit b039994 into NixOS:haskell-updates Sep 14, 2024
22 checks passed
@sternenseemann sternenseemann deleted the ghc-llvm-darwin-fix-clang-version branch September 14, 2024 15:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
6.topic: darwin Running or building packages on Darwin 6.topic: haskell 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux 11.by: package-maintainer This PR was created by the maintainer of the package it changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant