fix(llvm): correct clang's default GCC triple for Azure Linux stage2#17043
Draft
rlmenge wants to merge 1 commit intotomls/base/mainfrom
Draft
fix(llvm): correct clang's default GCC triple for Azure Linux stage2#17043rlmenge wants to merge 1 commit intotomls/base/mainfrom
rlmenge wants to merge 1 commit intotomls/base/mainfrom
Conversation
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'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. 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.
🔒❌ Lock files are out of dateFIX: — run this and commit the result: azldev component update -p opencryptokiOr download the fix patch and apply it: gh run download 25407858954 -R microsoft/azurelinux -n locks-patch
git apply locks.patchChanged components (1)
|
reubeno
reviewed
May 6, 2026
| # upstream spec and pulls in python3-nanobind-devel which doesn't exist yet. | ||
| build.without = ["mlir"] | ||
|
|
||
| [[components.llvm.overlays]] |
Member
There was a problem hiding this comment.
We also build llvm15, 18, and 20; are they all impacted too?
| [[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' |
Member
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.