Skip to content

[LLVM_full] Restore compiler-rt on AArch64 and ARM for LLVM 22/23 - #14805

Merged
maleadt merged 4 commits into
masterfrom
tb/clang-compiler-rt-aarch64
Sep 16, 2026
Merged

maleadt merged 4 commits into
masterfrom
tb/clang-compiler-rt-aarch64

Conversation

@maleadt

@maleadt maleadt commented Sep 15, 2026

Copy link
Copy Markdown
Member

LLVM_full 22 and 23 can finish building successfully while installing no
compiler-rt libraries on AArch64 and 32-bit ARM. This leaves the extracted
Clang_jll without compiler builtins or the profile runtime needed to link code
compiled with -fprofile-generate.

compiler-rt detects supported architectures by compiling small test programs.
Its ARM probes pass -march, which BinaryBuilder's compiler wrapper rejects
because it controls the target architecture itself. The failed probes remove the
architecture from the runtime build, but do not fail the overall LLVM build.

This extends the diagnosis and AArch64 fix in
JuliaPackaging/Yggdrasil#12953
to LLVM 22 and 23, with these changes:

  • Remove -march=armv8-a from the AArch64 and aarch32 probes.
  • Fix the separate arm probe used by armv6l and armv7l. Probe armhf using
    the wrapper's defaults: these BinaryBuilder targets use the hard-float ABI,
    and the wrapper selects the correct CPU. This also avoids imposing ARMv7
    instructions on ARMv6 builds. Changing only the aarch32 probe does not fix
    these targets.
  • Omit the emulated pointer-authentication builtins (emupac.cpp) when building
    with GCC. Once AArch64 runtimes are enabled, the bundled GNU assembler rejects
    that file's PAC instructions. Clang builds retain these builtins. GCC-built
    artifacts consequently do not support the emulated-PAC helpers.
  • After installation, require a libclang_rt.profile*.a archive in the current
    LLVM major's resource directory on Linux and MinGW. A failed probe will now
    fail the build instead of producing an artifact without runtimes. The check
    applies to LLVM 22 onward; older recipes and macOS are outside its scope. A
    separable third commit extends the same check to FreeBSD, since AArch64 FreeBSD
    is one of the platforms restored here and installs the archive under
    lib/clang/<major>/lib/freebsd/.

Build triggers are bumped for both LLVM_full and LLVM_full_assert at 22 and 23.
The assert recipes share the patches through symlinks and need their own trigger.
The probe fix and assembler workaround are kept in one commit because enabling
AArch64 runtimes requires both. A second commit adds the installation check, and a
third extends it to FreeBSD; that third commit is independent and can be dropped.

Validation

Three full LLVM_full@22 builds against the final branch, in the BinaryBuilder
sandbox, roughly 25-30 minutes each:

target result
aarch64-linux-gnu complete; 58 compiler-rt entries in the tarball, incl. libclang_rt.profile-aarch64.a. Tree hash identical to the pre-review build, so the revisions are behaviour-preserving here
armv7l-linux-gnueabihf complete; 33 entries, incl. libclang_rt.profile-armhf.a. This is the target the revised arm probe fixes
aarch64-unknown-freebsd complete; 34 entries, incl. libclang_rt.profile-aarch64.a, with emupac.cpp compiled by Clang 18 and libclang_rt.builtins-aarch64.a produced

Every released artifact for those three platforms contains zero compiler-rt
files today. -- Compiler-RT supported architectures: reports aarch64 / armhf
where it is empty without the patches, which is the bug in a single line. The
post-install check passed on all three.

