From 8af5bdabc13add1d26a982a78b5f1e3045840008 Mon Sep 17 00:00:00 2001 From: Chris Co Date: Sun, 24 May 2026 00:32:55 -0700 Subject: [PATCH 1/2] fix(rocm-compilersupport): introduce azl_release counter The hard-coded "Release: 15.rocm%{rocm_version}%{?dist}" line in this spec gives no machine-readable signal for "AZL has rebuilt this on top of an unchanged upstream pin", which means every distro-local change (overlay tweak, build-flag adjustment, dependency rebuild) requires hand-editing the Release prefix to bump it. That is easy to forget and trivial to get wrong. Switch to the same %{azl_release}-driven pattern used elsewhere in the distro by adding a spec-set-tag overlay: Release: %[15 + %{azl_release}].rocm%{rocm_version}%{?dist} spec-set-tag is the documented form for manual-release components (see comp-toml.instructions.md) and is anchor-free, so it survives upstream Release-line restructures (e.g. Fedora's rocm-7.x preview branch wraps Release in %if/%endif, which a literal spec-search-replace anchor would silently miss). %{azl_release} is set via build.defines in the comp.toml and is meant to be incremented monotonically by every commit that changes a tracked input (overlay edit, build-define change, lock pin refresh). The "15 +" base preserves continuity with the previously shipped Release == 15 builds so the schema stays monotonic across the switchover. The initial value (3) accounts for the upstream-fingerprint-changing commits that preceded this one, plus this commit itself; the inline comment in comp.toml lists them by title so reviewers can audit the counter against history without scraping git log. No build behaviour changes besides the literal Release number. --- .../rocm-compilersupport.comp.toml | 35 ++++++++++++++++++- locks/rocm-compilersupport.lock | 2 +- .../rocm-compilersupport.azl.macros | 3 ++ .../rocm-compilersupport.spec | 6 +++- 4 files changed, 43 insertions(+), 3 deletions(-) create mode 100644 specs/r/rocm-compilersupport/rocm-compilersupport.azl.macros diff --git a/base/comps/rocm-compilersupport/rocm-compilersupport.comp.toml b/base/comps/rocm-compilersupport/rocm-compilersupport.comp.toml index d44a56ce34b..5f829c13841 100644 --- a/base/comps/rocm-compilersupport/rocm-compilersupport.comp.toml +++ b/base/comps/rocm-compilersupport/rocm-compilersupport.comp.toml @@ -1,3 +1,36 @@ [components.rocm-compilersupport] -# Release: 15.rocm%{rocm_version}%{?dist} +# Release is composed in the overlay below as +# Release: %[15 + %{azl_release}].rocm%{rocm_version}%{?dist} +# The "15 +" base anchors the formula at the last hard-coded Release +# value before the counter was introduced; %{azl_release} then adds the +# number of AZL-only rebuilds on top of that, ensuring Release stays +# monotonic across the switchover. release = { calculation = "manual" } + +[components.rocm-compilersupport.build.defines] +# AZL-only release counter. Composed with the "15." base via the overlay +# below (Release: %[15 + %{azl_release}].rocm...), keeping a monotonically +# increasing single-number Release schema. Bump whenever an AZL-only +# change requires a new RPM (new overlay, build-flag change, rebuild +# against new dependency) WITHOUT moving the upstream pin. +# +# Current value matches the number of times the lock file's +# input-fingerprint has changed. Each commit that touches a tracked +# input (overlay edit, build-define change, lock pin refresh, etc.) +# advances the counter by one in the same PR. +# +# Commits that have bumped this counter (newest last): +# 1. feat: introduce deterministic commit resolution via Azure Linux lock file +# 2. fix(rocm-compilersupport): set manual release calculation +# 3. fix(rocm-compilersupport): introduce azl_release counter +azl_release = "3" + +[[components.rocm-compilersupport.overlays]] +# spec-set-tag is the documented form for manual-release components and is +# anchor-free, so this survives upstream Release-line restructures (e.g. +# Fedora's rocm-7.x preview branch wraps Release in %if/%endif which would +# break a literal spec-search-replace anchor). +description = "Set Release to %{azl_release}-driven formula so AZL-only rebuilds bump cleanly without manual edits" +type = "spec-set-tag" +tag = "Release" +value = "%[15 + %{azl_release}].rocm%{rocm_version}%{?dist}" diff --git a/locks/rocm-compilersupport.lock b/locks/rocm-compilersupport.lock index fba220fb70b..2db32214a6d 100644 --- a/locks/rocm-compilersupport.lock +++ b/locks/rocm-compilersupport.lock @@ -2,5 +2,5 @@ version = 1 import-commit = '878261eeebbede5f9f220522155fb1ccd8110df8' upstream-commit = '878261eeebbede5f9f220522155fb1ccd8110df8' -input-fingerprint = 'sha256:85e674748ef2b244a89da353d8de60b5f64024025b9b7bb8db662555e85c0f60' +input-fingerprint = 'sha256:f9cc0fb681d6fdbc327ab3a6b4758b6cda917056d64d399c10e1121f5cc5ff0d' resolution-input-hash = 'sha256:466421704711c4fd3c71f0b2ed715a0e61d49e3e26f3a2637fee755795849c8e' diff --git a/specs/r/rocm-compilersupport/rocm-compilersupport.azl.macros b/specs/r/rocm-compilersupport/rocm-compilersupport.azl.macros new file mode 100644 index 00000000000..bc741136bc9 --- /dev/null +++ b/specs/r/rocm-compilersupport/rocm-compilersupport.azl.macros @@ -0,0 +1,3 @@ +# Macros file automatically generated by azldev. +# Do not edit manually; changes will be overwritten. +%azl_release 3 diff --git a/specs/r/rocm-compilersupport/rocm-compilersupport.spec b/specs/r/rocm-compilersupport/rocm-compilersupport.spec index cb7fdb3ff76..ce97802834b 100644 --- a/specs/r/rocm-compilersupport/rocm-compilersupport.spec +++ b/specs/r/rocm-compilersupport/rocm-compilersupport.spec @@ -1,6 +1,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}/rocm-compilersupport.azl.macros} + # The package follows LLVM's major version, but API version is still important: %global comgr_maj_api_ver 3 # local, fedora @@ -42,7 +45,7 @@ Name: rocm-compilersupport Version: %{llvm_maj_ver} -Release: 15.rocm%{rocm_version}%{?dist} +Release: %[15 + %{azl_release}].rocm%{rocm_version}%{?dist} Summary: Various AMD ROCm LLVM related services %if 0%{?suse_version} Group: Development/Languages/Other @@ -53,6 +56,7 @@ Url: https://github.com/ROCm/llvm-project License: NCSA and MIT Source0: https://github.com/ROCm/%{upstreamname}/archive/refs/tags/rocm-%{rocm_version}.tar.gz#/%{name}-%{rocm_version}.tar.gz Source1: rocm-compilersupport.prep.in +Source9999: rocm-compilersupport.azl.macros Patch3: 0001-Remove-err_drv_duplicate_config-check.patch Patch4: 0001-Replace-use-of-mktemp-with-mkstemp.patch From e157c35414d05c4b7bfa0d700f9b11ae03e38ed4 Mon Sep 17 00:00:00 2001 From: Chris Co Date: Sun, 24 May 2026 00:34:01 -0700 Subject: [PATCH 2/2] fix(rocm-compilersupport): teach rocm-llvm clang to find the AZL GCC toolchain AZL's azurelinux-rpm-config overlay changes %_vendor from "redhat" to "azurelinux", so GCC installs its runtime objects (crtbeginS.o, libgcc, libstdc++, etc.) under /usr/lib/gcc/-azurelinux-linux//. The upstream clang GCCInstallationDetector triple list in clang/lib/Driver/ToolChains/Gnu.cpp only knows about a fixed set of vendor strings ("redhat", "suse", "amazon", ...) and has no "azurelinux" entry, so any clang built without an AZL-aware config silently fails to find the GCC install and produces link errors like: ld.lld: error: cannot open crtbeginS.o: No such file or directory ld.lld: error: unable to find library -lstdc++ ld.lld: error: unable to find library -lgcc_s / -lgcc The system llvm / llvm20 packages already work around this by writing %{_target_platform}-clang.cfg files into /etc/clang containing "--gcc-triple=%{_target_cpu}-%{_vendor}-linux". The rocm-llvm clang shipped here lives at /usr/lib64/rocm/llvm/bin/ and does not read /etc/clang, so it needs its own per-binary config file. This was breaking the mivisionx build on x86_64 (and would similarly break every other ROCm consumer that drives the rocm-llvm clang directly, e.g. hipblaslt, hipcub, hipfft, rocfft, rocblas, miopen). A rebuild of rocm-compilersupport itself also fails for the same reason because the multi-stage %build uses its own freshly-built clang to compile each subsequent stage. Drop a single per-triple "%{llvm_triple}.cfg" file containing --gcc-triple=%{_target_cpu}-%{_vendor}-linux in three places: 1. Next to the stage-1 clang inside build-llvm/bin so stage 2+ of the in-package %build can compile and link. 2. Pre-staged inside build-llvm-2/bin before stage-2 %cmake_build runs so the LLVM "runtimes" sub-build (compiler-rt, libcxx, libcxxabi) can configure once stage-2 clang is produced. 3. Installed into %{bundle_prefix}/bin alongside the shipped clang so every downstream ROCm consumer sees the right toolchain triple. The per-triple filename form (.cfg, looked up by clang's config-file step 5 in Driver.cpp) is preferred over mode-specific clang.cfg / clang++.cfg files because: - It is mode-independent, so it covers clang, clang++, clang-cpp, clang-cl, clang-dxc, and flang from a single file. (flang and clang-dxc do not fall through to clang.cfg via the modeSuffix logic, so a mode-specific cfg would silently miss them.) - It is only loaded when the active target triple matches the filename, so an explicit "--target=aarch64-linux-gnu" invocation on an x86_64 host does NOT pick up the AZL --gcc-triple flag and cross-compilation behaviour matches upstream. The shipped cfg uses spec-append-lines targeted at the %install section (rather than a spec-search-replace anchored on a fragile upstream comment like "# Remove lld's libs"), so it survives upstream restructures of the install-time cleanup block. The existing "%{bundle_prefix}/bin/clang*" glob in %files -n rocm-clang does not match ".cfg", so the file is also explicitly listed via a second spec-append-lines overlay on the rocm-clang %files section. This mirrors the existing per-triple cfg approach in base/comps/llvm and base/comps/llvm20 (whose cfg files land in /etc/clang/) rather than introducing a new mechanism. --- .../rocm-compilersupport.comp.toml | 89 ++++++++++++++++++- locks/rocm-compilersupport.lock | 2 +- .../rocm-compilersupport.azl.macros | 2 +- .../rocm-compilersupport.spec | 20 +++++ 4 files changed, 110 insertions(+), 3 deletions(-) diff --git a/base/comps/rocm-compilersupport/rocm-compilersupport.comp.toml b/base/comps/rocm-compilersupport/rocm-compilersupport.comp.toml index 5f829c13841..868ecaf9900 100644 --- a/base/comps/rocm-compilersupport/rocm-compilersupport.comp.toml +++ b/base/comps/rocm-compilersupport/rocm-compilersupport.comp.toml @@ -23,7 +23,8 @@ release = { calculation = "manual" } # 1. feat: introduce deterministic commit resolution via Azure Linux lock file # 2. fix(rocm-compilersupport): set manual release calculation # 3. fix(rocm-compilersupport): introduce azl_release counter -azl_release = "3" +# 4. fix(rocm-compilersupport): teach rocm-llvm clang to find the AZL GCC toolchain +azl_release = "4" [[components.rocm-compilersupport.overlays]] # spec-set-tag is the documented form for manual-release components and is @@ -34,3 +35,89 @@ description = "Set Release to %{azl_release}-driven formula so AZL-only rebuilds type = "spec-set-tag" tag = "Release" value = "%[15 + %{azl_release}].rocm%{rocm_version}%{?dist}" + +[[components.rocm-compilersupport.overlays]] +# AZL changes %_vendor from "redhat" to "azurelinux" (see azurelinux-rpm-config), +# so GCC installs its runtime objects under /usr/lib/gcc/-azurelinux-linux//. +# Upstream clang's GCCInstallationDetector triple list does not include the +# "azurelinux" vendor, so without help any clang built against this layout can't +# find crtbeginS.o / libstdc++ / libgcc and link of any C++ test program (e.g. +# CMake compiler probe) fails with "cannot open crtbeginS.o" and "unable to find +# library -lstdc++". +# +# Fix it by dropping .cfg next to the clang binaries with +# --gcc-triple=. Clang's config-file lookup (clang/lib/Driver/Driver.cpp +# step 5) tries .cfg from the binary's directory before any system +# config dir, mode-independently — so this single file covers clang, clang++, +# clang-cpp, clang-cl, clang-dxc, and flang, without leaking onto explicit +# cross-target (--target=...) invocations whose triple won't match the filename. +# +# The three overlays below drop the file in three places: +# 1. next to the stage-1 clang in the in-package build tree, so stage 2+ +# of this spec's %build can compile and link; +# 2. pre-staged inside the stage-2 build tree before %cmake_build runs, so +# the LLVM runtimes sub-build (compiler-rt, libcxx, libcxxabi) can +# configure once stage-2 clang is produced; +# 3. installed into %{bundle_prefix}/bin alongside the shipped clang, so +# every downstream ROCm consumer (mivisionx, rocblas, hipblaslt, …) +# sees the right toolchain triple without needing any change of its own. +description = "Drop %{llvm_triple}.cfg next to the in-tree stage-1 clang so later build stages can locate the Azure Linux GCC toolchain" +type = "spec-search-replace" +regex = '''build_stage1=\$p/build-llvm''' +replacement = '''build_stage1=$p/build-llvm + +# AZL: drop the per-triple clang config inside the stage-1 build tree so +# every subsequent stage (stage-2 llvm, device-libs, comgr, hipcc) compiled +# by this clang finds the Azure Linux GCC toolchain at +# /usr/lib/gcc/%{_target_cpu}-%{_vendor}-linux/. +echo "--gcc-triple=%{_target_cpu}-%{_vendor}-linux" > $build_stage1/bin/%{llvm_triple}.cfg''' + +[[components.rocm-compilersupport.overlays]] +# Stage 2 builds the LLVM "runtimes" project (compiler-rt, libcxx, libcxxabi) +# as a sub-build that re-invokes CMake using the freshly-built stage-2 clang +# at build-llvm-2/bin/. That sub-build re-runs the compiler/linker probes +# and hits the same GCC-toolchain-detection failure as stage 1 unless its +# clang has a per-triple config alongside it. Drop the cfg file into the +# stage-2 bin directory before %cmake_build runs; it sits there until clang +# is built and is picked up automatically on first invocation. +description = "Drop %{llvm_triple}.cfg into the stage-2 build tree so the LLVM runtimes sub-build can find the Azure Linux GCC toolchain" +type = "spec-search-replace" +regex = '''-DLLVM_ENABLE_RUNTIMES=%\{llvm_runtimes\}''' +replacement = '''-DLLVM_ENABLE_RUNTIMES=%{llvm_runtimes} + +# AZL: pre-stage the per-triple clang config inside build-llvm-2/bin so +# the LLVM runtimes sub-build can locate the Azure Linux GCC toolchain. +# The .cfg only needs to exist by the time clang is invoked. +mkdir -p $PWD/build-llvm-2/bin +echo "--gcc-triple=%{_target_cpu}-%{_vendor}-linux" > $PWD/build-llvm-2/bin/%{llvm_triple}.cfg''' + +[[components.rocm-compilersupport.overlays]] +# The shipped rocm-llvm clang at %{bundle_prefix}/bin/ doesn't read /etc/clang +# (which is where the system llvm/llvm20 packages put their --gcc-triple cfg), +# so we need to drop a per-triple cfg next to the rocm-llvm binaries too. +# Appending to %install (rather than anchoring on a fragile upstream comment +# like "# Remove lld's libs") guarantees this runs even if upstream reshapes +# the cleanup block at the bottom of %install. +description = "Install %{llvm_triple}.cfg next to the shipped rocm-llvm clang so every downstream ROCm consumer sees the Azure Linux GCC toolchain" +type = "spec-append-lines" +section = "%install" +lines = [ + "", + "# AZL: drop a per-triple clang config file next to the shipped rocm-llvm", + "# binaries so every clang/clang++/flang/clang-cl/clang-dxc invocation that", + "# uses the default (AZL) target triple can locate the GCC toolchain at", + "# /usr/lib/gcc/%{_target_cpu}-%{_vendor}-linux/. Cross-target invocations", + "# (--target=) do not match this filename and are unaffected.", + "echo \"--gcc-triple=%{_target_cpu}-%{_vendor}-linux\" > %{buildroot}%{bundle_prefix}/bin/%{llvm_triple}.cfg", +] + +[[components.rocm-compilersupport.overlays]] +# %{bundle_prefix}/bin/clang* in %files -n rocm-clang does not match a file +# named .cfg, so it has to be listed explicitly. +description = "Ship the per-triple clang config file as part of rocm-clang" +type = "spec-append-lines" +section = "%files" +package = "rocm-clang" +lines = [ + "%{bundle_prefix}/bin/%{llvm_triple}.cfg", +] diff --git a/locks/rocm-compilersupport.lock b/locks/rocm-compilersupport.lock index 2db32214a6d..df6b4b15f5d 100644 --- a/locks/rocm-compilersupport.lock +++ b/locks/rocm-compilersupport.lock @@ -2,5 +2,5 @@ version = 1 import-commit = '878261eeebbede5f9f220522155fb1ccd8110df8' upstream-commit = '878261eeebbede5f9f220522155fb1ccd8110df8' -input-fingerprint = 'sha256:f9cc0fb681d6fdbc327ab3a6b4758b6cda917056d64d399c10e1121f5cc5ff0d' +input-fingerprint = 'sha256:cb296b2ad24bf5e1caecff75194d8040b8c80cfe2e2619eed83fea15f2da588a' resolution-input-hash = 'sha256:466421704711c4fd3c71f0b2ed715a0e61d49e3e26f3a2637fee755795849c8e' diff --git a/specs/r/rocm-compilersupport/rocm-compilersupport.azl.macros b/specs/r/rocm-compilersupport/rocm-compilersupport.azl.macros index bc741136bc9..d235e1c54e4 100644 --- a/specs/r/rocm-compilersupport/rocm-compilersupport.azl.macros +++ b/specs/r/rocm-compilersupport/rocm-compilersupport.azl.macros @@ -1,3 +1,3 @@ # Macros file automatically generated by azldev. # Do not edit manually; changes will be overwritten. -%azl_release 3 +%azl_release 4 diff --git a/specs/r/rocm-compilersupport/rocm-compilersupport.spec b/specs/r/rocm-compilersupport/rocm-compilersupport.spec index ce97802834b..4c269978e9f 100644 --- a/specs/r/rocm-compilersupport/rocm-compilersupport.spec +++ b/specs/r/rocm-compilersupport/rocm-compilersupport.spec @@ -463,6 +463,12 @@ popd build_stage1=$p/build-llvm +# AZL: drop the per-triple clang config inside the stage-1 build tree so +# every subsequent stage (stage-2 llvm, device-libs, comgr, hipcc) compiled +# by this clang finds the Azure Linux GCC toolchain at +# /usr/lib/gcc/%{_target_cpu}-%{_vendor}-linux/. +echo "--gcc-triple=%{_target_cpu}-%{_vendor}-linux" > $build_stage1/bin/%{llvm_triple}.cfg + %global llvmrocm_stage1_config \\\ -DCMAKE_AR=$build_stage1/bin/llvm-ar \\\ -DCMAKE_C_COMPILER=$build_stage1/bin/clang \\\ @@ -501,6 +507,12 @@ export LD_LIBRARY_PATH=$PWD/build-llvm-2/lib -DLLVM_TOOL_LIBCXX_BUILD=ON \ -DLLVM_ENABLE_PROJECTS=%{llvm_projects} \ -DLLVM_ENABLE_RUNTIMES=%{llvm_runtimes} + +# AZL: pre-stage the per-triple clang config inside build-llvm-2/bin so +# the LLVM runtimes sub-build can locate the Azure Linux GCC toolchain. +# The .cfg only needs to exist by the time clang is invoked. +mkdir -p $PWD/build-llvm-2/bin +echo "--gcc-triple=%{_target_cpu}-%{_vendor}-linux" > $PWD/build-llvm-2/bin/%{llvm_triple}.cfg %cmake_build -j ${JOBS} popd @@ -730,6 +742,13 @@ rm %{buildroot}%{_bindir}/hip*.pl %fdupes %{buildroot}%{_prefix} %endif + +# AZL: drop a per-triple clang config file next to the shipped rocm-llvm +# binaries so every clang/clang++/flang/clang-cl/clang-dxc invocation that +# uses the default (AZL) target triple can locate the GCC toolchain at +# /usr/lib/gcc/%{_target_cpu}-%{_vendor}-linux/. Cross-target invocations +# (--target=) do not match this filename and are unaffected. +echo "--gcc-triple=%{_target_cpu}-%{_vendor}-linux" > %{buildroot}%{bundle_prefix}/bin/%{llvm_triple}.cfg %files macros %{_rpmmacrodir}/macros.rocmcompiler @@ -982,6 +1001,7 @@ rm %{buildroot}%{_bindir}/hip*.pl %{bundle_prefix}/share/clang/* %{bundle_prefix}/share/clang-doc +%{bundle_prefix}/bin/%{llvm_triple}.cfg %files -n rocm-clang-devel %license clang/LICENSE.TXT %{bundle_prefix}/include/clang/*