Use gcc-toolset-15 by default

Bring the latest changes from Rawhide, including the update of the GTS
version used.

Resolves: RHEL-130773
This commit is contained in:
Tulio Magno Quites Machado Filho 2025-12-22 16:46:14 -03:00
parent 5955389f54
commit 5adde6ea3a
6 changed files with 1632 additions and 59 deletions

View File

@ -1,48 +0,0 @@
From 10c38a8830c2c93b490b342596a2d286f4f21ae6 Mon Sep 17 00:00:00 2001
From: Tulio Magno Quites Machado Filho <tuliom@redhat.com>
Date: Wed, 29 Oct 2025 10:59:29 -0300
Subject: [PATCH] [BPF] Revert the behavior when handling traps
Commit ab391beb11f733b526b86f9df23734a34657d876 in LLVM 21 changed the
behavior of the BPF backend when handling traps in order to require
kfunc __bpf_trap. This kfunc is only available on Linux >= 6.16 via
commit f95695f2c46592b4260032736a9bfc6e2a01c77c.
RHEL 8 uses Linux 4.18, which means we can't adopt the new behavior
unless __bpf_trap is backported.
---
llvm/lib/Target/BPF/BPFTargetMachine.cpp | 3 ++-
llvm/test/CodeGen/BPF/BTF/unreachable.ll | 4 ++--
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/llvm/lib/Target/BPF/BPFTargetMachine.cpp b/llvm/lib/Target/BPF/BPFTargetMachine.cpp
index ad3df2c879fe..426facc74904 100644
--- a/llvm/lib/Target/BPF/BPFTargetMachine.cpp
+++ b/llvm/lib/Target/BPF/BPFTargetMachine.cpp
@@ -40,7 +40,8 @@ opt<bool> DisableMIPeephole("disable-bpf-peephole", cl::Hidden,
cl::desc("Disable machine peepholes for BPF"));
static cl::opt<bool>
- DisableCheckUnreachable("bpf-disable-trap-unreachable", cl::Hidden,
+ DisableCheckUnreachable("bpf-disable-trap-unreachable", cl::init(true),
+ cl::Hidden,
cl::desc("Disable Trap Unreachable for BPF"));
extern "C" LLVM_ABI LLVM_EXTERNAL_VISIBILITY void LLVMInitializeBPFTarget() {
diff --git a/llvm/test/CodeGen/BPF/BTF/unreachable.ll b/llvm/test/CodeGen/BPF/BTF/unreachable.ll
index 5f53a7445433..91bd94e8dc45 100644
--- a/llvm/test/CodeGen/BPF/BTF/unreachable.ll
+++ b/llvm/test/CodeGen/BPF/BTF/unreachable.ll
@@ -1,7 +1,7 @@
-; RUN: llc -mtriple=bpfel -mcpu=v3 -filetype=obj -o %t1 %s
+; RUN: llc -mtriple=bpfel -mcpu=v3 -filetype=obj -o %t1 -bpf-disable-trap-unreachable=0 %s
; RUN: llvm-objcopy --dump-section='.BTF'=%t2 %t1
; RUN: %python %p/print_btf.py %t2 | FileCheck -check-prefixes=CHECK-BTF %s
-; RUN: llc -mtriple=bpfel -mcpu=v3 < %s | FileCheck -check-prefixes=CHECK %s
+; RUN: llc -mtriple=bpfel -mcpu=v3 -bpf-disable-trap-unreachable=0 < %s | FileCheck -check-prefixes=CHECK %s
define void @foo() {
entry:
--
2.50.1

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,130 @@
From be4fa19ecf95d94d3ef46be183d3d4b4ebb6bb47 Mon Sep 17 00:00:00 2001
From: yonghong-song <yhs@fb.com>
Date: Mon, 3 Nov 2025 11:11:47 -0800
Subject: [PATCH] [BPF] Remove unused weak symbol __bpf_trap (#166003)
Nikita Popov reported an issue ([1]) where a dangling weak symbol
__bpf_trap is in the final binary and this caused libbpf failing like
below:
$ veristat -v ./t.o
Processing 't.o'...
libbpf: elf: skipping unrecognized data section(4) .eh_frame
libbpf: elf: skipping relo section(5) .rel.eh_frame for section(4) .eh_frame
libbpf: failed to find BTF for extern '__bpf_trap': -3
Failed to open './t.o': -3
In llvm, the dag selection phase generates __bpf_trap in code. Later the
UnreachableBlockElim pass removed __bpf_trap from the code, but
__bpf_trap symbol survives in the symbol table.
Having a dangling __bpf_trap weak symbol is not good for old kernels as
seen in the above veristat failure. Although users could use compiler
flag `-mllvm -bpf-disable-trap-unreachable` to workaround the issue,
this patch fixed the issue by removing the dangling __bpf_trap.
[1] https://github.com/llvm/llvm-project/issues/165696
(cherry picked from commit 8fd1bf2f8c9e6e7c4bc5f6915a9d52bb3672601b)
---
llvm/lib/Target/BPF/BPFAsmPrinter.cpp | 24 ++++++++++++++++++++
llvm/lib/Target/BPF/BPFAsmPrinter.h | 1 +
llvm/test/CodeGen/BPF/bpf_trap.ll | 32 +++++++++++++++++++++++++++
3 files changed, 57 insertions(+)
create mode 100644 llvm/test/CodeGen/BPF/bpf_trap.ll
diff --git a/llvm/lib/Target/BPF/BPFAsmPrinter.cpp b/llvm/lib/Target/BPF/BPFAsmPrinter.cpp
index 77dc4a75a7d6..b2a82040ee82 100644
--- a/llvm/lib/Target/BPF/BPFAsmPrinter.cpp
+++ b/llvm/lib/Target/BPF/BPFAsmPrinter.cpp
@@ -88,6 +88,16 @@ bool BPFAsmPrinter::doFinalization(Module &M) {
}
}
+ for (GlobalObject &GO : M.global_objects()) {
+ if (!GO.hasExternalWeakLinkage())
+ continue;
+
+ if (!SawTrapCall && GO.getName() == BPF_TRAP) {
+ GO.eraseFromParent();
+ break;
+ }
+ }
+
return AsmPrinter::doFinalization(M);
}
@@ -160,6 +170,20 @@ bool BPFAsmPrinter::PrintAsmMemoryOperand(const MachineInstr *MI,
}
void BPFAsmPrinter::emitInstruction(const MachineInstr *MI) {
+ if (MI->isCall()) {
+ for (const MachineOperand &Op : MI->operands()) {
+ if (Op.isGlobal()) {
+ if (const GlobalValue *GV = Op.getGlobal())
+ if (GV->getName() == BPF_TRAP)
+ SawTrapCall = true;
+ } else if (Op.isSymbol()) {
+ if (const MCSymbol *Sym = Op.getMCSymbol())
+ if (Sym->getName() == BPF_TRAP)
+ SawTrapCall = true;
+ }
+ }
+ }
+
BPF_MC::verifyInstructionPredicates(MI->getOpcode(),
getSubtargetInfo().getFeatureBits());
diff --git a/llvm/lib/Target/BPF/BPFAsmPrinter.h b/llvm/lib/Target/BPF/BPFAsmPrinter.h
index 0cfb2839c8ff..60a285ea2b7d 100644
--- a/llvm/lib/Target/BPF/BPFAsmPrinter.h
+++ b/llvm/lib/Target/BPF/BPFAsmPrinter.h
@@ -39,6 +39,7 @@ public:
private:
BTFDebug *BTF;
TargetMachine &TM;
+ bool SawTrapCall = false;
const BPFTargetMachine &getBTM() const;
};
diff --git a/llvm/test/CodeGen/BPF/bpf_trap.ll b/llvm/test/CodeGen/BPF/bpf_trap.ll
new file mode 100644
index 000000000000..ab8df5ff7cb0
--- /dev/null
+++ b/llvm/test/CodeGen/BPF/bpf_trap.ll
@@ -0,0 +1,32 @@
+; RUN: llc < %s | FileCheck %s
+;
+target triple = "bpf"
+
+define i32 @test(i8 %x) {
+entry:
+ %0 = and i8 %x, 3
+ switch i8 %0, label %default.unreachable4 [
+ i8 0, label %return
+ i8 1, label %sw.bb1
+ i8 2, label %sw.bb2
+ i8 3, label %sw.bb3
+ ]
+
+sw.bb1: ; preds = %entry
+ br label %return
+
+sw.bb2: ; preds = %entry
+ br label %return
+
+sw.bb3: ; preds = %entry
+ br label %return
+
+default.unreachable4: ; preds = %entry
+ unreachable
+
+return: ; preds = %entry, %sw.bb3, %sw.bb2, %sw.bb1
+ %retval.0 = phi i32 [ 12, %sw.bb1 ], [ 43, %sw.bb2 ], [ 54, %sw.bb3 ], [ 32, %entry ]
+ ret i32 %retval.0
+}
+
+; CHECK-NOT: __bpf_trap
--
2.50.1

View File

@ -0,0 +1,34 @@
From ac5b6151976c70c8b676d3bc6ff82895fe0e1d01 Mon Sep 17 00:00:00 2001
From: yonghong-song <yhs@fb.com>
Date: Tue, 4 Nov 2025 15:15:33 -0800
Subject: [PATCH] [BPF] Remove dead code related to __bpf_trap global var
(#166440)
In [1], the symbol __bpf_trap (macro BPF_TRAP) is removed if it is not
used in the code. In the discussion in [1], it is found that the branch
"if (Op.isSymbol())" is actually always false. Remove it to avoid
confusion.
[1] https://github.com/llvm/llvm-project/pull/166003
---
llvm/lib/Target/BPF/BPFAsmPrinter.cpp | 4 ----
1 file changed, 4 deletions(-)
diff --git a/llvm/lib/Target/BPF/BPFAsmPrinter.cpp b/llvm/lib/Target/BPF/BPFAsmPrinter.cpp
index 378a72ab27dd..abe081c0c76f 100644
--- a/llvm/lib/Target/BPF/BPFAsmPrinter.cpp
+++ b/llvm/lib/Target/BPF/BPFAsmPrinter.cpp
@@ -176,10 +176,6 @@ void BPFAsmPrinter::emitInstruction(const MachineInstr *MI) {
if (const GlobalValue *GV = Op.getGlobal())
if (GV->getName() == BPF_TRAP)
SawTrapCall = true;
- } else if (Op.isSymbol()) {
- if (const MCSymbol *Sym = Op.getMCSymbol())
- if (Sym->getName() == BPF_TRAP)
- SawTrapCall = true;
}
}
}
--
2.50.1

121
llvm.spec
View File

@ -2,7 +2,7 @@
#region version
%global maj_ver 21
%global min_ver 1
%global patch_ver 4
%global patch_ver 7
#global rc_ver rc3
%bcond_with snapshot_build
@ -19,6 +19,24 @@
%bcond_with gold
%endif
# Enable this in order to disable a lot of features and get to clang as fast
# as possible. This is useful in order to bisect issues affecting LLVM, clang
# or LLD.
%bcond_with fastclang
%if %{with fastclang}
%define bcond_override_default_lldb 0
%define bcond_override_default_offload 0
%define bcond_override_default_mlir 0
%define bcond_override_default_flang 0
%define bcond_override_default_build_bolt 0
%define bcond_override_default_polly 0
%define bcond_override_default_pgo 0
%define bcond_override_default_libcxx 0
%define bcond_override_default_lto_build 0
%define bcond_override_default_check 0
%define _find_debuginfo_dwz_opts %{nil}
%endif
# Build compat packages llvmN instead of main package for the current LLVM
# version. Used on Fedora.
%bcond_with compat_build
@ -236,8 +254,10 @@ end
%global __cxx /usr/bin/clang++-%{host_clang_maj_ver}
%endif
%if %{defined rhel} && 0%{?rhel} < 10
%global gts_version 14
# The upper bound must remain and never exceed the latest RHEL version with GTS,
# so that this does not apply to ELN or a brand new RHEL version.
%if %{defined rhel} && 0%{?rhel} <= 10
%global gts_version 15
%endif
%if %{defined rhel} && 0%{?rhel} <= 8
@ -493,9 +513,13 @@ Patch2202: 0001-22-polly-shared-libs.patch
#region RHEL patches
# RHEL 8 only
Patch501: 0001-Fix-page-size-constant-on-aarch64-and-ppc64le.patch
# Ensure that the BPF backend does not require kfunc __bpf_trap which is not
# available on RHEL 8.
Patch502: 0001-BPF-Revert-the-behavior-when-handling-traps.patch
# Backport a fix for https://github.com/llvm/llvm-project/issues/165696 from
# LLVM 22. The first patch is a requirement of the second patch.
# Apply the fix to RHEL8 only because the other distros do not need this fix
# because they already support kfunc __bpf_trap.
Patch502: 0001-BPF-Support-Jump-Table-149715.patch
Patch503: 0002-BPF-Remove-unused-weak-symbol-__bpf_trap-166003.patch
Patch504: 0003-BPF-Remove-dead-code-related-to-__bpf_trap-global-va.patch
#endregion RHEL patches
# Fix a pgo miscompilation triggered by building Rust 1.87 with pgo on ppc64le.
@ -523,6 +547,13 @@ Patch2201: 0001-clang-Add-a-hack-to-fix-the-offload-build-with-the-m.patch
%global __python3 /usr/bin/python3.12
%endif
%if %{with fastclang}
# fastclang depends on overriding default conditionals via
# bcond_override_default which is only available on RPM 4.20 and newer.
# More info:
# https://rpm-software-management.github.io/rpm/manual/conditionalbuilds.html#overriding-defaults
BuildRequires: rpm >= 4.20
%endif
%if %{defined gts_version}
# Required for 64-bit atomics on i686.
BuildRequires: gcc-toolset-%{gts_version}-libatomic-devel
@ -568,6 +599,10 @@ BuildRequires: python3-scipy
%endif
%endif
%else
%if %{with use_lld}
BuildRequires: lld
%endif
%endif
# This intentionally does not use python3_pkgversion. RHEL 8 does not have
@ -834,7 +869,11 @@ Requires: gcc-toolset-%{gts_version}-gcc-c++
Recommends: %{pkg_name_compiler_rt}%{?_isa} = %{version}-%{release}
Requires: %{pkg_name_llvm}-libs = %{version}-%{release}
# atomic support is not part of compiler-rt
%if %{defined gts_version}
Recommends: gcc-toolset-%{gts_version}-libatomic-devel
%else
Recommends: libatomic%{?_isa}
%endif
# libomp-devel is required, so clang can find the omp.h header when compiling
# with -fopenmp.
Recommends: %{pkg_name_libomp}-devel%{_isa} = %{version}-%{release}
@ -1305,7 +1344,12 @@ Flang runtime libraries.
%if %{defined rhel} && 0%{?rhel} == 8
%patch -p1 -P501
%if %{maj_ver} < 22
# The following patches have been backported from LLVM 22.
%patch -p1 -P502
%patch -p1 -P503
%patch -p1 -P504
%endif
%endif
#region LLVM preparation
@ -1375,7 +1419,7 @@ cd llvm/utils/lit
%ifarch %ix86
%global reduce_debuginfo 1
%endif
%if 0%{?rhel} == 8
%if 0%{?rhel} == 8 || %{with fastclang}
%global reduce_debuginfo 1
%endif
@ -1416,7 +1460,10 @@ cd llvm/utils/lit
%global runtimes %{runtimes};offload
%endif
%global cfg_file_content --gcc-triple=%{_target_cpu}-redhat-linux
%global gcc_triple --gcc-triple=%{_target_cpu}-redhat-linux
%global cfg_file_content %{gcc_triple}
%global cfg_file_content_flang %{gcc_triple}
# We want to use DWARF-5 on all snapshot builds.
%if %{without snapshot_build} && %{defined rhel} && 0%{?rhel} < 10
@ -2335,6 +2382,7 @@ rm -v %{buildroot}%{install_libdir}/libFIRAnalysis.a \
%{buildroot}%{install_libdir}/libFortranDecimal.a
%if %{maj_ver} >= 22
rm -v %{buildroot}%{install_libdir}/libFortranUtils.a \
%{buildroot}%{install_libdir}/libFIROpenACCAnalysis.a \
%{buildroot}%{install_libdir}/libFIROpenACCTransforms.a \
%{buildroot}%{install_libdir}/libMIFDialect.a
%endif
@ -2343,6 +2391,14 @@ find %{buildroot}%{install_includedir}/flang -type f -a ! -iname '*.mod' -delete
# this is a test binary
rm -v %{buildroot}%{install_bindir}/f18-parse-demo
# Probably this directory already existed before
mkdir -pv %{buildroot}%{_sysconfdir}/%{pkg_name_clang}/
echo " %{cfg_file_content_flang}" >> %{buildroot}%{_sysconfdir}/%{pkg_name_clang}/%{_target_platform}-flang.cfg
%ifarch x86_64
# On x86_64, install an additional config file.
echo " %{cfg_file_content_flang}" >> %{buildroot}%{_sysconfdir}/%{pkg_name_clang}/i386-redhat-linux-gnu-flang.cfg
%endif
%endif
#endregion flang installation
@ -2454,6 +2510,17 @@ install -m 0755 ../llvm-compat-libs/lib/liblldb.so.%{compat_maj_ver}* %{buildroo
# TODO(kkleine): Instead of deleting test files we should mark them as expected
# to fail. See https://llvm.org/docs/CommandGuide/lit.html#cmdoption-lit-xfail
# Tell if the GTS version used by the newly built clang is equal to the
# expected version.
function is_gts_equal {
local gts_used=$(`pwd`/%{_vpath_builddir}/bin/clang -v 2>&1 | grep "Selected GCC installation" | sed 's|.*/\([0-9]\+\)$|\1|')
if [[ -z "%{gts_version}" ]]; then
return 0
fi
test "x$gts_used" = "x%{gts_version}"
return $?
}
# Increase open file limit while running tests.
if [[ $(ulimit -n) -lt 10000 ]]; then
ulimit -n 10000
@ -2755,7 +2822,16 @@ export LD_LIBRARY_PATH=%{buildroot}%{_prefix}/lib/clang/%{maj_ver}/lib/%{llvm_tr
%if 0%{?rhel}
# libomp tests are often very slow on s390x brew builders
%ifnarch s390x riscv64
%cmake_build --target check-openmp
# Rarely, the system clang uses a GCC installation directory that is
# different from what we'd like to build with.
# Our newly built clang ends up using that old GCC because of the config
# files under /etc/clang pointing to the old GCC. We won't be able to run all
# tests because the installed libatomic cannot be found due to our newly built
# clang using the wrong GCC directory, e.g. we installed the libatomic from
# the latest GTS, but the installed GCC is 1 version earlier.
if is_gts_equal; then
%cmake_build --target check-openmp
fi
%endif
%else
%cmake_build --target check-openmp
@ -3252,6 +3328,11 @@ fi
llvm-opt-fuzzer
llvm-test-mustache-spec
}}
%if %{maj_ver} >= 22
%{expand_bins %{expand:
llvm-cas
}}
%endif
%{expand_mans %{expand:
llvm-test-mustache-spec
}}
@ -3458,6 +3539,11 @@ fi
%ifnarch %{ix86} s390x riscv64
%{_prefix}/lib/clang/%{maj_ver}/lib/%{compiler_rt_triple}/liborc_rt.a
%endif
%ifarch s390x
%if %{maj_ver} >= 22
%{_prefix}/lib/clang/%{maj_ver}/lib/%{compiler_rt_triple}/liborc_rt.a
%endif
%endif
# Additional symlink if two triples are in use.
%if "%{llvm_triple}" != "%{compiler_rt_triple}"
@ -3611,6 +3697,12 @@ fi
libMLIR*.so.%{maj_ver}*
}}
%if %{maj_ver} >= 22
%{expand_libs %{expand:
libmlir_apfloat_wrappers.so.%{maj_ver}*
}}
%endif
%files -n %{pkg_name_mlir}-static
%expand_libs libMLIR*.a
@ -3642,6 +3734,12 @@ fi
libMLIR*.so
}}
%if %{maj_ver} >= 22
%{expand_libs %{expand:
libmlir_apfloat_wrappers.so
}}
%endif
%files -n python%{python3_pkgversion}-%{pkg_name_mlir}
%{python3_sitearch}/mlir/
%endif
@ -3682,7 +3780,12 @@ fi
flang/iso_fortran_env_impl.mod
flang/omp_lib.mod
flang/omp_lib_kinds.mod
flang/flang_debug.mod
}}
%{_sysconfdir}/%{pkg_name_clang}/%{_target_platform}-flang.cfg
%ifarch x86_64
%{_sysconfdir}/%{pkg_name_clang}/i386-redhat-linux-gnu-flang.cfg
%endif
%{_prefix}/lib/clang/%{maj_ver}/include/ISO_Fortran_binding.h

View File

@ -1,4 +1,4 @@
SHA512 (llvm-project-21.1.4.src.tar.xz) = a8c0883abe7c5a3e55ca7ed0fd974fae4351184a0b0df18295a982ca8ddb0f8d167353564204ed00f0cd9a1d8baef7074c0b39a99e0b5c52ced6bbee73dde3da
SHA512 (llvm-project-21.1.4.src.tar.xz.sig) = 4812c2e3861aa3b726d842c3ca259b19ef1aa531fed9f6f47099483de91de2b2a165f40d243f6f40f2eea749741d5f8b7090f394399c56db02053f308921077a
SHA512 (llvm-project-20.1.8.src.tar.xz) = f330e72e6a1da468569049437cc0ba7a41abb816ccece7367189344f7ebfef730f4788ac7af2bef0aa8a49341c15ab1d31e941ffa782f264d11fe0dc05470773
SHA512 (llvm-project-20.1.8.src.tar.xz.sig) = d74369bdb4d1b82775161ea53c9c5f3a23ce810f4df5ff617123023f9d8ce720e7d6ecc9e17f8ebd39fd9e7a9de79560abdf2ffe73bcb907a43148d43665d619
SHA512 (llvm-project-21.1.7.src.tar.xz) = ae30a53ed929df979849f7433bf705bc3d540aa9e12a02a175eb2483d1a56f9ca1203c9b67795f6e84cf2407c28d46d5d5351b290d8735adb5206103fee6f379
SHA512 (llvm-project-21.1.7.src.tar.xz.sig) = d02b09c77abd537eb24d6d43470f962c80a9ec6ccc03ac0efc950d90dbdec5b94dd6abad18143890ff85cee2bdeb7bcf1dac2a576ffcab8ef053d8526417bdcc