Skip to content

fix(llvm,llvm20): correct clang's default GCC triple for Azure Linux stage2#17100

Merged
reubeno merged 1 commit into
tomls/base/mainfrom
rlmenge/tomls/clang-gcc-triple-bootstrap
May 11, 2026
Merged

fix(llvm,llvm20): correct clang's default GCC triple for Azure Linux stage2#17100
reubeno merged 1 commit into
tomls/base/mainfrom
rlmenge/tomls/clang-gcc-triple-bootstrap

Conversation

@rlmenge
Copy link
Copy Markdown
Contributor

@rlmenge rlmenge commented May 8, 2026

Merge Checklist

All boxes should be checked before merging the PR (just tick any boxes which don't apply to this PR)

  • The toolchain has been rebuilt successfully (or no changes were made to it)
  • The toolchain/worker package manifests are up-to-date
  • Any updated packages successfully build (or no packages were changed)
  • Packages depending on static components modified in this PR (Golang, *-static subpackages, etc.) have had their Release tag incremented.
  • Package tests (%check section) have been verified with RUN_CHECK=y for existing SPEC files, or added to new SPEC files
  • All package sources are available
  • cgmanifest files are up-to-date and sorted (./cgmanifest.json, ./toolkit/scripts/toolchain/cgmanifest.json, .github/workflows/cgmanifest.json)
  • LICENSE-MAP files are up-to-date (./LICENSES-AND-NOTICES/SPECS/data/licenses.json, ./LICENSES-AND-NOTICES/SPECS/LICENSES-MAP.md, ./LICENSES-AND-NOTICES/SPECS/LICENSE-EXCEPTIONS.PHOTON)
  • All source files have up-to-date hashes in the *.signatures.json files
  • sudo make go-tidy-all and sudo make go-test-coverage pass
  • Documentation has been updated to match any changes to the build system
  • Ready to merge

Summary

Fix clang/clang20 stage2 bootstrap failures caused by clang’s generated default GCC triple pointing at the Fedora/RHEL-style runtime path.

Both llvm and llvm20 generate clang config files containing:

--gcc-triple=%{_target_cpu}-redhat-linux

In Azure Linux stage2, GCC runtime files are installed under the Azure Linux vendor triple instead:

/usr/lib/gcc/%{_target_cpu}-%{_vendor}-linux/

This mismatch causes clang-driven links to fail when looking for crtbeginS.o, libgcc, and libgcc_s. That affects both the primary LLVM toolchain and the llvm20 compatibility toolchain during
stage2/self-bootstrap builds, and can also break downstream packages that link through clang.

This change updates both llvm and llvm20 to:

  • Generate clang/clang20 default configs with %{_target_cpu}-%{_vendor}-linux.
  • Add a temporary bootstrap clang config during %build so the current self-rebuild overrides the stale clang config already present in the buildroot.
  • Wrap the instrumented clang used during PGO profile generation so generate-profdata also uses the corrected GCC triple.
  • Disable %check by default because OpenMP tests are unreliable under systemd-nspawn due to missing /proc/sys/kernel tunables and restricted cgroup/thread support.

The %build bootstrap config injection and PGO clang wrapper are intended as temporary workarounds. The plan is to remove them once stage2 reaches a stable state where a usable clang with the corrected default config is already available in the buildroot.

Change Log

  • Correct clang and clang20 default GCC triple from *-redhat-linux to *-%{_vendor}-linux.
  • Add matching llvm and llvm20 bootstrap workarounds using --config=/tmp/azl-clang-bootstrap.cfg.
  • Apply the bootstrap config to the PGO instrumented clang wrapper for both toolchains.
  • Disable %check by default for both llvm and llvm20.
  • Regenerate specs, macro files, and lock fingerprints for both components.

Associated issues

Test Methodology

Validated both llvm and llvm20 through Koji stage2 builds.

  • llvm20 Koji task/build: 2337113
  • llvm Koji task/build: 2337114
    Both Koji builds completed successfully and produced the expected clang/LLVM/lld RPMs.
[azureuser@rlmenge-azl4-arm64 clang-test-17100]$ rpm -qa | grep llvm
llvm-filesystem-21.1.8-6.azl4.aarch64
llvm-libs-21.1.8-6.azl4.aarch64
llvm-21.1.8-6.azl4.aarch64
[azureuser@rlmenge-azl4-arm64 clang-test-17100]$ clang --version
clang version 21.1.8 (Microsoft Corporation 21.1.8-6.azl4)
Target: aarch64-azurelinux-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
Configuration file: /etc/clang/aarch64-azurelinux-linux-gnu-clang.cfg
[azureuser@rlmenge-azl4-arm64 clang-test-17100]$

@rlmenge rlmenge marked this pull request as ready for review May 8, 2026 22:26
@rlmenge rlmenge requested a review from ddstreetmicrosoft as a code owner May 8, 2026 22:26
Copilot AI review requested due to automatic review settings May 8, 2026 22:26
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the LLVM (llvm, llvm20) packaging to fix Azure Linux stage2 bootstrap/self-rebuild failures caused by clang’s default GCC triple pointing at the wrong vendor runtime path.

Changes:

  • Update clang/clang20 default config generation to use %{_target_cpu}-%{_vendor}-linux instead of *-redhat-linux.
  • Add stage2 bootstrap workarounds (temporary /tmp clang config injection and a PGO perf-training clang wrapper) to force the corrected GCC triple during the self-rebuild.
  • Disable %check by default for llvm/llvm20 and regenerate rendered specs/macros + refresh lock fingerprints.

Reviewed changes

Copilot reviewed 7 out of 9 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
specs/l/llvm/llvm.spec Rendered spec updated: corrected gcc triple in clang config, added bootstrap config injection + PGO wrapper, default %check disabled.
specs/l/llvm/llvm.azl.macros Generated azldev macros updated to include %_without_check 1.
specs/l/llvm20/llvm20.spec Rendered spec updated: adds macros load/source, corrected gcc triple in clang20 config, adds bootstrap config injection + PGO wrapper, default %check disabled.
specs/l/llvm20/llvm20.azl.macros New generated azldev macros file (disables check + mlir by default).
base/comps/llvm/llvm.comp.toml Component config adds overlays/workarounds for gcc triple + bootstrap/PGO wrapper; disables check/mlir via build.without.
base/comps/llvm20/llvm20.comp.toml New component config for llvm20 with the same overlays/workarounds; disables check/mlir via build.without.
base/comps/components.toml Removes inline [components.llvm20] entry now that llvm20 has a dedicated .comp.toml.
locks/llvm.lock Updates input fingerprint to match component config changes.
locks/llvm20.lock Updates input fingerprint to match new component config + overlays.

Comment thread specs/l/llvm/llvm.spec Outdated
Comment thread specs/l/llvm/llvm.spec Outdated
Comment thread specs/l/llvm20/llvm20.spec Outdated
Comment thread specs/l/llvm20/llvm20.spec Outdated
Comment thread base/comps/llvm/llvm.comp.toml Outdated
Comment thread base/comps/llvm20/llvm20.comp.toml Outdated
Comment thread base/comps/llvm/llvm.comp.toml Outdated
Clang's generated default config used the Fedora/RHEL GCC runtime triple
`%{_target_cpu}-redhat-linux`, but Azure Linux stage2 provides GCC runtime
files under `%{_target_cpu}-%{_vendor}-linux`. That made clang look in the
wrong GCC tree for crtbegin/crtend and libgcc when linking packages in
stage2 builds.

Update llvm and llvm20 to generate clang config files with the Azure Linux
vendor triple. Add bootstrap config injection during the self-rebuild so
the existing broken in-chroot clang is overridden while rebuilding LLVM,
and wrap the PGO instrumented clang so perf training uses the corrected
triple as well.

For llvm20, apply the same bootstrap path because compat builds pin the
host compiler major version to 20 and therefore still rely on the broken
stage2 clang20 during self-rebuilds.

Keep check disabling controlled by `build.without = ["mlir", "check"]`
only; this generates the azldev macro `%_without_check 1`, so no bcond
overlay is needed. Move the bootstrap config under `%{_builddir}` and use
an EXIT trap to restore the PGO clang wrapper safely if generate-profdata
fails.

Validated with:
  azldev comp build -p llvm -p llvm20 --preserve-buildenv on-failure -q

Also smoke-tested the rebuilt clang and clang20 RPMs in the stage2 mock:
both select the Azure Linux GCC runtime path and compile/link a trivial C
program successfully.
@rlmenge rlmenge force-pushed the rlmenge/tomls/clang-gcc-triple-bootstrap branch from 7e1693b to 567230a Compare May 10, 2026 05:15
@reubeno reubeno merged commit f394783 into tomls/base/main May 11, 2026
10 checks passed
@reubeno reubeno deleted the rlmenge/tomls/clang-gcc-triple-bootstrap branch May 11, 2026 10:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants