Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
122 changes: 121 additions & 1 deletion base/comps/rocm-compilersupport/rocm-compilersupport.comp.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,123 @@
[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
# 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
# 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}"

[[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/<cpu>-azurelinux-linux/<ver>/.
# 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 <triple>.cfg next to the clang binaries with
# --gcc-triple=<azl-triple>. Clang's config-file lookup (clang/lib/Driver/Driver.cpp
# step 5) tries <triple>.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'''
Comment thread
christopherco marked this conversation as resolved.
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=<other>) 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 <triple>.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",
]
2 changes: 1 addition & 1 deletion locks/rocm-compilersupport.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
version = 1
import-commit = '878261eeebbede5f9f220522155fb1ccd8110df8'
upstream-commit = '878261eeebbede5f9f220522155fb1ccd8110df8'
input-fingerprint = 'sha256:85e674748ef2b244a89da353d8de60b5f64024025b9b7bb8db662555e85c0f60'
input-fingerprint = 'sha256:cb296b2ad24bf5e1caecff75194d8040b8c80cfe2e2619eed83fea15f2da588a'
resolution-input-hash = 'sha256:466421704711c4fd3c71f0b2ed715a0e61d49e3e26f3a2637fee755795849c8e'
3 changes: 3 additions & 0 deletions specs/r/rocm-compilersupport/rocm-compilersupport.azl.macros
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Macros file automatically generated by azldev.
# Do not edit manually; changes will be overwritten.
%azl_release 4
26 changes: 25 additions & 1 deletion specs/r/rocm-compilersupport/rocm-compilersupport.spec
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -459,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
Comment thread
christopherco marked this conversation as resolved.

%global llvmrocm_stage1_config \\\
-DCMAKE_AR=$build_stage1/bin/llvm-ar \\\
-DCMAKE_C_COMPILER=$build_stage1/bin/clang \\\
Expand Down Expand Up @@ -497,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
Comment on lines +511 to +515

%cmake_build -j ${JOBS}
popd
Expand Down Expand Up @@ -726,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=<other>) 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
Comment thread
christopherco marked this conversation as resolved.

Expand Down Expand Up @@ -978,6 +1001,7 @@ rm %{buildroot}%{_bindir}/hip*.pl
%{bundle_prefix}/share/clang/*
%{bundle_prefix}/share/clang-doc

%{bundle_prefix}/bin/%{llvm_triple}.cfg
Comment thread
christopherco marked this conversation as resolved.
%files -n rocm-clang-devel
%license clang/LICENSE.TXT
%{bundle_prefix}/include/clang/*
Expand Down
Loading