Repository navigation
llvmPackages_{22,23,git}.compiler-rt: fix no-libc build on aarch64-linux - #566346
whispersofthedawn merged 1 commit into
Conversation
|
See also: llvm/llvm-project#127227 for upstream related discussion about how to resolve this. |
| --replace-fail "#include <stdlib.h>" "" | ||
| '' | ||
| + | ||
| lib.optionalString (stdenv.hostPlatform.isAarch64 && lib.versionAtLeast release_version "22") |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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)
284858a to
8c59070
Compare
peterwaller-arm
left a comment
There was a problem hiding this comment.
@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.
|
These packages have never been built successfully on |
peterwaller-arm
left a comment
There was a problem hiding this comment.
Hopefully we can fix upstream one day. But this seems like an acceptable workaround for the time being.
There was a problem hiding this comment.
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
|
Successfully created backport PR for |
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)
llvmPackages_22.compiler-rt-no-libcdoes not build on aarch64-linux, which takesllvmPackages_22.libcxx,libcxxClangandclangUseLLVMdown with it (same forllvmPackages_23andllvmPackages_git). Hydra has no aarch64-linux build of any of those jobs, while thellvmPackages_21ones 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 incompiler-rt/lib/builtins/cpu_model/aarch64.c. The no-libc variant has no libc headers, so the file fails withFix: in the existing
!haveLibcblock ofcompiler-rt/default.nix, restore the guards with asubstituteInPlace, gated on Linux, aarch64 and LLVM >= 22. (The Linux part matters: Darwin buildscompiler-rt-no-libcwithout a libc as well, and without it everyllvmPackages_{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_atomicsstays false when there is no libc. The FMV branch is already compiled out in this configuration byCOMPILER_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-failcovers all three.Only
compiler-rt-no-libcand what is built on top of it change, and only on aarch64-linux. Checked withnix-instantiateagainst master for LLVM 21, 22, 23 and git:compiler-rt-libc,clang,libllvm,lldand 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 withllvmPackages_22.libcxxClang; with this fix it builds and passes its NixOS test natively on aarch64-linux.Things done
nixpkgs-reviewreports nothing to rebuild)llvmPackages_22.compiler-rt-no-libc,llvmPackages_22.libcxx,llvmPackages_23.compiler-rt-no-libc,llvmPackages_23.libcxxbuild; without the changellvmPackages_23.compiler-rt-no-libcfails 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.isLinux; eval shows no darwin rebuilds)nixosTests.redpanda-server(from the companion PR) on aarch64-linux against a libc++ 22 built with this change.passthru.tests.nixpkgs-reviewon this PR. See nixpkgs-review usage. (x86_64-linux: nothing to rebuild.)./result/bin/. (No binaries; the resulting libc++ links and runsredpanda-server.)treefmt --ciand./ci/nixpkgs-vet.sh masterclean.)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