fix(llvm): correct clang's default GCC triple for Azure Linux stage2#17043
fix(llvm): correct clang's default GCC triple for Azure Linux stage2#17043rlmenge wants to merge 2 commits intotomls/base/mainfrom
Conversation
| # upstream spec and pulls in python3-nanobind-devel which doesn't exist yet. | ||
| build.without = ["mlir"] | ||
|
|
||
| [[components.llvm.overlays]] |
There was a problem hiding this comment.
We also build llvm15, 18, and 20; are they all impacted too?
There was a problem hiding this comment.
20 for sure. Looks like 15 and 18 don't have the config file refrence so I am not sure. I will update the pr at least for llvm20.
| [[components.llvm.overlays]] | ||
| description = "Use the Azure Linux GCC toolchain triple in clang's default config so clang can find gcc runtime files in stage2 builds" | ||
| type = "spec-search-replace" | ||
| regex = '%global cfg_file_content --gcc-triple=%{_target_cpu}-redhat-linux' |
There was a problem hiding this comment.
Is there an opportunity to use the standard RPM macro %{_target_platform} in place of the whole thing? That's presumably what the upstream spec should have used.
There was a problem hiding this comment.
There is unfortunately not a match thanks to the "gnu"
<mock-chroot> sh-5.3# rpm --eval '%{_target_platform}'
x86_64-azurelinux-linux-gnu
There was a problem hiding this comment.
Good to know. How about at least using %{_vendor}?
There was a problem hiding this comment.
%vendor should work!
The upstream Fedora clang spec writes a default config drop-in to /etc/clang/<triple>-clang.cfg containing '--gcc-triple=<cpu>-redhat-linux'. Clang autoloads this drop-in when its compiled-in default target matches the basename. In Azure Linux 4.0 stage2, GCC runtime files (crtbegin.o, crtend.o, libgcc.a, etc.) ship under /usr/lib/gcc/x86_64-azurelinux-linux/ not /usr/lib/gcc/x86_64-redhat-linux/, so clang fails to find crtbeginS.o, -lgcc, and -lgcc_s when invoking ld.lld. This breaks any package whose build links via clang -- most visibly the kernel BPF selftests, which abort with 'cannot open crtbeginS.o' while linking liburandom_read.so, leading to the kernel build aborting on a strict 'cp .../bpftool' for missing artifacts. Add a spec-search-replace overlay to change the gcc_triple macro from -redhat-linux to -azurelinux-linux so the shipped clang config points at the actual Azure Linux GCC runtime tree.
ae36f49 to
f88da1b
Compare
Same issue as llvm (clang 21): the upstream Fedora spec hardcodes --gcc-triple=<cpu>-redhat-linux in the clang config drop-in. Apply the identical spec-search-replace overlay to llvm20 so that clang-20 also finds GCC runtime files under /usr/lib/gcc/x86_64-azurelinux-linux/. Move the llvm20 component from inline components.toml to a dedicated base/comps/llvm20/llvm20.comp.toml to house the overlay.
f88da1b to
2ed0299
Compare
📄❌ Rendered specs are out of dateFIX: — run this and commit the result: azldev component render llvm llvm20Or download the fix patch and apply it: gh run download 25465127854 -R microsoft/azurelinux -n rendered-specs-patch
git apply rendered-specs.patch
Content diffs`specs/l/llvm/llvm.spec`--- committed/specs/l/llvm/llvm.spec
+++ rendered/specs/l/llvm/llvm.spec
@@ -3515,7 +3515,7 @@
%changelog
## START: Generated by rpmautospec
* Fri May 01 2026 Rachel Menge <rachelmenge@microsoft.com> - 21.1.8-6
-- fix(llvm): correct clang's default GCC triple for Azure Linux stage2
+- fix(llvm): correct clang default GCC triple for Azure Linux stage2
* Thu Apr 30 2026 Daniel McIlvaney <damcilva@microsoft.com> - 21.1.8-5
- feat: introduce deterministic commit resolution via Azure Linux lock file
`specs/l/llvm20/llvm20.spec`--- committed/specs/l/llvm20/llvm20.spec
+++ rendered/specs/l/llvm20/llvm20.spec
@@ -2,7 +2,7 @@
## (rpmautospec version 0.8.3)
## RPMAUTOSPEC: autorelease, autochangelog
%define autorelease(e:s:pb:n) %{?-p:0.}%{lua:
- release_number = 3;
+ release_number = 4;
base_release_number = tonumber(rpm.expand("%{?-b*}%{!?-b:1}"));
print(release_number + base_release_number - 1);
}%{?-e:.%{-e*}}%{?-s:.%{-s*}}%{!?-n:%{?dist}}
@@ -3514,6 +3514,9 @@
%changelog
## START: Generated by rpmautospec
+* Wed May 06 2026 Rachel Menge <rachelmenge@microsoft.com> - 20.1.8-4
+- fix(llvm20): apply same GCC triple fix for llvm20
+
* Thu Apr 30 2026 Daniel McIlvaney <damcilva@microsoft.com> - 20.1.8-3
- feat: introduce deterministic commit resolution via Azure Linux lock file
|
|
Closing to use the bootsrtap version: #17100 |
Merge Checklist
All boxes should be checked before merging the PR (just tick any boxes which don't apply to this PR)
*-staticsubpackages, etc.) have had theirReleasetag incremented../cgmanifest.json,./toolkit/scripts/toolchain/cgmanifest.json,.github/workflows/cgmanifest.json)./LICENSES-AND-NOTICES/SPECS/data/licenses.json,./LICENSES-AND-NOTICES/SPECS/LICENSES-MAP.md,./LICENSES-AND-NOTICES/SPECS/LICENSE-EXCEPTIONS.PHOTON)*.signatures.jsonfilessudo make go-tidy-allandsudo make go-test-coveragepassSummary
The upstream Fedora clang spec writes a default config drop-in to /etc/clang/-clang.cfg containing '--gcc-triple=-redhat-linux'. Clang autoloads this drop-in when its compiled-in default target matches the basename.
In Azure Linux 4.0 stage2, GCC's runtime files (crtbegin.o, crtend.o, libgcc.a, etc.) ship under /usr/lib/gcc/x86_64-azurelinux-linux/ instead of /usr/lib/gcc/x86_64-redhat-linux/. As a result, clang can fail to find crtbeginS.o, -lgcc, and -lgcc_s when linking with ld.lld.
Add one LLVM component overlay to change the generated cfg_file_content macro from -redhat-linux to -azurelinux-linux, so the shipped clang default config points at the actual Azure Linux GCC runtime tree.
This is the clean fix, but rollout may require a bootstrap build or pre-seeding the stage2 buildroot with the fixed clang package. A full local LLVM rebuild from the no-bootstrap branch currently fails because the buildroot's already-installed clang still has the old bad config. The branch fixes the config that the new clang RPM would install, but the build depends on the existing broken clang before it can produce that RPM.
A local full build requires a temporary bootstrap step or a buildroot where clang's GCC triple is already corrected.
Refresh locks/llvm.lock and rerender specs/l/llvm/llvm.spec. This branch intentionally omits the temporary bootstrap workarounds used for local LLVM self-rebuild testing.
Verified with azldev comp render -p llvm -O json.
Change Log
Does this affect the toolchain?
NO
Associated issues
Test Methodology
validated the change in two layers: render validation and clang runtime/link behavior in the stage2 mock chroot.
1. Render validation
Rendered LLVM successfully:
Confirmed rendered spec contains:
Confirmed the no-bootstrap branch does not contain the temporary bootstrap workaround:
2. Runtime/link validation
Reproduced the existing failure in the local stage2 mock buildroot. The currently installed clang package still has the bad config:
With that existing config, clang fails to link a simple C program because it cannot locate GCC runtime files:
Verified that forcing the Azure Linux GCC triple fixes simple C and C++ linking in the same mock chroot:
Also attempted a full local LLVM build:
That build fails before producing new RPMs because the buildroot uses the currently installed clang package, whose config still points at
x86_64-redhat-linux. This is the bootstrap issue this change is intended to fix for future clang packages.Current Limitation
A full local LLVM rebuild from the no-bootstrap branch currently fails because the buildroot's already-installed clang still has the old bad config. The branch fixes the config that the new clang RPM would install, but the build depends on the existing broken clang before it can produce that RPM.
A local full build requires a temporary bootstrap step or a buildroot where clang's GCC triple is already corrected.