-
Notifications
You must be signed in to change notification settings - Fork 650
Expand file tree
/
Copy pathrocm-compilersupport.comp.toml
More file actions
123 lines (115 loc) · 6.8 KB
/
rocm-compilersupport.comp.toml
File metadata and controls
123 lines (115 loc) · 6.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
[components.rocm-compilersupport]
# 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'''
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",
]