Skip to content

llvmPackages_{22,23,git}.compiler-rt: fix no-libc build on aarch64-linux - #566346

Merged
whispersofthedawn merged 1 commit into
NixOS:masterfrom
randomizedcoder:llvm22-compiler-rt-aarch64-nolibc
Oct 4, 2026
Merged

whispersofthedawn merged 1 commit into
NixOS:masterfrom
randomizedcoder:llvm22-compiler-rt-aarch64-nolibc

Conversation

@randomizedcoder

@randomizedcoder randomizedcoder commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

llvmPackages_22.compiler-rt-no-libc does not build on aarch64-linux, which takes llvmPackages_22.libcxx, libcxxClang and clangUseLLVM down with it (same for llvmPackages_23 and llvmPackages_git). Hydra has no aarch64-linux build of any of those jobs, while the llvmPackages_21 ones build.

Cause: llvm/llvm-project#161751 (in 22.1.0 and later) removed the __has_include(<sys/auxv.h>) guards from the AArch64 LSE-atomics and FMV feature detection in compiler-rt/lib/builtins/cpu_model/aarch64.c. The no-libc variant has no libc headers, so the file fails with

compiler-rt/lib/builtins/cpu_model/aarch64.c:51:10: fatal error: 'sys/auxv.h' file not found

Fix: in the existing !haveLibc block of compiler-rt/default.nix, restore the guards with a substituteInPlace, gated on Linux, aarch64 and LLVM >= 22. (The Linux part matters: Darwin builds compiler-rt-no-libc without a libc as well, and without it every llvmPackages_{22,23} derivation on aarch64-darwin would rebuild for no effect, which is what the first eval of this PR showed.) That gives the LLVM 21 behaviour back: LSE detection is skipped and __aarch64_have_lse_atomics stays false when there is no libc. The FMV branch is already compiled out in this configuration by COMPILER_RT_DISABLE_AARCH64_FMV (ded560c, same block, same gate). The substituted line is identical in 22.1.8, 23.1.0 and the git snapshot (two occurrences each), so --replace-fail covers all three.

Only compiler-rt-no-libc and what is built on top of it change, and only on aarch64-linux. Checked with nix-instantiate against master for LLVM 21, 22, 23 and git: compiler-rt-libc, clang, libllvm, lld and the stdenv keep their derivations; nothing changes on x86_64-linux or on aarch64-darwin.

Fixes #495155. Upstream context: llvm/llvm-project#127227 (acyclic compiler-rt/libc bootstrap) and llvm/llvm-project#152394 (proposed no-libc-headers build mode, still open); until something like that lands, restoring the LLVM 21 guard is the smallest change that keeps the no-libc build working.

Context: this came out of packaging redpanda-server, which is built with llvmPackages_22.libcxxClang; with this fix it builds and passes its NixOS test natively on aarch64-linux.

Things done

  • Built on platform:
    • x86_64-linux (no derivation changes; nixpkgs-review reports nothing to rebuild)
    • aarch64-linux (Raspberry Pi 5): llvmPackages_22.compiler-rt-no-libc, llvmPackages_22.libcxx, llvmPackages_23.compiler-rt-no-libc, llvmPackages_23.libcxx build; without the change llvmPackages_23.compiler-rt-no-libc fails with the error above. A full application (redpanda-server, libc++ 22, ~8,600 Bazel actions) builds against the result and passes its NixOS VM test.
    • aarch64-darwin (not affected: the change is gated on isLinux; eval shows no darwin rebuilds)
  • Tested, as applicable:
  • Ran nixpkgs-review on this PR. See nixpkgs-review usage. (x86_64-linux: nothing to rebuild.)
  • Tested basic functionality of all binary files, usually in ./result/bin/. (No binaries; the resulting libc++ links and runs redpanda-server.)
  • Nixpkgs Release Notes
    • Package update: when the change is major or breaking.
  • NixOS Release Notes
    • Module addition: when adding a new NixOS module.
    • Module update: when the change is significant.
  • Fits CONTRIBUTING.md, pkgs/README.md, maintainers/README.md and other READMEs. (treefmt --ci and ./ci/nixpkgs-vet.sh master clean.)
  • Follows the automation/AI policy. Written with Claude Code (Claude Fable 5.1), Assisted-by: trailer on the commit; this description was drafted the same way. The author reviewed the change and ran the builds above.

🤖 Generated with Claude Code

@nixpkgs-ci
nixpkgs-ci Bot requested review from a team and andir and removed request for a team September 23, 2026 23:00
@nixpkgs-ci nixpkgs-ci Bot added 10.rebuild-linux: 11-100 This PR causes between 11 and 100 packages to rebuild on Linux. 10.rebuild-darwin: 11-100 This PR causes between 11 and 100 packages to rebuild on Darwin. llm-assisted Contributions that include code generation with LLMs 6.topic: llvm/clang Issues related to llvmPackages, clangStdenv and related labels Sep 23, 2026
@nixpkgs-ci
nixpkgs-ci Bot requested a review from a team September 23, 2026 23:01
@peterwaller-arm

