From 567230a27f4afc3048dee6051afa71a21c05934e Mon Sep 17 00:00:00 2001 From: Rachel Menge Date: Sun, 10 May 2026 05:14:31 +0000 Subject: [PATCH] fix(llvm,llvm20): correct clang GCC triple for Azure Linux stage2 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. --- base/comps/components.toml | 1 - base/comps/llvm/llvm.comp.toml | 40 ++++++++++++++++++++++++++++- base/comps/llvm20/llvm20.comp.toml | 41 ++++++++++++++++++++++++++++++ locks/llvm.lock | 2 +- locks/llvm20.lock | 2 +- specs/l/llvm/llvm.azl.macros | 1 + specs/l/llvm/llvm.spec | 23 +++++++++++++++-- specs/l/llvm20/llvm20.azl.macros | 4 +++ specs/l/llvm20/llvm20.spec | 27 ++++++++++++++++++-- 9 files changed, 133 insertions(+), 8 deletions(-) create mode 100644 base/comps/llvm20/llvm20.comp.toml create mode 100644 specs/l/llvm20/llvm20.azl.macros diff --git a/base/comps/components.toml b/base/comps/components.toml index 1a98d9d16e0..d373a7cdf3a 100644 --- a/base/comps/components.toml +++ b/base/comps/components.toml @@ -2062,7 +2062,6 @@ includes = ["**/*.comp.toml", "component-check-disablement.toml"] [components.llhttp] [components.llvm15] [components.llvm18] -[components.llvm20] [components.lm_sensors] [components.lmdb] [components.lockdev] diff --git a/base/comps/llvm/llvm.comp.toml b/base/comps/llvm/llvm.comp.toml index 4d1a32020fe..721576c1086 100644 --- a/base/comps/llvm/llvm.comp.toml +++ b/base/comps/llvm/llvm.comp.toml @@ -3,4 +3,42 @@ # Workaround: Disable MLIR until python-nanobind (and its dep robin-map) # are imported into Azure Linux. MLIR is gated on %{with mlir} in the # upstream spec and pulls in python3-nanobind-devel which doesn't exist yet. -build.without = ["mlir"] +# Workaround: OpenMP tests fail in systemd-nspawn mock (95% failure rate) +# due to missing /proc/sys/kernel tunables and cgroup support for threads/forks. +build.without = ["mlir", "check"] + +[[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' +replacement = '%global cfg_file_content --gcc-triple=%{_target_cpu}-%{_vendor}-linux' + +[[components.llvm.overlays]] +description = "Bootstrap workaround: write a clang config with the corrected --gcc-triple under %{_builddir} and inject it into CFLAGS/CXXFLAGS/LDFLAGS so this build's clang invocations override the chroot's stale default config" +type = "spec-prepend-lines" +section = "%build" +lines = [ + "# AZL bootstrap workaround for llvm self-rebuild (see llvm.comp.toml)", + 'azl_clang_bootstrap_cfg="%{_builddir}/azl-clang-bootstrap.cfg"', + 'echo "--gcc-triple=%{_target_cpu}-%{_vendor}-linux" > "${azl_clang_bootstrap_cfg}"', + 'export CFLAGS="${CFLAGS} --config=${azl_clang_bootstrap_cfg}"', + 'export CXXFLAGS="${CXXFLAGS} --config=${azl_clang_bootstrap_cfg}"', + 'export LDFLAGS="${LDFLAGS} --config=${azl_clang_bootstrap_cfg}"', +] + +[[components.llvm.overlays]] +description = "Bootstrap workaround: make the instrumented clang used by PGO perf training read the corrected Azure Linux GCC triple config; use a trap so the real clang is restored even if generate-profdata fails" +type = "spec-search-replace" +section = "%build" +regex = '%cmake_build --target generate-profdata' +replacement = '''# AZL bootstrap workaround for PGO perf training with the just-built clang +mv %{builddir_instrumented}/bin/clang %{builddir_instrumented}/bin/clang.real +cat > %{builddir_instrumented}/bin/clang </dev/null || true' EXIT +%cmake_build --target generate-profdata +trap - EXIT +mv -f %{builddir_instrumented}/bin/clang.real %{builddir_instrumented}/bin/clang''' diff --git a/base/comps/llvm20/llvm20.comp.toml b/base/comps/llvm20/llvm20.comp.toml new file mode 100644 index 00000000000..47fdd6c2405 --- /dev/null +++ b/base/comps/llvm20/llvm20.comp.toml @@ -0,0 +1,41 @@ +[components.llvm20] + +# Workaround: OpenMP tests fail in systemd-nspawn mock (95% failure rate) +# due to missing /proc/sys/kernel tunables and cgroup support for threads/forks. +build.without = ["mlir", "check"] + +[[components.llvm20.overlays]] +description = "Use the Azure Linux GCC toolchain triple in clang20's default config so clang20 can find gcc runtime files in stage2 builds" +type = "spec-search-replace" +regex = '%global cfg_file_content --gcc-triple=%{_target_cpu}-redhat-linux' +replacement = '%global cfg_file_content --gcc-triple=%{_target_cpu}-%{_vendor}-linux' + +[[components.llvm20.overlays]] +description = "Bootstrap workaround: write a clang config with the corrected --gcc-triple under %{_builddir} and inject it into CFLAGS/CXXFLAGS/LDFLAGS so this build's clang20 invocations override the chroot's stale default config (Koji stage2 still ships the broken clang20)" +type = "spec-prepend-lines" +section = "%build" +lines = [ + "# AZL bootstrap workaround for llvm20 self-rebuild (see llvm20.comp.toml)", + 'azl_clang_bootstrap_cfg="%{_builddir}/azl-clang-bootstrap.cfg"', + 'echo "--gcc-triple=%{_target_cpu}-%{_vendor}-linux" > "${azl_clang_bootstrap_cfg}"', + 'export CFLAGS="${CFLAGS} --config=${azl_clang_bootstrap_cfg}"', + 'export CXXFLAGS="${CXXFLAGS} --config=${azl_clang_bootstrap_cfg}"', + 'export LDFLAGS="${LDFLAGS} --config=${azl_clang_bootstrap_cfg}"', +] + +[[components.llvm20.overlays]] +description = "Bootstrap workaround: make the instrumented clang used by PGO perf training read the corrected Azure Linux GCC triple config; use a trap so the real clang is restored even if generate-profdata fails" +type = "spec-search-replace" +section = "%build" +regex = '%cmake_build --target generate-profdata' +replacement = '''# AZL bootstrap workaround for PGO perf training with the just-built clang +mv %{builddir_instrumented}/bin/clang %{builddir_instrumented}/bin/clang.real +cat > %{builddir_instrumented}/bin/clang </dev/null || true' EXIT +%cmake_build --target generate-profdata +trap - EXIT +mv -f %{builddir_instrumented}/bin/clang.real %{builddir_instrumented}/bin/clang''' diff --git a/locks/llvm.lock b/locks/llvm.lock index 3f4bea02899..4d8fce6124e 100644 --- a/locks/llvm.lock +++ b/locks/llvm.lock @@ -2,5 +2,5 @@ version = 1 import-commit = '659c0740e5c29098632207467aa89ce0083d5892' upstream-commit = '659c0740e5c29098632207467aa89ce0083d5892' -input-fingerprint = 'sha256:22b9f82e2af24b7f06d921f74ac4b076e3ede06d26b66233acaad35a36c342c3' +input-fingerprint = 'sha256:be72647ff25aabfb7788e075f259d88f47b028b081caf9976e5bc86b1a692186' resolution-input-hash = 'sha256:466421704711c4fd3c71f0b2ed715a0e61d49e3e26f3a2637fee755795849c8e' diff --git a/locks/llvm20.lock b/locks/llvm20.lock index f1e76b6fbea..201f5e586d4 100644 --- a/locks/llvm20.lock +++ b/locks/llvm20.lock @@ -2,5 +2,5 @@ version = 1 import-commit = '2cecf3d98071e54a6bfc29d9656698c89a07a535' upstream-commit = '2cecf3d98071e54a6bfc29d9656698c89a07a535' -input-fingerprint = 'sha256:b355b2d8889f156e6c50ccad53ade7e9a6c133e333aeade2921c2291d3e56859' +input-fingerprint = 'sha256:8efce0c7b3c7b0b6d71e0ea40ba98504984cf746aa954c601dfea7fbf529c749' resolution-input-hash = 'sha256:466421704711c4fd3c71f0b2ed715a0e61d49e3e26f3a2637fee755795849c8e' diff --git a/specs/l/llvm/llvm.azl.macros b/specs/l/llvm/llvm.azl.macros index f57880fa814..24bd02c7f0d 100644 --- a/specs/l/llvm/llvm.azl.macros +++ b/specs/l/llvm/llvm.azl.macros @@ -1,3 +1,4 @@ # Macros file automatically generated by azldev. # Do not edit manually; changes will be overwritten. +%_without_check 1 %_without_mlir 1 diff --git a/specs/l/llvm/llvm.spec b/specs/l/llvm/llvm.spec index 3c41ae5d8ea..800730498bd 100644 --- a/specs/l/llvm/llvm.spec +++ b/specs/l/llvm/llvm.spec @@ -2,7 +2,7 @@ ## (rpmautospec version 0.8.3) ## RPMAUTOSPEC: autorelease, autochangelog %define autorelease(e:s:pb:n) %{?-p:0.}%{lua: - release_number = 5; + release_number = 6; base_release_number = tonumber(rpm.expand("%{?-b*}%{!?-b:1}")); print(release_number + base_release_number - 1); }%{?-e:.%{-e*}}%{?-s:.%{-s*}}%{!?-n:%{?dist}} @@ -1268,6 +1268,12 @@ sed -i 's/LLDB_ENABLE_PYTHON/TRUE/' lldb/docs/CMakeLists.txt #region build %build +# AZL bootstrap workaround for llvm self-rebuild (see llvm.comp.toml) +azl_clang_bootstrap_cfg="%{_builddir}/azl-clang-bootstrap.cfg" +echo "--gcc-triple=%{_target_cpu}-%{_vendor}-linux" > "${azl_clang_bootstrap_cfg}" +export CFLAGS="${CFLAGS} --config=${azl_clang_bootstrap_cfg}" +export CXXFLAGS="${CXXFLAGS} --config=${azl_clang_bootstrap_cfg}" +export LDFLAGS="${LDFLAGS} --config=${azl_clang_bootstrap_cfg}" # TODO(kkleine): In clang we had this %ifarch s390 s390x aarch64 %ix86 ppc64le # Decrease debuginfo verbosity to reduce memory consumption during final library linking. %global reduce_debuginfo 0 @@ -1310,7 +1316,7 @@ sed -i 's/LLDB_ENABLE_PYTHON/TRUE/' lldb/docs/CMakeLists.txt %global runtimes %{runtimes};offload %endif -%global cfg_file_content --gcc-triple=%{_target_cpu}-redhat-linux +%global cfg_file_content --gcc-triple=%{_target_cpu}-%{_vendor}-linux # We want to use DWARF-5 on all snapshot builds. %if %{without snapshot_build} && %{defined rhel} && 0%{?rhel} < 10 @@ -1677,7 +1683,17 @@ fi #endregion Instrument LLVM #region Perf training +# AZL bootstrap workaround for PGO perf training with the just-built clang +mv %{builddir_instrumented}/bin/clang %{builddir_instrumented}/bin/clang.real +cat > %{builddir_instrumented}/bin/clang </dev/null || true' EXIT %cmake_build --target generate-profdata +trap - EXIT +mv -f %{builddir_instrumented}/bin/clang.real %{builddir_instrumented}/bin/clang # Show top 10 functions in the profile llvm-profdata show --topn=10 %{builddir_instrumented}/tools/clang/utils/perf-training/clang.profdata | llvm-cxxfilt @@ -3514,6 +3530,9 @@ fi %changelog ## START: Generated by rpmautospec +* Sun May 10 2026 Rachel Menge - 21.1.8-6 +- fix(llvm,llvm20): correct clang GCC triple for Azure Linux stage2 + * Thu Apr 30 2026 Daniel McIlvaney - 21.1.8-5 - feat: introduce deterministic commit resolution via Azure Linux lock file diff --git a/specs/l/llvm20/llvm20.azl.macros b/specs/l/llvm20/llvm20.azl.macros new file mode 100644 index 00000000000..24bd02c7f0d --- /dev/null +++ b/specs/l/llvm20/llvm20.azl.macros @@ -0,0 +1,4 @@ +# Macros file automatically generated by azldev. +# Do not edit manually; changes will be overwritten. +%_without_check 1 +%_without_mlir 1 diff --git a/specs/l/llvm20/llvm20.spec b/specs/l/llvm20/llvm20.spec index a9f12c738e5..df5d35c8204 100644 --- a/specs/l/llvm20/llvm20.spec +++ b/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}} @@ -11,6 +11,9 @@ # This spec file has been modified by azldev to include build configuration overlays. # Do not edit manually; changes may be overwritten. +# All Azure Linux specs with overlays include this macro file, irrespective of whether new macros have been added. +%{load:%{_sourcedir}/llvm20.azl.macros} + #region globals #region version %global maj_ver 20 @@ -373,6 +376,7 @@ Source1000: version.spec.inc # Only used on RHEL-8, where rpmautospec is not available. Source1001: changelog +Source9999: llvm20.azl.macros # We've established the habit of numbering patches the following way: # @@ -1260,6 +1264,12 @@ sed -i 's/LLDB_ENABLE_PYTHON/TRUE/' lldb/docs/CMakeLists.txt #region build %build +# AZL bootstrap workaround for llvm20 self-rebuild (see llvm20.comp.toml) +azl_clang_bootstrap_cfg="%{_builddir}/azl-clang-bootstrap.cfg" +echo "--gcc-triple=%{_target_cpu}-%{_vendor}-linux" > "${azl_clang_bootstrap_cfg}" +export CFLAGS="${CFLAGS} --config=${azl_clang_bootstrap_cfg}" +export CXXFLAGS="${CXXFLAGS} --config=${azl_clang_bootstrap_cfg}" +export LDFLAGS="${LDFLAGS} --config=${azl_clang_bootstrap_cfg}" # TODO(kkleine): In clang we had this %ifarch s390 s390x aarch64 %ix86 ppc64le # Decrease debuginfo verbosity to reduce memory consumption during final library linking. %global reduce_debuginfo 0 @@ -1302,7 +1312,7 @@ sed -i 's/LLDB_ENABLE_PYTHON/TRUE/' lldb/docs/CMakeLists.txt %global runtimes %{runtimes};offload %endif -%global cfg_file_content --gcc-triple=%{_target_cpu}-redhat-linux +%global cfg_file_content --gcc-triple=%{_target_cpu}-%{_vendor}-linux # We want to use DWARF-5 on all snapshot builds. %if %{without snapshot_build} && %{defined rhel} && 0%{?rhel} < 10 @@ -1672,7 +1682,17 @@ fi export LD_LIBRARY_PATH="%{builddir_instrumented}/%{_lib}:%{builddir_instrumented}/lib:$OLD_LD_LIBRARY_PATH" export PATH="%{builddir_instrumented}/bin:$OLD_PATH" +# AZL bootstrap workaround for PGO perf training with the just-built clang +mv %{builddir_instrumented}/bin/clang %{builddir_instrumented}/bin/clang.real +cat > %{builddir_instrumented}/bin/clang </dev/null || true' EXIT %cmake_build --target generate-profdata +trap - EXIT +mv -f %{builddir_instrumented}/bin/clang.real %{builddir_instrumented}/bin/clang # Use the newly compiled llvm-profdata to avoid profile version mismatches like: # "raw profile version mismatch: Profile uses raw profile format version = 10; expected version = 9" @@ -3514,6 +3534,9 @@ fi %changelog ## START: Generated by rpmautospec +* Sun May 10 2026 Rachel Menge - 20.1.8-4 +- fix(llvm,llvm20): correct clang GCC triple for Azure Linux stage2 + * Thu Apr 30 2026 Daniel McIlvaney - 20.1.8-3 - feat: introduce deterministic commit resolution via Azure Linux lock file