Also verified:

  • Both patches apply to the pinned julia-22.1.8-1 and julia-23.1.1-1 sources at
    exact offsets with no fuzz (patch --dry-run, then three real builds). The 23 pin
    has since moved to fbe0dc11 ([LLVM_full] Rebuild v23.1.1 with AArch64 load latency fix #14797); its two extra commits touch only llvm/,
    not compiler-rt.
  • The GCC-only PAC condition behaves as intended on both sides: GCC targets drop
    the file (their GNU as is 2.34, which rejects xpaclri, .arch_extension pauth
    and pacda), while FreeBSD, which builds with Clang 18, keeps and compiles it.
  • memprof and contextual profiling are x86_64-only in both pinned sources, and the
    AArch64 build installs neither, so [LLVM_full] Don't set -march in cmake tests for compiler-rt targets #12953's musl hunk is unnecessary here.

Not built: aarch64-linux-musl, armv6l, the ARM musl variants, and all of
LLVM 23. #12953's CI is green for the equivalent change on LLVM 20/21 across all of
those platforms, and the LLVM 23 patches were confirmed to apply. CI still needs to
cover them here.

Once this registers as 22.1.8+2 / 23.1.1+2, Clang_jll gets re-extracted from it
against the existing libLLVM_jll +1 (only Clang ships the compiler-rt archives;
the other extraction packages are unaffected).

BinaryBuilder rejects the -march flags in compiler-rt's architecture probes.
The failed probes silently remove ARM architectures from the runtime build,
leaving Clang without builtins or the library needed by -fprofile-generate.

Extend the AArch64/aarch32 probe fix from Yggdrasil#12953 to LLVM 22 and 23.
Also fix the separate arm probe used by armv6l and armv7l: select armhf with
the wrapper's default flags, preserving the target's CPU and hard-float ABI.

Once AArch64 runtimes are enabled, emupac.cpp fails with the bundled GNU
assembler. Omit it for GCC builds while retaining it for Clang builds.
Keep this workaround with the probe fix so enabling the runtimes does not
introduce an intermediate assembler failure.

Bump build triggers for both regular and assert recipes; the latter share
the patches through bundled symlinks.

Validation: patches apply without fuzz or offsets to both pinned sources;
CMake checks cover the four ARM probe paths and GCC/Clang/MSVC PAC selection.
The previous full LLVM 22 aarch64-linux-gnu build validates the unchanged
AArch64 probe and GCC source selection. Other targets still need CI.
A failed architecture probe can disable every compiler-rt runtime without
failing CMake or Ninja. After installation, require a profile archive in
the current LLVM major's resource directory on Linux and MinGW.

Apply the check to LLVM 22 onward, where this branch adds the probe fix,
so older recipes do not acquire a new failure on rebuild. The archive glob
matches the layout selected by LLVM_ENABLE_PER_TARGET_RUNTIME_DIR=OFF.

Validation: bash -n on the build script, ShellCheck on the guard with its
external variables declared, and ten shell cases covering missing/present
archives, version/platform gating, paths with spaces, and unrelated files.
AArch64 FreeBSD is one of the platforms restored here, and it installs the
runtimes as `lib/clang/<ver>/lib/freebsd/libclang_rt.profile-aarch64.a`, which the
existing glob already matches. Cover it too, so the check spans every platform
this fixes rather than stopping at Linux and Windows.
@maleadt

maleadt commented Sep 15, 2026

Copy link
Copy Markdown
Member Author

Sorry to kick off another huge run, but it doubles as a good way to catch JuliaPackaging/BinaryBuilder.jl#1453

With the architecture probes fixed, compiler-rt now builds on these targets
and hits two problems that PR CI exposed:

- On musl, only SANITIZERS and XRAY were disabled, but memprof and
  ctx_profile also pull in sanitizer_common, which does not compile against
  musl on ARM and AArch64. Both are x86_64-only, so disable them on musl
  targets other than x86_64 (x86_64-linux-musl keeps shipping them).
- LLVM 22 enables COMPILER_RT_ARM_OPTIMIZED_FP by default. Its assembly needs
  ARMv7, which breaks armv6l, and LLVM 23's divdf3.S uses syntax that our
  GNU as 2.34 cannot parse. Turn it off on 32-bit ARM for LLVM >= 22 so the
  generic C builtins are used.
@maleadt
maleadt merged commit 4dbe01a into master Sep 16, 2026
64 checks passed
@maleadt
maleadt deleted the tb/clang-compiler-rt-aarch64 branch September 16, 2026 03:14
maleadt added a commit to JuliaLang/julia that referenced this pull request Sep 16, 2026
Clang_jll 23.1.1+2 is extracted from a rebuilt LLVM_full_jll that
installs compiler-rt on AArch64 and ARM Linux and on AArch64 FreeBSD
(JuliaPackaging/Yggdrasil#14805, JuliaPackaging/Yggdrasil#14812).
Earlier builds shipped no libclang_rt archives on those platforms, so
linking with -fprofile-generate, as the instrumented stage of
contrib/optimized does, failed there for want of the profile runtime.

The LLVM sources and patches are unchanged, so libLLVM, LLD and the
LLVM tools stay at 23.1.1+1.

Assisted-by: Claude Code (Opus 5)
maleadt added a commit to JuliaLang/julia that referenced this pull request Sep 17, 2026
Clang_jll 23.1.1+2 is extracted from a rebuilt LLVM_full_jll that
installs compiler-rt on AArch64 and ARM Linux and on AArch64 FreeBSD
(JuliaPackaging/Yggdrasil#14805, JuliaPackaging/Yggdrasil#14812).
Earlier builds shipped no libclang_rt archives on those platforms, so
linking with -fprofile-generate, as the instrumented stage of
contrib/optimized does, failed there for want of the profile runtime.

The LLVM sources and patches are unchanged, so libLLVM, LLD and the
LLVM tools stay at 23.1.1+1.

Assisted-by: Claude Code (Opus 5)
maleadt added a commit to JuliaLang/julia that referenced this pull request Sep 17, 2026
Clang_jll 23.1.1+2 is extracted from a rebuilt LLVM_full_jll that
installs compiler-rt on AArch64 and ARM Linux and on AArch64 FreeBSD
(JuliaPackaging/Yggdrasil#14805, JuliaPackaging/Yggdrasil#14812).
Earlier builds shipped no libclang_rt archives on those platforms, so
linking with -fprofile-generate, as the instrumented stage of
contrib/optimized does, failed there for want of the profile runtime.

The LLVM sources and patches are unchanged, so libLLVM, LLD and the
LLVM tools stay at 23.1.1+1.

Assisted-by: Claude Code (Opus 5)
maleadt added a commit to JuliaLang/julia that referenced this pull request Sep 18, 2026
Clang_jll 23.1.1+2 is extracted from a rebuilt LLVM_full_jll that
installs compiler-rt on AArch64 and ARM Linux and on AArch64 FreeBSD
(JuliaPackaging/Yggdrasil#14805, JuliaPackaging/Yggdrasil#14812).
Earlier builds shipped no libclang_rt archives on those platforms, so
linking with -fprofile-generate, as the instrumented stage of
contrib/optimized does, failed there for want of the profile runtime.

The LLVM sources and patches are unchanged, so libLLVM, LLD and the
LLVM tools stay at 23.1.1+1.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant