Update to 21.1.7

Relates: RHEL-130780
[DEV Task]: [RHEL9.8] Remove offload libraries from ppc64le

Relates: RHEL-130783
[DEV Task]: clang use gcc-toolset-15 by default [rhel-9]

Resolves: RHEL-108352
clang use gcc-toolset-15 by default [rhel-9]

Resolves: RHEL-92552
[RHEL9.8] Remove offload libraries from ppc64le
This commit is contained in:
Konrad Kleine 2025-12-09 09:00:18 +00:00
parent 9cb7e1045d
commit c6b19a3c95
6 changed files with 1900 additions and 114 deletions

1
.gitignore vendored
View File

@ -12,3 +12,4 @@
/BUILDROOT
/out
/version.spec.inc
/.gdbinit

File diff suppressed because it is too large Load Diff

View File

@ -1,81 +0,0 @@
From 6d5697f7cb4e933d2f176c46b7ac05a9cbaeb8b6 Mon Sep 17 00:00:00 2001
From: Ulrich Weigand <ulrich.weigand@de.ibm.com>
Date: Thu, 23 Jan 2025 19:11:18 +0100
Subject: [PATCH] [SystemZ] Fix ICE with i128->i64 uaddo carry chain
We can only optimize a uaddo_carry via specialized instruction
if the carry was produced by another uaddo(_carry) instruction;
there is already a check for that.
However, i128 uaddo(_carry) use a completely different mechanism;
they indicate carry in a vector register instead of the CC flag.
Thus, we must also check that we don't mix those two - that check
has been missing.
Fixes: https://github.com/llvm/llvm-project/issues/124001
---
.../Target/SystemZ/SystemZISelLowering.cpp | 12 ++++++----
llvm/test/CodeGen/SystemZ/pr124001.ll | 23 +++++++++++++++++++
2 files changed, 31 insertions(+), 4 deletions(-)
create mode 100644 llvm/test/CodeGen/SystemZ/pr124001.ll
diff --git a/llvm/lib/Target/SystemZ/SystemZISelLowering.cpp b/llvm/lib/Target/SystemZ/SystemZISelLowering.cpp
index 4040ab6d4510..1fb31c26e20d 100644
--- a/llvm/lib/Target/SystemZ/SystemZISelLowering.cpp
+++ b/llvm/lib/Target/SystemZ/SystemZISelLowering.cpp
@@ -4708,15 +4708,19 @@ SDValue SystemZTargetLowering::lowerXALUO(SDValue Op,
}
static bool isAddCarryChain(SDValue Carry) {
- while (Carry.getOpcode() == ISD::UADDO_CARRY)
+ while (Carry.getOpcode() == ISD::UADDO_CARRY &&
+ Carry->getValueType(0) != MVT::i128)
Carry = Carry.getOperand(2);
- return Carry.getOpcode() == ISD::UADDO;
+ return Carry.getOpcode() == ISD::UADDO &&
+ Carry->getValueType(0) != MVT::i128;
}
static bool isSubBorrowChain(SDValue Carry) {
- while (Carry.getOpcode() == ISD::USUBO_CARRY)
+ while (Carry.getOpcode() == ISD::USUBO_CARRY &&
+ Carry->getValueType(0) != MVT::i128)
Carry = Carry.getOperand(2);
- return Carry.getOpcode() == ISD::USUBO;
+ return Carry.getOpcode() == ISD::USUBO &&
+ Carry->getValueType(0) != MVT::i128;
}
// Lower UADDO_CARRY/USUBO_CARRY nodes.
diff --git a/llvm/test/CodeGen/SystemZ/pr124001.ll b/llvm/test/CodeGen/SystemZ/pr124001.ll
new file mode 100644
index 000000000000..9cf630a55dd6
--- /dev/null
+++ b/llvm/test/CodeGen/SystemZ/pr124001.ll
@@ -0,0 +1,23 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
+; RUN: llc < %s -mtriple=s390x-linux-gnu -mcpu=z13 | FileCheck %s
+
+define i64 @test(i128 %in) {
+; CHECK-LABEL: test:
+; CHECK: # %bb.0:
+; CHECK-NEXT: larl %r1, .LCPI0_0
+; CHECK-NEXT: vl %v0, 0(%r2), 3
+; CHECK-NEXT: vl %v1, 0(%r1), 3
+; CHECK-NEXT: vaccq %v0, %v0, %v1
+; CHECK-NEXT: vlgvg %r1, %v0, 1
+; CHECK-NEXT: la %r2, 1(%r1)
+; CHECK-NEXT: br %r14
+ %1 = tail call { i128, i1 } @llvm.uadd.with.overflow.i128(i128 %in, i128 1)
+ %2 = extractvalue { i128, i1 } %1, 1
+ %3 = zext i1 %2 to i64
+ %4 = add i64 %3, 1
+ ret i64 %4
+}
+
+declare { i128, i1 } @llvm.uadd.with.overflow.i128(i128, i128) #0
+
+attributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
--
2.48.1

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

444
llvm.spec
View File

@ -2,7 +2,7 @@
#region version
%global maj_ver 21
%global min_ver 1
%global patch_ver 3
%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
@ -49,16 +67,18 @@
%else
%bcond_without offload
%endif
%elifarch %{ix86}
%else
%ifarch %{ix86}
# libomptarget is not supported on 32-bit systems.
%bcond_with offload
%else
%bcond_without offload
%endif
%endif
# MLIR version 22 started to require nanobind >= 2.9, which is only available
# on Fedora >= 44.
%if %{without compat_build} && ((%{maj_ver} >= 22 && 0%{?fedora} >= 44) || (%{maj_ver} < 22 && 0%{?fedora} >= 41))
%if %{without compat_build} && %{defined fedora} && (%{maj_ver} < 22 || 0%{?fedora} >= 44)
%ifarch %{ix86}
%bcond_with mlir
%else
@ -68,10 +88,69 @@
%bcond_with mlir
%endif
#region flang
%if %{without compat_build} && %{defined fedora} && (%{maj_ver} >= 22 && 0%{?fedora} >= 44)
# Link error on i686.
# s390x is not supported upstream yet.
%ifarch i686 s390x
%bcond_with flang
%else
%bcond_without flang
%endif
%endif
%if %{with flang}
# Sanity check for flang
# flang depends on mlir, clang, flang, openmp.
# Make sure those are being built.
%if %{without mlir}
%{error:flang must be built --with=mlir}
%endif
# Set Fortran build flags to nil because they contain flags that don't apply to flang.
%global build_fflags %{nil}
%{lua:
-- Return the maximum number of parallel jobs a build can run based on the
-- amount of maximum memory used per process (per_proc_mem).
function print_max_procs(per_proc_mem)
local f = io.open("/proc/meminfo", "r")
local mem = 0
local nproc_str = nil
for line in f:lines() do
_, _, mem = string.find(line, "MemTotal:%s+(%d+)%s+kB")
if mem then
break
end
end
f:close()
local proc_handle = io.popen("nproc")
_, _, nproc_str = string.find(proc_handle:read("*a"), "(%d+)")
proc_handle:close()
local nproc = tonumber(nproc_str)
if nproc < 1 then
nproc = 1
end
local mem_mb = mem / 1024
local cpu = math.floor(mem_mb / per_proc_mem)
if cpu < 1 then
cpu = 1
end
if cpu > nproc then
cpu = nproc
end
print(cpu)
end
}
%endif
#endregion flang
# The libcxx build condition also enables libcxxabi and libunwind.
# Fedora 41 is the first version that enabled FatLTO for clang-built files.
# Without FatLTO, we can't enable ThinLTO and link using GNU LD.
%if %{without compat_build} && 0%{?fedora} >= 41
%if %{without compat_build} && %{defined fedora}
%bcond_without libcxx
%else
%bcond_with libcxx
@ -79,7 +158,7 @@
# I've called the build condition "build_bolt" to indicate that this does not
# necessarily "use" BOLT in order to build LLVM.
%if %{without compat_build} && 0%{?fedora} >= 41
%if %{without compat_build} && %{defined fedora}
# BOLT only supports aarch64 and x86_64
%ifarch aarch64 x86_64
%bcond_without build_bolt
@ -90,7 +169,7 @@
%bcond_with build_bolt
%endif
%if %{without compat_build} && 0%{?fedora} >= 41
%if %{without compat_build} && %{defined fedora}
%bcond_without polly
%else
%bcond_with polly
@ -131,8 +210,24 @@
%ifarch %ix86 riscv64
%bcond_with lto_build
%else
%if %{defined rhel} && 0%{?rhel} <= 8
# LTO builds got enabled on Fedora and RHEL >= 9 only.
%bcond_with lto_build
%else
%bcond_without lto_build
%endif
%endif
# Historically, LLD was used used at the same combinations that enabled PGO.
# If this changes, we need to update the following lines.
# However, we should be able to link using LLD even if PGO is disabled.
# Reminder: RHEL8 still builds with gcc + ld.bfd.
%if %{with pgo}
%bcond_without use_lld
%else
# RHEL8 still builds with gcc + ld.bfd.
%bcond_with use_lld
%endif
# For PGO Disable LTO for now because of LLVMgold.so not found error
# Use LLVM_ENABLE_LTO:BOOL=ON flags to enable LTO instead
@ -142,6 +237,7 @@
# We are building with clang for faster/lower memory LTO builds.
# See https://docs.fedoraproject.org/en-US/packaging-guidelines/#_compiler_macros
# Reminder: This only works on Fedora and RHEL >= 9.
%global toolchain clang
# Make sure that we are not building with a newer compiler than the targeted
@ -158,8 +254,10 @@
%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
@ -314,6 +412,10 @@
%endif
#endregion PGO globals
#region flang globals
%global pkg_name_flang flang%{pkg_suffix}
#endregion flang globals
#endregion globals
#region packages
@ -411,6 +513,12 @@ Patch2202: 0001-22-polly-shared-libs.patch
#region RHEL patches
# RHEL 8 only
Patch501: 0001-Fix-page-size-constant-on-aarch64-and-ppc64le.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
#endregion RHEL patches
# Fix a pgo miscompilation triggered by building Rust 1.87 with pgo on ppc64le.
@ -438,6 +546,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
@ -483,6 +598,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
@ -571,7 +690,7 @@ BuildRequires: procps-ng
# For reproducible pyc file generation
# See https://docs.fedoraproject.org/en-US/packaging-guidelines/Python_Appendix/#_byte_compilation_reproducibility
# Since Fedora 41 this happens automatically, and RHEL 8 does not support this.
%if %{without compat_build} && ((%{defined fedora} && 0%{?fedora} < 41) || 0%{?rhel} == 9 || 0%{?rhel} == 10)
%if %{without compat_build} && (0%{?rhel} == 9 || 0%{?rhel} == 10)
BuildRequires: /usr/bin/marshalparser
%global py_reproducible_pyc_path %{buildroot}%{python3_sitelib}
%endif
@ -749,7 +868,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}
@ -1146,6 +1269,42 @@ Polly header files.
%endif
#endregion polly packages
#region flang packages
%if %{with flang}
%package -n %{pkg_name_flang}
Summary: a Fortran language front-end designed for integration with LLVM
Requires: %{pkg_name_flang}-runtime%{?_isa} = %{version}-%{release}
# flang installs headers in the clang resource directory
Requires: %{pkg_name_clang}-resource-filesystem%{?_isa} = %{version}-%{release}
# flang implicitly calls ld.bfd when linking and depends on the gcc runtime objects.
Requires: binutils
Requires: gcc
# Up to version 17.0.6-1, flang used to provide a flang-devel package.
# This changed in 17.0.6-2 and all development-related files are now
# distributed in the main flang package.
Obsoletes: %{pkg_name_flang}-devel < 17.0.6-2
# We no longer ship flang-doc.
Obsoletes: %{pkg_name_flang}-doc < 22
License: Apache-2.0 WITH LLVM-exception
URL: https://flang.llvm.org
%description -n %{pkg_name_flang}
Flang is a ground-up implementation of a Fortran front end written in modern
C++.
%package -n %{pkg_name_flang}-runtime
Summary: Flang runtime libraries
Conflicts: %{pkg_name_flang} < 17.0.6-2
%description -n %{pkg_name_flang}-runtime
Flang runtime libraries.
%endif
#endregion flang packages
#endregion packages
#region prep
@ -1184,6 +1343,11 @@ Polly header files.
%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
%endif
%endif
#region LLVM preparation
@ -1253,7 +1417,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
@ -1281,6 +1445,11 @@ cd llvm/utils/lit
%global projects %{projects};polly
%endif
%if %{with flang}
%global projects %{projects};flang
%global runtimes %{runtimes};flang-rt
%endif
%if %{with libcxx}
%global runtimes %{runtimes};libcxx;libcxxabi;libunwind
%endif
@ -1289,7 +1458,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
@ -1373,6 +1545,11 @@ popd
-DLLVM_ENABLE_EH=ON
%endif
%if %reduce_debuginfo == 1
%global cmake_common_args %{cmake_common_args} -DCMAKE_C_FLAGS_RELWITHDEBINFO="%{optflags} -DNDEBUG"
%global cmake_common_args %{cmake_common_args} -DCMAKE_CXX_FLAGS_RELWITHDEBINFO="%{optflags} -DNDEBUG"
%endif
%global cmake_config_args %{cmake_common_args}
#region clang options
@ -1401,7 +1578,8 @@ popd
#region compiler-rt options
%global cmake_config_args %{cmake_config_args} \\\
-DCOMPILER_RT_INCLUDE_TESTS:BOOL=OFF \\\
-DCOMPILER_RT_INSTALL_PATH=%{_prefix}/lib/clang/%{maj_ver}
-DCOMPILER_RT_INSTALL_PATH=%{_prefix}/lib/clang/%{maj_ver} \\\
-DLLVM_BUILD_EXTERNAL_COMPILER_RT:BOOL=ON
#endregion compiler-rt options
#region docs options
@ -1469,7 +1647,6 @@ popd
%global cmake_config_args %{cmake_config_args} \\\
-DLLVM_APPEND_VC_REV:BOOL=OFF \\\
-DLLVM_BUILD_EXAMPLES:BOOL=OFF \\\
-DLLVM_BUILD_EXTERNAL_COMPILER_RT:BOOL=ON \\\
-DLLVM_BUILD_RUNTIME:BOOL=ON \\\
-DLLVM_BUILD_TOOLS:BOOL=ON \\\
-DLLVM_BUILD_UTILS:BOOL=ON \\\
@ -1502,6 +1679,7 @@ popd
-DMLIR_INSTALL_AGGREGATE_OBJECTS=OFF \\\
-DMLIR_BUILD_MLIR_C_DYLIB=ON \\\
-DMLIR_ENABLE_BINDINGS_PYTHON:BOOL=ON
%endif
#endregion mlir options
@ -1538,6 +1716,23 @@ popd
%endif
#endregion polly options
#region flang options
%if %{with flang}
%global cmake_config_args %{cmake_config_args} \\\
-DFLANG_INCLUDE_DOCS:BOOL=ON
# Build both, shared and static flang runtime objects.
# See also https://llvm.org/devmtg/2025-04/slides/quick_talk/kruse_flang-rt.pdf
%global cmake_config_args %{cmake_config_args} \\\
-DFLANG_RT_ENABLE_SHARED:BOOL=ON \\\
-DFLANG_RT_ENABLE_STATIC:BOOL=ON
# The amount of RAM used per process has been set by trial and error.
# This number may increase/decrease from time to time and may require changes.
# We prefer to be on the safe side in order to avoid spurious errors.
%global cmake_config_args %{cmake_config_args} \\\
-DFLANG_PARALLEL_COMPILE_JOBS=%{lua: print_max_procs(3072)}
%endif
#endregion flang options
#region test options
%global cmake_config_args %{cmake_config_args} \\\
@ -1547,11 +1742,7 @@ popd
-DLLVM_LIT_ARGS="-vv"
%if %{with lto_build}
%if 0%{?fedora} >= 41
%global cmake_config_args %{cmake_config_args} -DLLVM_UNITTEST_LINK_FLAGS="-fno-lto"
%else
%global cmake_config_args %{cmake_config_args} -DLLVM_UNITTEST_LINK_FLAGS="-Wl,-plugin-opt=O0"
%endif
%endif
#endregion test options
@ -1579,11 +1770,6 @@ popd
%global cmake_config_args %{cmake_config_args} -DPPC_LINUX_DEFAULT_IEEELONGDOUBLE=ON
%endif
%if %reduce_debuginfo == 1
%global cmake_config_args %{cmake_config_args} -DCMAKE_C_FLAGS_RELWITHDEBINFO="%{optflags} -DNDEBUG"
%global cmake_config_args %{cmake_config_args} -DCMAKE_CXX_FLAGS_RELWITHDEBINFO="%{optflags} -DNDEBUG"
%endif
%if 0%{?__isa_bits} == 64
%global cmake_config_args %{cmake_config_args} -DLLVM_LIBDIR_SUFFIX=64
%endif
@ -1609,7 +1795,11 @@ popd
# This option uses the NUMBER_OF_LOGICAL_CORES query in CMake which doesn't
# work on s390x.
# https://gitlab.kitware.com/cmake/cmake/-/issues/26619
%global cmake_config_args %{cmake_config_args} -DLLVM_RAM_PER_COMPILE_JOB=2048
# The value 4096 was used after we've seen cases of memory exhaustion on a
# system with 64GiB RAM and 16 jobs. It worked a few times after applied,
# but we can't guarantee it's enough. It's important to remember that RHEL8
# uses GCC. This value should not be applied to a build using clang.
%global cmake_config_args %{cmake_config_args} -DLLVM_RAM_PER_COMPILE_JOB=4096
%endif
%endif
#endregion misc options
@ -1731,11 +1921,15 @@ cd $OLD_CWD
# LLVM_VP_COUNTERS_PER_SITE instead of adding it, hence the
# -DLLVM_VP_COUNTERS_PER_SITE=8.
%global extra_cmake_opts %{extra_cmake_opts} -DLLVM_VP_COUNTERS_PER_SITE=8
%endif
%if 0%{with lto_build}
%global extra_cmake_opts %{extra_cmake_opts} -DLLVM_ENABLE_LTO:BOOL=Thin
%global extra_cmake_opts %{extra_cmake_opts} -DLLVM_ENABLE_FATLTO=ON
%endif
%global extra_cmake_opts %{extra_cmake_opts} -DLLVM_USE_LINKER=lld
%if 0%{with use_lld}
%global extra_cmake_opts %{extra_cmake_opts} -DLLVM_USE_LINKER=lld
%endif
%cmake -G Ninja %{cmake_config_args} %{extra_cmake_opts} $extra_cmake_args
@ -1887,6 +2081,14 @@ popd
%cmake_install
%if %{with flang}
# Create ld.so.conf.d entry
mkdir -p %{buildroot}%{_sysconfdir}/ld.so.conf.d
cat >> %{buildroot}%{_sysconfdir}/ld.so.conf.d/%{pkg_name_flang}-%{_arch}.conf << EOF
%{_prefix}/lib/clang/%{maj_ver}/lib/%{llvm_triple}/
EOF
%endif
popd
mkdir -p %{buildroot}/%{_bindir}
@ -2066,7 +2268,8 @@ echo " %{cfg_file_content}" >> %{buildroot}%{_sysconfdir}/%{pkg_name_clang}/i386
%ifarch ppc64le
# Fix install path on ppc64le so that the directory name matches the triple used
# by clang.
mv %{buildroot}%{_prefix}/lib/clang/%{maj_ver}/lib/powerpc64le-redhat-linux-gnu %{buildroot}%{_prefix}/lib/clang/%{maj_ver}/lib/%{llvm_triple}
mkdir -pv %{buildroot}%{_prefix}/lib/clang/%{maj_ver}/lib/%{llvm_triple}
mv %{buildroot}%{_prefix}/lib/clang/%{maj_ver}/lib/powerpc64le-redhat-linux-gnu/* %{buildroot}%{_prefix}/lib/clang/%{maj_ver}/lib/%{llvm_triple}
%endif
%ifarch %{ix86}
@ -2141,6 +2344,62 @@ rm -rf %{buildroot}%{install_prefix}/src/python
%endif
#endregion mlir installation
#region flang installation
%if %{with flang}
# Remove unnecessary files.
rm -rfv %{buildroot}%{install_libdir}/cmake/flang
# Remove runtime development headers (see https://github.com/llvm/llvm-project/pull/165610)
rm -rfv %{buildroot}%{install_includedir}/flang-rt
rm -v %{buildroot}%{install_libdir}/libFIRAnalysis.a \
%{buildroot}%{install_libdir}/libFIRBuilder.a \
%{buildroot}%{install_libdir}/libFIRCodeGen.a \
%{buildroot}%{install_libdir}/libFIRCodeGenDialect.a \
%{buildroot}%{install_libdir}/libFIRDialect.a \
%{buildroot}%{install_libdir}/libFIRDialectSupport.a \
%{buildroot}%{install_libdir}/libFIROpenACCSupport.a \
%{buildroot}%{install_libdir}/libFIROpenMPSupport.a \
%{buildroot}%{install_libdir}/libFIRSupport.a \
%{buildroot}%{install_libdir}/libFIRTestAnalysis.a \
%{buildroot}%{install_libdir}/libFIRTestOpenACCInterfaces.a \
%{buildroot}%{install_libdir}/libFIRTransforms.a \
%{buildroot}%{install_libdir}/libflangFrontend.a \
%{buildroot}%{install_libdir}/libflangFrontendTool.a \
%{buildroot}%{install_libdir}/libflangPasses.a \
%{buildroot}%{install_libdir}/libFlangOpenMPTransforms.a \
%{buildroot}%{install_libdir}/libFortranEvaluate.a \
%{buildroot}%{install_libdir}/libFortranLower.a \
%{buildroot}%{install_libdir}/libFortranParser.a \
%{buildroot}%{install_libdir}/libFortranSemantics.a \
%{buildroot}%{install_libdir}/libFortranSupport.a \
%{buildroot}%{install_libdir}/libHLFIRDialect.a \
%{buildroot}%{install_libdir}/libHLFIRTransforms.a \
%{buildroot}%{install_libdir}/libCUFAttrs.a \
%{buildroot}%{install_libdir}/libCUFDialect.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
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
#region libcxx installation
%if %{with libcxx}
# We can't install the unversionned path on default location because that would conflict with
@ -2195,14 +2454,14 @@ move_and_replace_with_symlinks %{buildroot}%{install_datadir} %{buildroot}%{_dat
mkdir -p %{buildroot}%{_bindir}
for f in %{buildroot}%{install_bindir}/*; do
filename=`basename $f`
if [[ "$filename" =~ ^(lit|ld|clang-%{maj_ver})$ ]]; then
if [[ "$filename" =~ ^(lit|ld|clang-%{maj_ver}|flang-%{maj_ver})$ ]]; then
continue
fi
%if %{with compat_build}
ln -s ../../%{install_bindir}/$filename %{buildroot}/%{_bindir}/$filename-%{maj_ver}
%else
# clang-NN is already created by the build system.
if [[ "$filename" == "clang" ]]; then
# clang-NN and flang-NN are already created by the build system.
if [[ "$filename" =~ ^(clang|flang)$ ]]; then
continue
fi
ln -s $filename %{buildroot}/%{_bindir}/$filename-%{maj_ver}
@ -2249,6 +2508,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
@ -2357,6 +2627,7 @@ export LIT_XFAIL="tools/UpdateTestChecks"
#region Test CLANG
reset_test_opts
export LIT_XFAIL="$LIT_XFAIL;clang/test/CodeGen/profile-filter.c"
%cmake_build --target check-clang
#endregion Test Clang
@ -2539,10 +2810,26 @@ adjust_lit_filter_out test_list_filter_out
# to pass. And then we can adapt this number.
export LIT_OPTS="$LIT_OPTS --max-retries-per-test=4"
%if %{with flang}
# Without this we run into a libflang_rt.runtime.so not found error.
# See https://github.com/llvm/llvm-project/pull/150722 for why this only
# happens when flang is found.
export LD_LIBRARY_PATH=%{buildroot}%{_prefix}/lib/clang/%{maj_ver}/lib/%{llvm_triple}
%endif
%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
@ -2603,6 +2890,12 @@ test_list_filter_out+=("MLIR :: python/execution_engine.py")
test_list_filter_out+=("MLIR :: python/multithreaded_tests.py")
%endif
%if %{with flang}
# TODO(kkleine): This test needs to be re-enabled. I currently only fails when building with flang.
# Here's the test failure: https://gist.github.com/kwk/5d551e27a28dfc1b34a09dca781f91df
test_list_filter_out+=("MLIR :: mlir-pdll-lsp-server/view-output.test")
%endif
adjust_lit_filter_out test_list_filter_out
export PYTHONPATH=%{buildroot}/%{python3_sitearch}
@ -2638,6 +2931,8 @@ if ! grep -q atomics /proc/cpuinfo; then
fi
%endif
adjust_lit_filter_out test_list_filter_out
%cmake_build --target check-bolt
%endif
#endregion BOLT tests
@ -2649,6 +2944,25 @@ reset_test_opts
%endif
#endregion polly tests
#region flang tests
%if %{with flang}
reset_test_opts
# https://github.com/llvm/llvm-project/issues/126051
test_list_filter_out+=("Flang :: Driver/linker-flags.f90")
# We filter our the location.f90 test for now because with LTO+PGO enabled,
# We miss the location.f90 entry in the loc_kind_array[ base, inclusion] entry.
# https://github.com/llvm/llvm-project/issues/156629
test_list_filter_out+=("Flang :: Lower/location.f90")
adjust_lit_filter_out test_list_filter_out
%cmake_build --target check-flang
%cmake_build --target check-flang-rt
%endif
#endregion flang tests
%endif
@ -3012,6 +3326,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
}}
@ -3371,6 +3690,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
@ -3402,12 +3727,69 @@ 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
#endregion MLIR files
#region libcxx files
#region flang files
%if %{with flang}
%files -n %{pkg_name_flang}
%license flang/LICENSE.TXT
%{expand_mans flang}
%{expand_bins %{expand:
tco
bbc
fir-opt
fir-lsp-server
flang
flang-new
}}
%{install_bindir}/flang-%{maj_ver}
%{expand_includes %{expand:
flang/__cuda_builtins.mod
flang/__cuda_device.mod
flang/__fortran_builtins.mod
flang/__fortran_ieee_exceptions.mod
flang/__fortran_type_info.mod
flang/__ppc_intrinsics.mod
flang/__ppc_types.mod
flang/cooperative_groups.mod
flang/ieee_arithmetic.mod
flang/ieee_exceptions.mod
flang/ieee_features.mod
flang/iso_c_binding.mod
flang/iso_fortran_env.mod
flang/mma.mod
flang/cudadevice.mod
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
%files -n %{pkg_name_flang}-runtime
%{_prefix}/lib/clang/%{maj_ver}/lib/%{llvm_triple}/libflang_rt.runtime.a
%{_prefix}/lib/clang/%{maj_ver}/lib/%{llvm_triple}/libflang_rt.runtime.so
%config(noreplace) %{_sysconfdir}/ld.so.conf.d/%{pkg_name_flang}-%{_arch}.conf
%endif
#region flang files
%if %{with libcxx}
%files -n %{pkg_name_libcxx}

View File

@ -1,4 +1,4 @@
SHA512 (llvm-project-21.1.3.src.tar.xz) = d3058e7c18ada2a6a6192c7e75970406520e0d2ba390dba3b89e99f05959198fd2976d38c200f8e6af37fb569d866b6367bf6e0e249fe4b340dfab74499e5723
SHA512 (llvm-project-21.1.3.src.tar.xz.sig) = d218a4071451e32a77890dd2e7de7a3b8a310ca85c7e6d90b88d85bad128979cf6866c9d772b880b50da2ec117832e77ba162049478c1deb7b0299cae008151a
SHA512 (llvm-project-21.1.7.src.tar.xz) = ae30a53ed929df979849f7433bf705bc3d540aa9e12a02a175eb2483d1a56f9ca1203c9b67795f6e84cf2407c28d46d5d5351b290d8735adb5206103fee6f379
SHA512 (llvm-project-21.1.7.src.tar.xz.sig) = d02b09c77abd537eb24d6d43470f962c80a9ec6ccc03ac0efc950d90dbdec5b94dd6abad18143890ff85cee2bdeb7bcf1dac2a576ffcab8ef053d8526417bdcc
SHA512 (llvm-project-20.1.8.src.tar.xz) = f330e72e6a1da468569049437cc0ba7a41abb816ccece7367189344f7ebfef730f4788ac7af2bef0aa8a49341c15ab1d31e941ffa782f264d11fe0dc05470773
SHA512 (llvm-project-20.1.8.src.tar.xz.sig) = d74369bdb4d1b82775161ea53c9c5f3a23ce810f4df5ff617123023f9d8ce720e7d6ecc9e17f8ebd39fd9e7a9de79560abdf2ffe73bcb907a43148d43665d619