Skip to content

llvmPackages_{20,21,git}.compiler-rt: no fmv on aarch64 without libc #409265

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

RossComputerGuy
Copy link
Member

…patch

Things done

Fixes #393603
Reverts #380213
Required for #407738

We're sending this patch to master and backporting it so pkgsLLVM actually works correctly with LLVM 20 and git.

  • 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/)
  • Nixpkgs 25.11 Release Notes (or backporting 24.11 and 25.05 Nixpkgs Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
  • NixOS 25.11 Release Notes (or backporting 24.11 and 25.05 NixOS Release notes)
    • (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.

@RossComputerGuy RossComputerGuy added the backport release-25.05 Backport PR automatically label May 21, 2025
@github-actions github-actions bot added the 6.topic: llvm/clang Issues related to llvmPackages, clangStdenv and related label May 21, 2025
@github-actions github-actions bot added 10.rebuild-darwin: 11-100 This PR causes between 11 and 100 packages to rebuild on Darwin. 10.rebuild-linux: 11-100 This PR causes between 11 and 100 packages to rebuild on Linux. 11.by: package-maintainer This PR was created by a maintainer of all the package it changes. labels May 21, 2025
@alyssais
Copy link
Member

Upstream?

@RossComputerGuy
Copy link
Member Author

Already tried going upstream but the PR was closed llvm/llvm-project#125922

@alyssais
Copy link
Member

Hmm, unfortunate…

@Ericson2314 what do you think about applying this? Seems a real shame to be adding a new LLVM patch.

@peterwaller-arm
Copy link
Contributor

peterwaller-arm commented Jul 15, 2025

@Ericson2314 just published a blog post adjacent to this: https://blog.obsidian.systems/compiler-bootstrapping-in-nixpkgs/

As patch author, my opinion is that given the timescales involved for a proper fix (e.g. llvm/llvm-project#127227), it would be good to unbreak this today in nixpkgs.

@RossComputerGuy
Copy link
Member Author

timescales involved for a proper fix (e.g. #127227)

Wrong issue linked?

@peterwaller-arm
Copy link
Contributor

Wrong issue linked?

Right issue number, wrong repo. Fixed.

@Artturin Artturin closed this Jul 28, 2025
@Artturin Artturin reopened this Jul 28, 2025
@nixpkgs-ci nixpkgs-ci bot added 10.rebuild-linux: 101-500 This PR causes between 101 and 500 packages to rebuild on Linux. and removed 10.rebuild-linux: 11-100 This PR causes between 11 and 100 packages to rebuild on Linux. labels Jul 28, 2025
@Ericson2314
Copy link
Member

Can we make the patch less linux-specific? Conceptually, we're talking about about generally building a "freestanding" compiler-rt on a non-freestanding platform, of which Linux is merely one example.

@peterwaller-arm
Copy link
Contributor

Can we make the patch less linux-specific? Conceptually, we're talking about about generally building a "freestanding" compiler-rt on a non-freestanding platform, of which Linux is merely one example.

https://github.com/llvm/llvm-project/blob/0c0aa56cdcf1fe3970a5f3875db412530512fc07/compiler-rt/lib/builtins/CMakeLists.txt#L884

It looks like setting COMPILER_RT_DISABLE_AARCH64_FMV is a better non-linux specific way forward here.

@RossComputerGuy RossComputerGuy mentioned this pull request Jul 31, 2025
13 tasks
@RossComputerGuy RossComputerGuy force-pushed the fix/pkgsllvm/stdenv branch 2 times, most recently from 8e018d7 to 31c3a2e Compare July 31, 2025 16:26
@RossComputerGuy
Copy link
Member Author

It looks like setting COMPILER_RT_DISABLE_AARCH64_FMV is a better non-linux specific way forward here.

Done and I've verified this to work correctly, it was blocking me for testing #429745 & #402198 since compiler-rt was failing. This should be gtg now, I'll merge once this gets approved.

@RossComputerGuy RossComputerGuy changed the title llvmPackages_{20,git}.compiler-rt: unbreak by readding the libc-free … llvmPackages_{20,21,git}.compiler-rt: disable fmv on aarch64 Jul 31, 2025
@nixpkgs-ci nixpkgs-ci bot added 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 1 This PR causes 1 package to rebuild on Linux. and removed 10.rebuild-linux: 101-500 This PR causes between 101 and 500 packages to rebuild on Linux. 10.rebuild-darwin: 11-100 This PR causes between 11 and 100 packages to rebuild on Darwin. 11.by: package-maintainer This PR was created by a maintainer of all the package it changes. labels Jul 31, 2025
@peterwaller-arm
Copy link
Contributor

The commit message and conditioning aren't quite right.

We want FMV (Function MultiVersioning) to work on aarch64. Where it doesn't work is in the no-libc compiler-rt, where linux features are unavailable. The original patch meant that the linux build of compiler-rt does have FMV switched on; only if linux was not defined (for a freestanding build) then it would it be turned off.

For a bit of background, FMV is machinery which enables having multiple versions of functions targeting different architectural features, and to have the best version selected at runtime. But to do this it needs libc available so it can interrogate the kernel to discover which features are available.

The problem is that we're trying to build a compiler-rt without libc available, so we need to condition on this -- it should only apply for compiler-rt-no-libc. compiler-rt-libc can leave FMV in tact.

@Ericson2314
Copy link
Member

(Also btw @RossComputerGuy, we'll need to introduce a second GCC NG libgcc build to match LLVM for similar reasons.)

aarch64 FMV (Function MultiVersioning) is not available before the libc
is available. This causes issues while building with compiler-rt on
aarch64. By disabling FMV before the libc is available resolves missing
symbol errors.
@RossComputerGuy RossComputerGuy changed the title llvmPackages_{20,21,git}.compiler-rt: disable fmv on aarch64 llvmPackages_{20,21,git}.compiler-rt: no fmv on aarch64 without libc Aug 15, 2025
@RossComputerGuy
Copy link
Member Author

@peterwaller-arm Thanks for the explanation, I've updated things and this should be gtg now.

@@ -244,6 +244,10 @@ stdenv.mkDerivation (finalAttrs: {
++ lib.optionals (noSanitizers && lib.versionAtLeast release_version "19") [
(lib.cmakeBool "COMPILER_RT_BUILD_CTX_PROFILE" false)
]
++
lib.optional (useLLVM && stdenv.hostPlatform.isAarch64 && !haveLibc)
Copy link
Member

Choose a reason for hiding this comment

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

Based on the explanation in the commit message, wouldn't this also be required for !useLLVM?

Copy link
Member Author

Choose a reason for hiding this comment

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

No because the error only pops ups with pkgsLLVM.

Copy link
Member

Choose a reason for hiding this comment

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

So how does it work in the non-pkgsLLVM case?

Copy link
Member Author

Choose a reason for hiding this comment

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

My guess is that it's using something from GCC so the symbol isn't missing.

Copy link
Member

Choose a reason for hiding this comment

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

@peterwaller-arm do you know?

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 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. 10.rebuild-linux: 1 This PR causes 1 package to rebuild on Linux. backport release-25.05 Backport PR automatically
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Build failure: libcxx with LLVM+LLD on aarch64-linux
5 participants