Copy link
Copy Markdown
Member

See also: llvm/llvm-project#127227 for upstream related discussion about how to resolve this.
Related nixpkgs issues: #495155 #380604

--replace-fail "#include <stdlib.h>" ""
''
+
lib.optionalString (stdenv.hostPlatform.isAarch64 && lib.versionAtLeast release_version "22")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

PR says:

Only compiler-rt-no-libc and what is built on top of it change

... but this doesn't have a condition for compiler-rt-no-libc; is there an opportunity to confine the drv change so that compiler-rt-libc stays unmodified?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It is confined already, just not visibly from the diff context: the new lib.optionalString is nested inside the existing lib.optionalString (!haveLibc) ( … ) block that starts a few lines above (the one with the int_util.c substitution), so compiler-rt-libc never runs it. On aarch64-linux the llvmPackages_22.compiler-rt-libc derivation is byte-identical before and after this PR (nix-instantiate gives the same .drv for master, the original commit and the current one); the eval's aarch64-linux rebuild list contains only the no-libc side (compiler-rt-no-libc, libcxx, libunwind, the clangNoLibc*/clangUseLLVM/libcxxClang wrappers and their tests).

What the eval did flag, and what I had wrong in the description, is aarch64-darwin: Darwin builds compiler-rt-no-libc with overrideCC darwin.bootstrapStdenv clangNoLibcNoRt, so haveLibc is false there as well and the substitution ran on Darwin too. It is a no-op on Apple (the file's #elif defined(__linux__) branches are never selected there), but it changed the no-libc derivation, and compiler-rt-libc on Darwin changed transitively because its build compiler (clangWithLibcAndBasicRtAndLibcxx) carries that runtime. I have pushed a version that also gates on stdenv.hostPlatform.isLinux: on aarch64-darwin every llvmPackages_{22,23} derivation is now identical to master, and on aarch64-linux the derivations are identical to the first push, so the builds I did on the Pi still cover exactly this change.

Thanks for the links, and apologies for not searching the issue tracker before opening this: #495155 is this same failure and I should have found and referenced it. I have added "Fixes #495155" and the llvm/llvm-project#127227 context to the description. Until a no-libc-headers build mode exists upstream (llvm/llvm-project#152394 is still open), restoring the LLVM 21 __has_include guard seemed the smallest thing that keeps the no-libc build going.

(Reply drafted with Claude Code, Claude Fable 5.1, and reviewed by me; the derivation comparisons were run by hand with nix-instantiate.)

LLVM 22 dropped the `__has_include(<sys/auxv.h>)` guards from the
AArch64 LSE-atomics and FMV feature detection in compiler-rt's builtins
(llvm/llvm-project#161751, released in 22.1.0). The no-libc variant of
compiler-rt, which libcxx and the libc++ clang wrappers are built with,
has no libc headers, so lib/builtins/cpu_model/aarch64.c fails with

    fatal error: 'sys/auxv.h' file not found

and llvmPackages_22.{compiler-rt-no-libc,libcxx,libcxxClang,clangUseLLVM}
cannot be built on aarch64-linux; the same holds for llvmPackages_23 and
llvmPackages_git. Hydra has no aarch64-linux build of any of these jobs,
while the llvmPackages_21 ones build.

Restore the LLVM 21 behaviour for the no-libc build: guard both
`#elif defined(__linux__)` branches with `__has_include(<sys/auxv.h>)`,
so LSE detection is skipped and __aarch64_have_lse_atomics stays false
without a libc, as it did in 21. The FMV branch is already compiled out
in this configuration by COMPILER_RT_DISABLE_AARCH64_FMV (ded560c).
The substitution applies unchanged to 22.1.8, 23.1.0 and the git
snapshot.

Only compiler-rt-no-libc and what is built on top of it change, and only
on aarch64-linux: compiler-rt (with libc), clang, libllvm, lld and the
stdenv keep their derivations, and nothing changes on x86_64-linux. The
gate includes isLinux because Darwin builds compiler-rt-no-libc without
a libc as well but never takes the __linux__ branches; without it every
llvmPackages_{22,23} derivation on aarch64-darwin would rebuild for no
effect.

Fixes NixOS#495155.

Assisted-by: Claude Code (Claude Fable 5.1)
@randomizedcoder
randomizedcoder force-pushed the llvm22-compiler-rt-aarch64-nolibc branch from 284858a to 8c59070 Compare September 24, 2026 19:19
@nixpkgs-ci nixpkgs-ci Bot added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. and removed 10.rebuild-darwin: 11-100 This PR causes between 11 and 100 packages to rebuild on Darwin. labels Sep 24, 2026

@peterwaller-arm peterwaller-arm left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@RossComputerGuy @Ericson2314 - any thoughts? I think this looks an acceptable workaround for now until we can get LLVM rewired as needed. I don't think it puts nixpkgs in a worse position than it is already in.

@nixpkgs-ci nixpkgs-ci Bot added 12.approvals: 1 This PR was reviewed and approved by one person. 12.approved-by: package-maintainer This PR was reviewed and approved by a maintainer listed in any of the changed packages. labels Sep 24, 2026
@ArtifyCZ

Copy link
Copy Markdown
Member

These packages have never been built successfully on aarch64-linux, and I am linking the tracking issue for such packages.

@peterwaller-arm peterwaller-arm left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hopefully we can fix upstream one day. But this seems like an acceptable workaround for the time being.

@whispersofthedawn whispersofthedawn added the backport release-26.05 Backport PR automatically label Oct 4, 2026

@whispersofthedawn whispersofthedawn left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

seems reasonable. though it would indeed be nicer to have this fixed upstream, this seems like a straightforward enough patch. built llvmPackages_22.compiler-rt-no-libc and llvmPackages_23.compiler-rt-no-libc on aarch64-linux to test this, with no issues.

nixpkgs-review result

Generated using nixpkgs-review.

Command: nixpkgs-review pr 566346
Commit: 8c59070cfe9e4b4c6c96747d376fd286b4e6751a


aarch64-linux

❌ 1 package failed to build:
  • tests.cc-wrapper.supported
✅ 21 packages built:
  • llvmPackages_22.clangNoLibc (llvmPackages_22.clangNoLibcWithBasicRt)
  • llvmPackages_22.clangNoLibcxx (llvmPackages_22.clangWithLibcAndBasicRt)
  • llvmPackages_22.compiler-rt-no-libc
  • llvmPackages_22.libcxx
  • llvmPackages_22.libcxxClang
  • llvmPackages_22.clangUseLLVM
  • llvmPackages_22.libunwind
  • llvmPackages_22.clangWithLibcAndBasicRtAndLibcxx
  • llvmPackages_22.libcxxStdenv
  • llvmPackages_23.clangNoLibcxx (llvmPackages_23.clangWithLibcAndBasicRt)
  • llvmPackages_23.clangNoLibc (llvmPackages_23.clangNoLibcWithBasicRt)
  • llvmPackages_23.compiler-rt-no-libc
  • llvmPackages_23.libcxx
  • llvmPackages_23.libcxxClang
  • llvmPackages_23.clangUseLLVM
  • llvmPackages_23.libunwind
  • llvmPackages_23.libcxxStdenv
  • llvmPackages_23.clangWithLibcAndBasicRtAndLibcxx
  • rocmPackages.llvm.libcxx
  • tests.cc-wrapper.llvmTests.llvmPackages_22.libcxx
  • tests.cc-wrapper.llvmTests.llvmPackages_23.libcxx

@nixpkgs-ci nixpkgs-ci Bot added 12.approvals: 2 This PR was reviewed and approved by two persons. and removed 12.approvals: 1 This PR was reviewed and approved by one person. labels Oct 4, 2026
@whispersofthedawn
whispersofthedawn added this pull request to the merge queue Oct 4, 2026
Merged via the queue into NixOS:master with commit 8addc2a Oct 4, 2026
40 of 42 checks passed
@nixpkgs-ci

nixpkgs-ci Bot commented Oct 4, 2026

Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot added the 8.has: port to stable This PR already has a backport to the stable release. label Oct 4, 2026
randomizedcoder added a commit to randomizedcoder/nixpkgs that referenced this pull request Oct 10, 2026
The package already carries the aarch64-linux repository cache hash and
was verified natively on a Raspberry Pi 5 (5 h 46 min on 4 cores, 306
MiB closure, NixOS test passing). meta.platforms listed only
x86_64-linux because llvmPackages_22.compiler-rt-no-libc did not build
on aarch64-linux.

That blocker is gone: the fix landed in 8addc2a
(llvmPackages_{22,23,git}.compiler-rt: fix no-libc build on
aarch64-linux, NixOS#566346).

Assisted-by: Claude Code (Claude Opus 5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.topic: llvm/clang Issues related to llvmPackages, clangStdenv and related 8.has: port to stable This PR already has a backport to the stable release. 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 11-100 This PR causes between 11 and 100 packages to rebuild on Linux. 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. backport release-26.05 Backport PR automatically llm-assisted Contributions that include code generation with LLMs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

llvmPackages_22: CompilerRT-nolibc requires sys/auxv.h on linux_aarch64

4 participants