Skip to content

cc-wrapper: Workaround gnuabielfv{1,2} support deficiency on Clang#297425

Merged
flokli merged 1 commit intoNixOS:stagingfrom
OPNA2608:ppc64/clang-cc-wrapper
Jul 30, 2025
Merged

cc-wrapper: Workaround gnuabielfv{1,2} support deficiency on Clang#297425
flokli merged 1 commit intoNixOS:stagingfrom
OPNA2608:ppc64/clang-cc-wrapper

Conversation

@OPNA2608
Copy link
Contributor

@OPNA2608 OPNA2608 commented Mar 20, 2024

Description of changes

Clang doesn't parse the "gnuabielfv{1,2}" part of the triplet as anything beyond "gnu", so desired ABI gets ignored.

Work around this by explicitly setting the ABI.


Follow-up to #307819 which fixes building LLVM on powerpc64, this gets llvmPackages*.stdenv working.

  • I haven't checked how this may affect musl, and
  • I'm not sure if checking for non-"gnu" has any point beyond signaling intention, because we assert on powerpc64{,le}-unknown-linux-gnu due to this exact ABI ambiguity. Maybe checking for non-"musl" would be better, since that only supports ELFv2?

Staging just so cc-wrapper stuff that might get sent there doesn't encounter any merge conflicts.

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • powerpc64-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.05 Release Notes (or backporting 23.05 and 23.11 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 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 Mar 20, 2024
@OPNA2608 OPNA2608 force-pushed the ppc64/clang-cc-wrapper branch from 44eef7e to 22af3bf Compare March 20, 2024 13:18
@OPNA2608 OPNA2608 changed the title cc-wrapper: Workaround gnuelfabiv{1,2} support deficiency on Clang cc-wrapper: Workaround gnuabielfv{1,2} support deficiency on Clang Mar 20, 2024
@rrbutani rrbutani added 6.topic: llvm/clang Issues related to llvmPackages, clangStdenv and related 6.topic: stdenv Standard environment labels May 27, 2024
@wegank wegank added the 2.status: merge conflict This PR has merge conflicts with the target branch label Jul 6, 2024
@OPNA2608 OPNA2608 force-pushed the ppc64/clang-cc-wrapper branch from 22af3bf to c0e35c1 Compare August 9, 2024 14:23
@OPNA2608 OPNA2608 changed the base branch from master to staging August 9, 2024 14:24
@github-actions github-actions bot removed 6.topic: stdenv Standard environment 6.topic: llvm/clang Issues related to llvmPackages, clangStdenv and related labels Aug 9, 2024
@ofborg ofborg bot removed the 2.status: merge conflict This PR has merge conflicts with the target branch label Aug 9, 2024
@OPNA2608 OPNA2608 marked this pull request as ready for review August 9, 2024 15:47
@OPNA2608 OPNA2608 requested a review from Ericson2314 as a code owner August 9, 2024 15:47
@FliegendeWurst FliegendeWurst added the 6.topic: exotic Exotic hardware or software platform label Dec 4, 2024
Copy link
Member

@FliegendeWurst FliegendeWurst left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems reasonable

@wegank wegank added the 12.approvals: 1 This PR was reviewed and approved by one person. label Dec 4, 2024
@wegank wegank added the 2.status: merge conflict This PR has merge conflicts with the target branch label Apr 7, 2025
@nixpkgs-ci nixpkgs-ci bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jun 25, 2025
@OPNA2608 OPNA2608 force-pushed the ppc64/clang-cc-wrapper branch from c0e35c1 to 9d8274f Compare July 20, 2025 13:19
@OPNA2608
Copy link
Contributor Author

Reviving this, as it is still necessary for both ABI versions.

Support for understanding such triplets in Clang has since gotten worse:

puna@HC /d/shm> /nix/store/igsdrfi994cn9bhrw1vhpwminw3la8ri-clang-wrapper-19.1.7/bin/clang -target powerpc64-unknown-linux-gnuabielfv1 -mabi=elfv1 bla.c -o bla
clang: error: version 'abielfv1' in target triple 'powerpc64-unknown-linux-gnuabielfv1' is invalid

So in addition to passing the ABI via -mabi, we need to simplify gnuabielfv* in the target triplet to just gnu.

@nixpkgs-ci nixpkgs-ci bot added 10.rebuild-linux: 501+ This PR causes many rebuilds on Linux and should normally target the staging branches. 10.rebuild-darwin: 501+ This PR causes many rebuilds on Darwin and should normally target the staging branches. 10.rebuild-darwin-stdenv This PR causes stdenv to rebuild on Darwin and must target a staging branch. 10.rebuild-darwin: 5001+ This PR causes many rebuilds on Darwin and must target the staging branches. 10.rebuild-linux: 5001+ This PR causes many rebuilds on Linux and must target the staging branches. and removed 2.status: merge conflict This PR has merge conflicts with the target branch 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md 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 Jul 20, 2025
Clang cannot handle the gnuabielfv{1,2} ABI specification in the triplet properly. It used to parse it as just "gnu", disregarding the ABI version in it and defaulting to ELFv1. Now, it completely fails to parse such target triplet:

> clang: error: version 'abielfv1' in target triple 'powerpc64-unknown-linux-gnuabielfv1' is invalid

So when it comes time to passing the target triplet to Clang, handle this support deficiency:

1. If the triplet ends in gnuabielfv*, shorten it to just gnu. This makes it get parsed properly.
2. After the above, re-add the ABI via the separate -mabi option. This makes it use the correct ABI for the platform.
@OPNA2608 OPNA2608 force-pushed the ppc64/clang-cc-wrapper branch from 9d8274f to 07bce58 Compare July 21, 2025 12:07
@nixpkgs-ci nixpkgs-ci bot added 12.approvals: 2 This PR was reviewed and approved by two persons. 12.approved-by: package-maintainer This PR was reviewed and approved by a maintainer listed in any of the changed packages. and removed 12.approvals: 1 This PR was reviewed and approved by one person. labels Jul 21, 2025
@flokli flokli merged commit b7f958d into NixOS:staging Jul 30, 2025
28 of 29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.topic: exotic Exotic hardware or software platform 10.rebuild-darwin: 501+ This PR causes many rebuilds on Darwin and should normally target the staging branches. 10.rebuild-darwin: 5001+ This PR causes many rebuilds on Darwin and must target the staging branches. 10.rebuild-darwin-stdenv This PR causes stdenv to rebuild on Darwin and must target a staging branch. 10.rebuild-linux: 501+ This PR causes many rebuilds on Linux and should normally target the staging branches. 10.rebuild-linux: 5001+ This PR causes many rebuilds on Linux and must target the staging branches. 12.approvals: 2 This PR was reviewed and approved by two persons. 12.approved-by: package-maintainer This PR was reviewed and approved by a maintainer listed in any of the changed packages.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants