From 1d5eee3d6ae81658d3848e79373e47e48a89103f Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Wed, 30 Jul 2025 12:53:49 -0700 Subject: [PATCH] LLVM 20.1.8 release Resolves: RHEL-81020 Resolves: RHEL-106102 --- .copr/Makefile | 17 +- .copr/snapshot-info.sh | 0 .git-blame-ignore-revs | 9 + ...erts-to-test-added-in-145149-because.patch | 26 + ...ake-sure-instruction-get-from-SunkAd.patch | 143 ++++ ...ling-of-undefs-in-the-PPC-isSplatShu.patch | 67 ++ ...mon-Disable-termio-ioctls-on-PowerPC.patch | 51 -- ...-Disable-termio-ioctls-on-PowerPC.patch.20 | 56 -- ...-Remove-interceptors-for-deprecated-.patch | 67 -- 131801.patch | 46 -- 20-131099.patch | 28 + 21-146424.patch | 94 +++ Makefile | 20 +- llvm.spec | 614 ++++++++++++++---- rpminspect.yaml | 5 + sources | 6 +- tests/README.md | 8 +- 17 files changed, 910 insertions(+), 347 deletions(-) mode change 100644 => 100755 .copr/snapshot-info.sh create mode 100644 0001-Add-REQUIRES-asserts-to-test-added-in-145149-because.patch create mode 100644 0001-CodeGenPrepare-Make-sure-instruction-get-from-SunkAd.patch create mode 100644 0001-PowerPC-Fix-handling-of-undefs-in-the-PPC-isSplatShu.patch delete mode 100644 0001-sanitizer_common-Disable-termio-ioctls-on-PowerPC.patch delete mode 100644 0001-sanitizer_common-Disable-termio-ioctls-on-PowerPC.patch.20 delete mode 100644 0001-sanitizer_common-Remove-interceptors-for-deprecated-.patch delete mode 100644 131801.patch create mode 100644 20-131099.patch create mode 100644 21-146424.patch diff --git a/.copr/Makefile b/.copr/Makefile index d470d45..60013ce 100644 --- a/.copr/Makefile +++ b/.copr/Makefile @@ -6,10 +6,25 @@ COPR_USERNAME=$(shell rpm --eval %copr_username) COPR_PROJECT=$(shell rpm --eval %copr_projectname) YYYYMMDD=$(shell date +%Y%m%d) +required_packages=git tar xz curl fedpkg +outdir?=$(shell pwd) +spec?=llvm.spec + .PHONY: srpm srpm: - dnf install -y git tar xz curl --setopt=install_weak_deps=False + @echo "Check for required packages needed by snapshot-info.sh: $(required_packages)" + rpm -q $(required_packages) || dnf install -y $(required_packages) --setopt=install_weak_deps=False + + @echo "Fetch information about today's snapshot" YYYYMMDD=$(YYYYMMDD) ./.copr/snapshot-info.sh > version.spec.inc + + @echo "Get sources" + fedpkg --release rawhide sources --outdir $(shell pwd) + + @echo "Remove left-over llvm-project tarball and signature" + rm -vf $(shell pwd)/llvm-project-*.tar.xz* + + @echo "Finally build SRPM" rpmbuild \ --with=snapshot_build \ --define "_srcrpmdir $(outdir)" \ diff --git a/.copr/snapshot-info.sh b/.copr/snapshot-info.sh old mode 100644 new mode 100755 diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs index 2b6ffb3..03bdae2 100644 --- a/.git-blame-ignore-revs +++ b/.git-blame-ignore-revs @@ -7,3 +7,12 @@ # the following command. # # $ git config blame.ignoreRevsFile .git-blame-ignore-revs + +# Merge *.spec.inc files into llvm.spec +9984e82c507f69611b9589e16467d359622d36f9 + +# Cleanup CMake arguments +a4eda9ffbbf5c912ef764882e8a78da5f76a157d + +# [pre-commit]: pre-commit-hooks 5.0.0, tmt 1.38.0 +260d8e1cdccb5323b8913243f656ba7be20e53bb diff --git a/0001-Add-REQUIRES-asserts-to-test-added-in-145149-because.patch b/0001-Add-REQUIRES-asserts-to-test-added-in-145149-because.patch new file mode 100644 index 0000000..26f372c --- /dev/null +++ b/0001-Add-REQUIRES-asserts-to-test-added-in-145149-because.patch @@ -0,0 +1,26 @@ +From ffc7d5ae2d79f98967943fabb2abfbc1b1e047fd Mon Sep 17 00:00:00 2001 +From: Douglas Yung +Date: Tue, 24 Jun 2025 04:08:34 +0000 +Subject: [PATCH] Add `REQUIRES: asserts` to test added in #145149 because it + uses the `-debug-only=` flag. + +This should fix the test failure when building without asserts. +--- + llvm/test/CodeGen/PowerPC/pr141642.ll | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/llvm/test/CodeGen/PowerPC/pr141642.ll b/llvm/test/CodeGen/PowerPC/pr141642.ll +index 38a706574786..61bda4dfaf53 100644 +--- a/llvm/test/CodeGen/PowerPC/pr141642.ll ++++ b/llvm/test/CodeGen/PowerPC/pr141642.ll +@@ -2,6 +2,7 @@ + ; RUN: FileCheck %s + ; CHECK-NOT: lxvdsx + ; CHECK-NOT: LD_SPLAT ++; REQUIRES: asserts + + define weak_odr dso_local void @unpack(ptr noalias noundef %packed_in) local_unnamed_addr { + entry: +-- +2.49.0 + diff --git a/0001-CodeGenPrepare-Make-sure-instruction-get-from-SunkAd.patch b/0001-CodeGenPrepare-Make-sure-instruction-get-from-SunkAd.patch new file mode 100644 index 0000000..a195bc5 --- /dev/null +++ b/0001-CodeGenPrepare-Make-sure-instruction-get-from-SunkAd.patch @@ -0,0 +1,143 @@ +From c76137f1cfd5758f6889236d49a65f059e6432ff Mon Sep 17 00:00:00 2001 +From: weiguozhi <57237827+weiguozhi@users.noreply.github.com> +Date: Thu, 15 May 2025 09:27:25 -0700 +Subject: [PATCH] [CodeGenPrepare] Make sure instruction get from SunkAddrs is + before MemoryInst (#139303) + +Function optimizeBlock may do optimizations on a block for multiple +times. In the first iteration of the loop, MemoryInst1 may generate a +sunk instruction and store it into SunkAddrs. In the second iteration of +the loop, MemoryInst2 may use the same address and then it can reuse the +sunk instruction stored in SunkAddrs, but MemoryInst2 may be before +MemoryInst1 and the corresponding sunk instruction. In order to avoid +use before def error, we need to find appropriate insert position for the + sunk instruction. + +Fixes #138208. + +(cherry picked from commit 59c6d70ed8120b8864e5f796e2bf3de5518a0ef0) +--- + llvm/lib/CodeGen/CodeGenPrepare.cpp | 41 ++++++++++++++--- + .../CodeGenPrepare/X86/sink-addr-reuse.ll | 44 +++++++++++++++++++ + 2 files changed, 80 insertions(+), 5 deletions(-) + create mode 100644 llvm/test/Transforms/CodeGenPrepare/X86/sink-addr-reuse.ll + +diff --git a/llvm/lib/CodeGen/CodeGenPrepare.cpp b/llvm/lib/CodeGen/CodeGenPrepare.cpp +index 088062afab17..f779f4b782ae 100644 +--- a/llvm/lib/CodeGen/CodeGenPrepare.cpp ++++ b/llvm/lib/CodeGen/CodeGenPrepare.cpp +@@ -5728,6 +5728,35 @@ static bool IsNonLocalValue(Value *V, BasicBlock *BB) { + return false; + } + ++// Find an insert position of Addr for MemoryInst. We can't guarantee MemoryInst ++// is the first instruction that will use Addr. So we need to find the first ++// user of Addr in current BB. ++static BasicBlock::iterator findInsertPos(Value *Addr, Instruction *MemoryInst, ++ Value *SunkAddr) { ++ if (Addr->hasOneUse()) ++ return MemoryInst->getIterator(); ++ ++ // We already have a SunkAddr in current BB, but we may need to insert cast ++ // instruction after it. ++ if (SunkAddr) { ++ if (Instruction *AddrInst = dyn_cast(SunkAddr)) ++ return std::next(AddrInst->getIterator()); ++ } ++ ++ // Find the first user of Addr in current BB. ++ Instruction *Earliest = MemoryInst; ++ for (User *U : Addr->users()) { ++ Instruction *UserInst = dyn_cast(U); ++ if (UserInst && UserInst->getParent() == MemoryInst->getParent()) { ++ if (isa(UserInst) || UserInst->isDebugOrPseudoInst()) ++ continue; ++ if (UserInst->comesBefore(Earliest)) ++ Earliest = UserInst; ++ } ++ } ++ return Earliest->getIterator(); ++} ++ + /// Sink addressing mode computation immediate before MemoryInst if doing so + /// can be done without increasing register pressure. The need for the + /// register pressure constraint means this can end up being an all or nothing +@@ -5852,11 +5881,6 @@ bool CodeGenPrepare::optimizeMemoryInst(Instruction *MemoryInst, Value *Addr, + return Modified; + } + +- // Insert this computation right after this user. Since our caller is +- // scanning from the top of the BB to the bottom, reuse of the expr are +- // guaranteed to happen later. +- IRBuilder<> Builder(MemoryInst); +- + // Now that we determined the addressing expression we want to use and know + // that we have to sink it into this block. Check to see if we have already + // done this for some other load/store instr in this block. If so, reuse +@@ -5867,6 +5891,13 @@ bool CodeGenPrepare::optimizeMemoryInst(Instruction *MemoryInst, Value *Addr, + + Value *SunkAddr = SunkAddrVH.pointsToAliveValue() ? SunkAddrVH : nullptr; + Type *IntPtrTy = DL->getIntPtrType(Addr->getType()); ++ ++ // The current BB may be optimized multiple times, we can't guarantee the ++ // reuse of Addr happens later, call findInsertPos to find an appropriate ++ // insert position. ++ IRBuilder<> Builder(MemoryInst->getParent(), ++ findInsertPos(Addr, MemoryInst, SunkAddr)); ++ + if (SunkAddr) { + LLVM_DEBUG(dbgs() << "CGP: Reusing nonlocal addrmode: " << AddrMode + << " for " << *MemoryInst << "\n"); +diff --git a/llvm/test/Transforms/CodeGenPrepare/X86/sink-addr-reuse.ll b/llvm/test/Transforms/CodeGenPrepare/X86/sink-addr-reuse.ll +new file mode 100644 +index 000000000000..019f31140655 +--- /dev/null ++++ b/llvm/test/Transforms/CodeGenPrepare/X86/sink-addr-reuse.ll +@@ -0,0 +1,44 @@ ++; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5 ++; RUN: opt -S -p 'require,codegenprepare' -cgpp-huge-func=0 < %s | FileCheck %s ++ ++target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128" ++target triple = "x86_64-grtev4-linux-gnu" ++ ++declare void @g(ptr) ++ ++; %load and %load5 use the same address, %load5 is optimized first, %load is ++; optimized later and reuse the same address computation instruction. We must ++; make sure not to generate use before def error. ++ ++define void @f(ptr %arg) { ++; CHECK-LABEL: define void @f( ++; CHECK-SAME: ptr [[ARG:%.*]]) { ++; CHECK-NEXT: [[BB:.*:]] ++; CHECK-NEXT: [[GETELEMENTPTR:%.*]] = getelementptr i8, ptr [[ARG]], i64 -64 ++; CHECK-NEXT: call void @g(ptr [[GETELEMENTPTR]]) ++; CHECK-NEXT: [[SUNKADDR1:%.*]] = getelementptr i8, ptr [[ARG]], i64 -64 ++; CHECK-NEXT: [[LOAD:%.*]] = load ptr, ptr [[SUNKADDR1]], align 8 ++; CHECK-NEXT: [[SUNKADDR:%.*]] = getelementptr i8, ptr [[ARG]], i64 -56 ++; CHECK-NEXT: [[LOAD4:%.*]] = load i32, ptr [[SUNKADDR]], align 8 ++; CHECK-NEXT: [[LOAD5:%.*]] = load ptr, ptr [[SUNKADDR1]], align 8 ++; CHECK-NEXT: [[TMP0:%.*]] = call { i32, i1 } @llvm.uadd.with.overflow.i32(i32 1, i32 0) ++; CHECK-NEXT: [[MATH:%.*]] = extractvalue { i32, i1 } [[TMP0]], 0 ++; CHECK-NEXT: ret void ++; ++bb: ++ %getelementptr = getelementptr i8, ptr %arg, i64 -64 ++ %getelementptr1 = getelementptr i8, ptr %arg, i64 -56 ++ call void @g(ptr %getelementptr) ++ br label %bb3 ++ ++bb3: ++ %load = load ptr, ptr %getelementptr, align 8 ++ %load4 = load i32, ptr %getelementptr1, align 8 ++ %load5 = load ptr, ptr %getelementptr, align 8 ++ %add = add i32 1, 0 ++ %icmp = icmp eq i32 %add, 0 ++ br i1 %icmp, label %bb7, label %bb7 ++ ++bb7: ++ ret void ++} +-- +2.49.0 + diff --git a/0001-PowerPC-Fix-handling-of-undefs-in-the-PPC-isSplatShu.patch b/0001-PowerPC-Fix-handling-of-undefs-in-the-PPC-isSplatShu.patch new file mode 100644 index 0000000..e3d6135 --- /dev/null +++ b/0001-PowerPC-Fix-handling-of-undefs-in-the-PPC-isSplatShu.patch @@ -0,0 +1,67 @@ +From 735d721de451067c3a618b309703d0b8beb9cacc Mon Sep 17 00:00:00 2001 +From: Wael Yehia +Date: Mon, 23 Jun 2025 13:22:33 -0400 +Subject: [PATCH] [PowerPC] Fix handling of undefs in the + PPC::isSplatShuffleMask query (#145149) + +Currently, the query assumes that a single undef byte implies the rest of +the `EltSize - 1` bytes are undefs, but that's not always true. +e.g. isSplatShuffleMask( +<0,1,2,3,4,5,6,7,undef,undef,undef,undef,0,1,2,3>, 8) should return +false. + +--------- + +Co-authored-by: Wael Yehia +--- + llvm/lib/Target/PowerPC/PPCISelLowering.cpp | 13 +++++++++---- + llvm/test/CodeGen/PowerPC/pr141642.ll | 13 +++++++++++++ + 2 files changed, 22 insertions(+), 4 deletions(-) + create mode 100644 llvm/test/CodeGen/PowerPC/pr141642.ll + +diff --git a/llvm/lib/Target/PowerPC/PPCISelLowering.cpp b/llvm/lib/Target/PowerPC/PPCISelLowering.cpp +index 421a808de667..88c6fe632d26 100644 +--- a/llvm/lib/Target/PowerPC/PPCISelLowering.cpp ++++ b/llvm/lib/Target/PowerPC/PPCISelLowering.cpp +@@ -2242,10 +2242,15 @@ bool PPC::isSplatShuffleMask(ShuffleVectorSDNode *N, unsigned EltSize) { + return false; + + for (unsigned i = EltSize, e = 16; i != e; i += EltSize) { +- if (N->getMaskElt(i) < 0) continue; +- for (unsigned j = 0; j != EltSize; ++j) +- if (N->getMaskElt(i+j) != N->getMaskElt(j)) +- return false; ++ // An UNDEF element is a sequence of UNDEF bytes. ++ if (N->getMaskElt(i) < 0) { ++ for (unsigned j = 1; j != EltSize; ++j) ++ if (N->getMaskElt(i + j) >= 0) ++ return false; ++ } else ++ for (unsigned j = 0; j != EltSize; ++j) ++ if (N->getMaskElt(i + j) != N->getMaskElt(j)) ++ return false; + } + return true; + } +diff --git a/llvm/test/CodeGen/PowerPC/pr141642.ll b/llvm/test/CodeGen/PowerPC/pr141642.ll +new file mode 100644 +index 000000000000..38a706574786 +--- /dev/null ++++ b/llvm/test/CodeGen/PowerPC/pr141642.ll +@@ -0,0 +1,13 @@ ++; RUN: llc -mcpu=pwr8 -mtriple=powerpc64le-unknown-linux-gnu -O0 -debug-only=selectiondag -o - < %s 2>&1 | \ ++; RUN: FileCheck %s ++; CHECK-NOT: lxvdsx ++; CHECK-NOT: LD_SPLAT ++ ++define weak_odr dso_local void @unpack(ptr noalias noundef %packed_in) local_unnamed_addr { ++entry: ++ %ld = load <2 x i32>, ptr %packed_in, align 2 ++ %shuf = shufflevector <2 x i32> %ld, <2 x i32> poison, <4 x i32> ++ %ie = insertelement <4 x i32> %shuf, i32 7, i32 2 ++ store <4 x i32> %shuf, ptr %packed_in, align 2 ++ ret void ++} +-- +2.49.0 + diff --git a/0001-sanitizer_common-Disable-termio-ioctls-on-PowerPC.patch b/0001-sanitizer_common-Disable-termio-ioctls-on-PowerPC.patch deleted file mode 100644 index f44d6cb..0000000 --- a/0001-sanitizer_common-Disable-termio-ioctls-on-PowerPC.patch +++ /dev/null @@ -1,51 +0,0 @@ -From be7b1ef7c8e58b454e20f7f70d0e316528e2c823 Mon Sep 17 00:00:00 2001 -From: Tom Stellard -Date: Tue, 29 Apr 2025 21:35:57 +0000 -Subject: [PATCH] [sanitizer_common] Disable termio ioctls on PowerPC - -glibc-2.42 removed the termio.h header, but there are refrences to it -still in the kernel's ioctl.h, so we need disable these ioctls to fix -this build. ---- - .../sanitizer_platform_limits_posix.cpp | 14 +++++++++++--- - 1 file changed, 11 insertions(+), 3 deletions(-) - -diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp -index 7a89bf1c7498..7b81951f82ae 100644 ---- a/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp -+++ b/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp -@@ -182,6 +182,12 @@ typedef struct user_fpregs elf_fpregset_t; - #include - #endif - -+// Work around struct termio usage in ioctl.h on ppc64le. -+#if SANITIZER_GLIBC && !__has_include() && defined(__powerpc64__) -+ #define DISABLE_TERMIO_IOCTLS 1 -+#endif -+ -+ - // Include these after system headers to avoid name clashes and ambiguities. - # include "sanitizer_common.h" - # include "sanitizer_internal_defs.h" -@@ -779,13 +785,15 @@ unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr); - unsigned IOCTL_SOUND_PCM_WRITE_FILTER = SOUND_PCM_WRITE_FILTER; - #endif // SOUND_VERSION - unsigned IOCTL_TCFLSH = TCFLSH; -+#if !defined(DISABLE_TERMIO_IOCTLS) - unsigned IOCTL_TCGETA = TCGETA; -- unsigned IOCTL_TCGETS = TCGETS; -- unsigned IOCTL_TCSBRK = TCSBRK; -- unsigned IOCTL_TCSBRKP = TCSBRKP; - unsigned IOCTL_TCSETA = TCSETA; - unsigned IOCTL_TCSETAF = TCSETAF; - unsigned IOCTL_TCSETAW = TCSETAW; -+#endif -+ unsigned IOCTL_TCGETS = TCGETS; -+ unsigned IOCTL_TCSBRK = TCSBRK; -+ unsigned IOCTL_TCSBRKP = TCSBRKP; - unsigned IOCTL_TCSETS = TCSETS; - unsigned IOCTL_TCSETSF = TCSETSF; - unsigned IOCTL_TCSETSW = TCSETSW; --- -2.48.1 - diff --git a/0001-sanitizer_common-Disable-termio-ioctls-on-PowerPC.patch.20 b/0001-sanitizer_common-Disable-termio-ioctls-on-PowerPC.patch.20 deleted file mode 100644 index e9facda..0000000 --- a/0001-sanitizer_common-Disable-termio-ioctls-on-PowerPC.patch.20 +++ /dev/null @@ -1,56 +0,0 @@ -From 1e49835cc5737b2dffff5923e09546b70a54f90d Mon Sep 17 00:00:00 2001 -From: Tom Stellard -Date: Tue, 29 Apr 2025 21:35:57 +0000 -Subject: [PATCH] [sanitizer_common] Disable termio ioctls on PowerPC - -glibc-2.42 removed the termio.h header, but there are refrences to it -still in the kernel's ioctl.h, so we need disable these ioctls to fix -this build. ---- - .../sanitizer_platform_limits_posix.cpp | 19 ++++++++++++++++--- - 1 file changed, 16 insertions(+), 3 deletions(-) - -diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp -index 10b6535499de..303c82783528 100644 ---- a/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp -+++ b/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp -@@ -173,6 +173,17 @@ typedef struct user_fpregs elf_fpregset_t; - #include - #endif - -+#if SANITIZER_HAIKU -+#include -+#include -+#endif -+ -+// Work around struct termio usage in ioctl.h on ppc64le. -+#if SANITIZER_GLIBC && !__has_include() && defined(__powerpc64__) -+ #define DISABLE_TERMIO_IOCTLS 1 -+#endif -+ -+ - // Include these after system headers to avoid name clashes and ambiguities. - # include "sanitizer_common.h" - # include "sanitizer_internal_defs.h" -@@ -764,13 +775,15 @@ unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr); - unsigned IOCTL_SOUND_PCM_WRITE_FILTER = SOUND_PCM_WRITE_FILTER; - #endif // SOUND_VERSION - unsigned IOCTL_TCFLSH = TCFLSH; -+#if !defined(DISABLE_TERMIO_IOCTLS) - unsigned IOCTL_TCGETA = TCGETA; -- unsigned IOCTL_TCGETS = TCGETS; -- unsigned IOCTL_TCSBRK = TCSBRK; -- unsigned IOCTL_TCSBRKP = TCSBRKP; - unsigned IOCTL_TCSETA = TCSETA; - unsigned IOCTL_TCSETAF = TCSETAF; - unsigned IOCTL_TCSETAW = TCSETAW; -+#endif -+ unsigned IOCTL_TCGETS = TCGETS; -+ unsigned IOCTL_TCSBRK = TCSBRK; -+ unsigned IOCTL_TCSBRKP = TCSBRKP; - unsigned IOCTL_TCSETS = TCSETS; - unsigned IOCTL_TCSETSF = TCSETSF; - unsigned IOCTL_TCSETSW = TCSETSW; --- -2.48.1 - diff --git a/0001-sanitizer_common-Remove-interceptors-for-deprecated-.patch b/0001-sanitizer_common-Remove-interceptors-for-deprecated-.patch deleted file mode 100644 index b002cbe..0000000 --- a/0001-sanitizer_common-Remove-interceptors-for-deprecated-.patch +++ /dev/null @@ -1,67 +0,0 @@ -From 83bf10fffd7065317d50f19e138c9e9fd6adc064 Mon Sep 17 00:00:00 2001 -From: Tom Stellard -Date: Fri, 25 Apr 2025 14:49:34 -0700 -Subject: [PATCH] [sanitizer_common] Remove interceptors for deprecated struct - termio - -This struct will be removed from glibc-2.42 and has been deprecated for -a very long time. - -Fixes #137321 ---- - .../sanitizer_common_interceptors_ioctl.inc | 8 -------- - .../sanitizer_common/sanitizer_platform_limits_posix.cpp | 3 --- - .../sanitizer_common/sanitizer_platform_limits_posix.h | 1 - - 3 files changed, 12 deletions(-) - -diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc b/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc -index f88f914b1d14..bc8f02826c61 100644 ---- a/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc -+++ b/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc -@@ -342,17 +342,9 @@ static void ioctl_table_fill() { - _(SOUND_PCM_WRITE_CHANNELS, WRITE, sizeof(int)); - _(SOUND_PCM_WRITE_FILTER, WRITE, sizeof(int)); - _(TCFLSH, NONE, 0); --#if SANITIZER_GLIBC -- _(TCGETA, WRITE, struct_termio_sz); --#endif - _(TCGETS, WRITE, struct_termios_sz); - _(TCSBRK, NONE, 0); - _(TCSBRKP, NONE, 0); --#if SANITIZER_GLIBC -- _(TCSETA, READ, struct_termio_sz); -- _(TCSETAF, READ, struct_termio_sz); -- _(TCSETAW, READ, struct_termio_sz); --#endif - _(TCSETS, READ, struct_termios_sz); - _(TCSETSF, READ, struct_termios_sz); - _(TCSETSW, READ, struct_termios_sz); -diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp -index b4d87ab6228e..7a89bf1c7498 100644 ---- a/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp -+++ b/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp -@@ -494,9 +494,6 @@ unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr); - unsigned struct_input_id_sz = sizeof(struct input_id); - unsigned struct_mtpos_sz = sizeof(struct mtpos); - unsigned struct_rtentry_sz = sizeof(struct rtentry); --#if SANITIZER_GLIBC || SANITIZER_ANDROID -- unsigned struct_termio_sz = sizeof(struct termio); --#endif - unsigned struct_vt_consize_sz = sizeof(struct vt_consize); - unsigned struct_vt_sizes_sz = sizeof(struct vt_sizes); - unsigned struct_vt_stat_sz = sizeof(struct vt_stat); -diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h b/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h -index 348bb4f27aec..fdc52aa56c49 100644 ---- a/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h -+++ b/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h -@@ -1063,7 +1063,6 @@ extern unsigned struct_hd_geometry_sz; - extern unsigned struct_input_absinfo_sz; - extern unsigned struct_input_id_sz; - extern unsigned struct_mtpos_sz; --extern unsigned struct_termio_sz; - extern unsigned struct_vt_consize_sz; - extern unsigned struct_vt_sizes_sz; - extern unsigned struct_vt_stat_sz; --- -2.48.1 - diff --git a/131801.patch b/131801.patch deleted file mode 100644 index 853fba8..0000000 --- a/131801.patch +++ /dev/null @@ -1,46 +0,0 @@ -From d25887408ee9fb78d68787ff7388cba254aced6f Mon Sep 17 00:00:00 2001 -From: Nikita Popov -Date: Tue, 18 Mar 2025 14:36:06 +0100 -Subject: [PATCH] [GlobalMerge][PPC] Don't merge globals in llvm.metadata - section - -The llvm.metadata section is not emitted and has special semantics. -We should not merge globals in it, similarly to how we already -skip merging of `llvm.xyz` globals. - -Fixes https://github.com/llvm/llvm-project/issues/131394. ---- - llvm/lib/CodeGen/GlobalMerge.cpp | 3 ++- - llvm/test/CodeGen/PowerPC/global-merge-llvm-metadata.ll | 9 +++++++++ - 2 files changed, 11 insertions(+), 1 deletion(-) - create mode 100644 llvm/test/CodeGen/PowerPC/global-merge-llvm-metadata.ll - -diff --git a/llvm/lib/CodeGen/GlobalMerge.cpp b/llvm/lib/CodeGen/GlobalMerge.cpp -index 1aedc447935b7..ca743918cec24 100644 ---- a/llvm/lib/CodeGen/GlobalMerge.cpp -+++ b/llvm/lib/CodeGen/GlobalMerge.cpp -@@ -711,7 +711,8 @@ bool GlobalMergeImpl::run(Module &M) { - continue; - - // Ignore all 'special' globals. -- if (GV.getName().starts_with("llvm.") || GV.getName().starts_with(".llvm.")) -+ if (GV.getName().starts_with("llvm.") || -+ GV.getName().starts_with(".llvm.") || Section == "llvm.metadata") - continue; - - // Ignore all "required" globals: -diff --git a/llvm/test/CodeGen/PowerPC/global-merge-llvm-metadata.ll b/llvm/test/CodeGen/PowerPC/global-merge-llvm-metadata.ll -new file mode 100644 -index 0000000000000..7db092e13afeb ---- /dev/null -+++ b/llvm/test/CodeGen/PowerPC/global-merge-llvm-metadata.ll -@@ -0,0 +1,9 @@ -+; RUN: llc -mtriple=powerpc64le-unknown-linux-gnu < %s | FileCheck %s -+ -+@index = global i32 0, align 4 -+@.str = private unnamed_addr constant [1 x i8] zeroinitializer, section "llvm.metadata" -+@.str.1 = private unnamed_addr constant [7 x i8] c"test.c\00", section "llvm.metadata" -+@llvm.global.annotations = appending global [1 x { ptr, ptr, ptr, i32, ptr }] [{ ptr, ptr, ptr, i32, ptr } { ptr @index, ptr @.str, ptr @.str.1, i32 1, ptr null }], section "llvm.metadata" -+ -+; CHECK-NOT: .set -+; CHECK-NOT: _MergedGlobals diff --git a/20-131099.patch b/20-131099.patch new file mode 100644 index 0000000..0b66256 --- /dev/null +++ b/20-131099.patch @@ -0,0 +1,28 @@ +From e43271ec7438ecb78f99db134aeca274a47f6c28 Mon Sep 17 00:00:00 2001 +From: Konrad Kleine +Date: Thu, 13 Mar 2025 09:12:24 +0100 +Subject: [PATCH] Filter out configuration file from compile commands + +The commands to run the compilation when printed with `-###` contain +various irrelevant lines for the perf-training. Most of them are +filtered out already but when configured with +`CLANG_CONFIG_FILE_SYSTEM_DIR` a new line like the following is +added and needs to be filtered out: + +`Configuration file: /etc/clang/x86_64-redhat-linux-gnu-clang.cfg` +--- + clang/utils/perf-training/perf-helper.py | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/clang/utils/perf-training/perf-helper.py b/clang/utils/perf-training/perf-helper.py +index 80c6356d0497c..29904aded5ab0 100644 +--- a/clang/utils/perf-training/perf-helper.py ++++ b/clang/utils/perf-training/perf-helper.py +@@ -237,6 +237,7 @@ def get_cc1_command_for_args(cmd, env): + or ln.startswith("InstalledDir:") + or ln.startswith("LLVM Profile Note") + or ln.startswith(" (in-process)") ++ or ln.startswith("Configuration file:") + or " version " in ln + ): + continue diff --git a/21-146424.patch b/21-146424.patch new file mode 100644 index 0000000..5b95886 --- /dev/null +++ b/21-146424.patch @@ -0,0 +1,94 @@ +From eba58195932f37fb461ae17c69fc517181b99c9a Mon Sep 17 00:00:00 2001 +From: Paul Murphy +Date: Mon, 30 Jun 2025 10:13:37 -0500 +Subject: [PATCH] [PowerPC] fix lowering of SPILL_CRBIT on pwr9 and pwr10 + +If a copy exists between creation of a crbit and a spill, machine-cp +may delete the copy since it seems unaware of the relation between a cr +and crbit. A fix was previously made for the generic ppc64 lowering. It +should be applied to the pwr9 and pwr10 variants too. + +Likewise, relax and extend the pwr8 test to verify pwr9 and pwr10 +codegen too. + +This fixes #143989. +--- + llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp | 17 +++++++++++------ + .../PowerPC/NoCRFieldRedefWhenSpillingCRBIT.mir | 8 +++++++- + 2 files changed, 18 insertions(+), 7 deletions(-) + +diff --git a/llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp b/llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp +index 76dca4794e05..78d254a55fd9 100644 +--- a/llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp ++++ b/llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp +@@ -1102,13 +1102,20 @@ void PPCRegisterInfo::lowerCRBitSpilling(MachineBasicBlock::iterator II, + SpillsKnownBit = true; + break; + default: ++ // When spilling a CR bit, The super register may not be explicitly defined ++ // (i.e. it can be defined by a CR-logical that only defines the subreg) so ++ // we state that the CR field is undef. Also, in order to preserve the kill ++ // flag on the CR bit, we add it as an implicit use. ++ + // On Power10, we can use SETNBC to spill all CR bits. SETNBC will set all + // bits (specifically, it produces a -1 if the CR bit is set). Ultimately, + // the bit that is of importance to us is bit 32 (bit 0 of a 32-bit + // register), and SETNBC will set this. + if (Subtarget.isISA3_1()) { + BuildMI(MBB, II, dl, TII.get(LP64 ? PPC::SETNBC8 : PPC::SETNBC), Reg) +- .addReg(SrcReg, RegState::Undef); ++ .addReg(SrcReg, RegState::Undef) ++ .addReg(SrcReg, RegState::Implicit | ++ getKillRegState(MI.getOperand(0).isKill())); + break; + } + +@@ -1122,16 +1129,14 @@ void PPCRegisterInfo::lowerCRBitSpilling(MachineBasicBlock::iterator II, + SrcReg == PPC::CR4LT || SrcReg == PPC::CR5LT || + SrcReg == PPC::CR6LT || SrcReg == PPC::CR7LT) { + BuildMI(MBB, II, dl, TII.get(LP64 ? PPC::SETB8 : PPC::SETB), Reg) +- .addReg(getCRFromCRBit(SrcReg), RegState::Undef); ++ .addReg(getCRFromCRBit(SrcReg), RegState::Undef) ++ .addReg(SrcReg, RegState::Implicit | ++ getKillRegState(MI.getOperand(0).isKill())); + break; + } + } + + // We need to move the CR field that contains the CR bit we are spilling. +- // The super register may not be explicitly defined (i.e. it can be defined +- // by a CR-logical that only defines the subreg) so we state that the CR +- // field is undef. Also, in order to preserve the kill flag on the CR bit, +- // we add it as an implicit use. + BuildMI(MBB, II, dl, TII.get(LP64 ? PPC::MFOCRF8 : PPC::MFOCRF), Reg) + .addReg(getCRFromCRBit(SrcReg), RegState::Undef) + .addReg(SrcReg, +diff --git a/llvm/test/CodeGen/PowerPC/NoCRFieldRedefWhenSpillingCRBIT.mir b/llvm/test/CodeGen/PowerPC/NoCRFieldRedefWhenSpillingCRBIT.mir +index 41e21248a3f0..2796cdb3ae87 100644 +--- a/llvm/test/CodeGen/PowerPC/NoCRFieldRedefWhenSpillingCRBIT.mir ++++ b/llvm/test/CodeGen/PowerPC/NoCRFieldRedefWhenSpillingCRBIT.mir +@@ -1,6 +1,12 @@ + # RUN: llc -mcpu=pwr8 -mtriple=powerpc64le-unknown-linux-gnu -start-after \ + # RUN: virtregrewriter -ppc-asm-full-reg-names -verify-machineinstrs %s \ + # RUN: -o - | FileCheck %s ++# RUN: llc -mcpu=pwr9 -mtriple=powerpc64le-unknown-linux-gnu -start-after \ ++# RUN: virtregrewriter -ppc-asm-full-reg-names -verify-machineinstrs %s \ ++# RUN: -o - | FileCheck %s ++# RUN: llc -mcpu=pwr10 -mtriple=powerpc64le-unknown-linux-gnu -start-after \ ++# RUN: virtregrewriter -ppc-asm-full-reg-names -verify-machineinstrs %s \ ++# RUN: -o - | FileCheck %s + + --- | + ; ModuleID = 'a.ll' +@@ -30,7 +36,7 @@ + ; Function Attrs: nounwind + declare void @llvm.stackprotector(ptr, ptr) #1 + +- attributes #0 = { nounwind "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "frame-pointer"="none" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="ppc64le" "target-features"="+altivec,+bpermd,+crypto,+direct-move,+extdiv,+htm,+power8-vector,+vsx,-power9-vector" "unsafe-fp-math"="false" "use-soft-float"="false" } ++ attributes #0 = { nounwind "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "frame-pointer"="none" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" } + attributes #1 = { nounwind } + + !llvm.ident = !{!0} +-- +2.49.0 + diff --git a/Makefile b/Makefile index 5fd496b..242e15d 100644 --- a/Makefile +++ b/Makefile @@ -2,9 +2,9 @@ # See ~/.config/mock/.cfg or /etc/mock/.cfg # Tweak this to centos-stream-9-x86_64 to build for CentOS -MOCK_CHROOT?=centos-stream-10-x86_64 +MOCK_CHROOT?=fedora-rawhide-x86_64 MOCK_OPTS?= -MOCK_OPTS_RELEASE?=--no-clean --no-cleanup-after --without lto_build --define "debug_package %{nil}" $(MOCK_OPTS) +MOCK_OPTS_RELEASE?=--no-clean --no-cleanup-after --without lto_build --without pgo --define "debug_package %{nil}" $(MOCK_OPTS) MOCK_OPTS_SNAPSHOT?=$(MOCK_OPTS_RELEASE) --with snapshot_build $(MOCK_OPTS) YYYYMMDD?=$(shell date +%Y%m%d) SOURCEDIR=$(shell pwd) @@ -103,6 +103,22 @@ edit-last-failing-script: get-last-run-script mockbuild-rerun-last-script: get-last-run-script mock --root=$(MOCK_CHROOT) --shell 'sh -e $(last_run_script)' +.PHONY: mock-shell +## Run an interactive mock shell with bash +mock-shell: + mock --root=$(MOCK_CHROOT) --shell bash + +######### Help debug inside mock environment + +.PHONY: mock-install-debugging-tools +## This will install gdb, gdb-dashboard, vim, valgrind, lldb and +## other tools into your mock environment for you to debug any +## problems. +mock-install-debugging-tools: + mock --root=$(MOCK_CHROOT) --install python3-pygments vim gdb lldb python3-rpm valgrind + curl -sLO https://github.com/cyrus-and/gdb-dashboard/raw/master/.gdbinit + mock --root=$(MOCK_CHROOT) --copyin .gdbinit /builddir/.gdbinit + .PHONY: help # Based on https://gist.github.com/rcmachado/af3db315e31383502660 ## Display this help text. diff --git a/llvm.spec b/llvm.spec index 80040c6..92f2b7a 100644 --- a/llvm.spec +++ b/llvm.spec @@ -2,7 +2,7 @@ #region version %global maj_ver 20 %global min_ver 1 -%global patch_ver 4 +%global patch_ver 8 #global rc_ver 3 %bcond_with snapshot_build @@ -94,6 +94,37 @@ %bcond_with polly %endif +#region pgo +%ifarch %{ix86} +%bcond_with pgo +%else +%if 0%{?fedora} >= 43 || (0%{?rhel} >= 9 && %{maj_ver} >= 21) +%bcond_without pgo +%else +%bcond_with pgo +%endif +%endif + +# We only want to run the performance comparison on snapshot builds. +# centos-streams/RHEL do not have all the requirements. We tried to use pip, +# but we've seen issues on some architectures. We're now restricting this +# to Fedora. +%if %{with pgo} && %{with snapshot_build} && %{defined fedora} +%global run_pgo_perf_comparison 1 +%else +%global run_pgo_perf_comparison %{nil} +%endif + +# Sanity checks for PGO and bootstrapping +#---------------------------------------- +%if %{with pgo} +%ifarch %{ix86} +%{error:Your architecture is not allowed for PGO because it is in this list: %{ix86}} +%endif +%endif +#---------------------------------------- +#endregion pgo + # Disable LTO on x86 and riscv in order to reduce memory consumption. %ifarch %ix86 riscv64 %bcond_with lto_build @@ -101,7 +132,9 @@ %bcond_without lto_build %endif -%if %{without lto_build} +# For PGO Disable LTO for now because of LLVMgold.so not found error +# Use LLVM_ENABLE_LTO:BOOL=ON flags to enable LTO instead +%if 0%{without lto_build} || 0%{with pgo} %global _lto_cflags %nil %endif @@ -151,6 +184,15 @@ %endif %endif +# LLD uses "fast" as the algortithm for generating build-id +# values while ld.bfd uses "sha1" by default. We need to get lld +# to use the same algorithm or otherwise we end up with errors like thise one: +# +# "build-id found in [...]/usr/lib64/llvm21/bin/llvm-debuginfod-find too small" +# +# NOTE: Originally this is only needed for PGO but it doesn't hurt to have it on all the time. +%global build_ldflags %{?build_ldflags} -Wl,--build-id=sha1 + #region LLVM globals %if %{with compat_build} @@ -168,15 +210,15 @@ %global install_prefix %{_libdir}/llvm%{maj_ver} %global install_bindir %{install_prefix}/bin %global install_includedir %{install_prefix}/include -%global install_libdir %{install_prefix}/lib +%global install_libdir %{install_prefix}/%{_lib} %global install_datadir %{install_prefix}/share %global install_mandir %{install_prefix}/share/man %global install_libexecdir %{install_prefix}/libexec -%global build_libdir llvm/%{_vpath_builddir}/lib -%global unprefixed_libdir lib +%global build_libdir llvm/%{_vpath_builddir}/%{_lib} +%global unprefixed_libdir %{_lib} %if 0%{?rhel} -%global targets_to_build "X86;AMDGPU;PowerPC;NVPTX;SystemZ;AArch64;BPF;WebAssembly" +%global targets_to_build "X86;AMDGPU;PowerPC;NVPTX;SystemZ;AArch64;BPF;WebAssembly;RISCV" %global experimental_targets_to_build "" %else %global targets_to_build "all" @@ -261,13 +303,20 @@ #region polly globals %global pkg_name_polly polly%{pkg_suffix} #endregion polly globals + +#region PGO globals +%if 0%{run_pgo_perf_comparison} +%global llvm_test_suite_dir %{_datadir}/llvm-test-suite +%endif +#endregion PGO globals + #endregion globals #region packages #region main package Name: %{pkg_name_llvm} Version: %{maj_ver}.%{min_ver}.%{patch_ver}%{?rc_ver:~rc%{rc_ver}}%{?llvm_snapshot_version_suffix:~%{llvm_snapshot_version_suffix}} -Release: 2%{?dist} +Release: 1%{?dist} Summary: The Low Level Virtual Machine License: Apache-2.0 WITH LLVM-exception OR NCSA @@ -324,6 +373,7 @@ Source1000: version.spec.inc #region CLANG patches Patch101: 0001-PATCH-clang-Make-funwind-tables-the-default-on-all-a.patch Patch102: 0003-PATCH-clang-Don-t-install-static-libraries.patch +Patch2002: 20-131099.patch # Workaround a bug in ORC on ppc64le. # More info is available here: https://reviews.llvm.org/D159115#4641826 @@ -334,14 +384,6 @@ Patch103: 0001-Workaround-a-bug-in-ORC-on-ppc64le.patch Patch104: 0001-Driver-Give-devtoolset-path-precedence-over-Installe.patch #endregion CLANG patches -# Fix for glibc >= 2.42 -# https://github.com/llvm/llvm-project/pull/137403 -Patch2005: 0001-sanitizer_common-Remove-interceptors-for-deprecated-.patch - -# Fix for glibc >= 2.42 on ppc64le -Patch2008: 0001-sanitizer_common-Disable-termio-ioctls-on-PowerPC.patch.20 -Patch2108: 0001-sanitizer_common-Disable-termio-ioctls-on-PowerPC.patch - # Fix LLVMConfig.cmake when symlinks are used. # (https://github.com/llvm/llvm-project/pull/124743 landed in LLVM 21) Patch1902: 0001-cmake-Resolve-symlink-when-finding-install-prefix.patch @@ -352,8 +394,7 @@ Patch106: 0001-19-Always-build-shared-libs-for-LLD.patch #endregion LLD patches #region polly patches -Patch2001: 0001-20-polly-shared-libs.patch -Patch2101: 0001-20-polly-shared-libs.patch +Patch107: 0001-20-polly-shared-libs.patch #endregion polly patches #region RHEL patches @@ -365,6 +406,18 @@ Patch501: 0001-Fix-page-size-constant-on-aarch64-and-ppc64le.patch # https://github.com/llvm/llvm-project/issues/124001 Patch1901: 0001-SystemZ-Fix-ICE-with-i128-i64-uaddo-carry-chain.patch +# Fix a pgo miscompilation triggered by building Rust 1.87 with pgo on ppc64le. +# https://github.com/llvm/llvm-project/issues/138208 +Patch2004: 0001-CodeGenPrepare-Make-sure-instruction-get-from-SunkAd.patch + +# Fix Power9/Power10 crbit spilling +# https://github.com/llvm/llvm-project/pull/146424 +Patch108: 21-146424.patch + +# Fix for highway package build on ppc64le +Patch2005: 0001-PowerPC-Fix-handling-of-undefs-in-the-PPC-isSplatShu.patch +Patch2006: 0001-Add-REQUIRES-asserts-to-test-added-in-145149-because.patch + %if 0%{?rhel} == 8 %global python3_pkgversion 3.12 %global __python3 /usr/bin/python3.12 @@ -389,6 +442,28 @@ BuildRequires: zlib-devel BuildRequires: libzstd-devel BuildRequires: libffi-devel BuildRequires: ncurses-devel + +%if %{with pgo} +BuildRequires: lld +BuildRequires: compiler-rt +BuildRequires: llvm + +%if 0%{run_pgo_perf_comparison} +BuildRequires: llvm-test-suite +BuildRequires: tcl-devel +BuildRequires: which +# pandas and scipy are needed for running llvm-test-suite/utils/compare.py +# For RHEL we have to install it from pip and for fedora we take the RPM package. +%if 0%{?rhel} +BuildRequires: python3-pip +%else +BuildRequires: python3-pandas +BuildRequires: python3-scipy +%endif +%endif + +%endif + # This intentionally does not use python3_pkgversion. RHEL 8 does not have # python3.12-sphinx, and we are only using it as a binary anyway. BuildRequires: python3-sphinx @@ -540,9 +615,9 @@ Requires: %{pkg_name_llvm}-static%{?_isa} = %{version}-%{release} Requires: %{pkg_name_llvm}-test%{?_isa} = %{version}-%{release} Requires: %{pkg_name_llvm}-googletest%{?_isa} = %{version}-%{release} -%if %{without compat_build} -Requires(pre): alternatives -%endif + +Requires(post): alternatives +Requires(postun): alternatives Provides: llvm-devel(major) = %{maj_ver} @@ -1212,6 +1287,17 @@ export ASMFLAGS="%{build_cflags}" cd llvm +# Remember old values to reset to +OLD_PATH="$PATH" +OLD_LD_LIBRARY_PATH="$LD_LIBRARY_PATH" +OLD_CWD="$PWD" + +%global builddir_instrumented $RPM_BUILD_DIR/instrumented-llvm +%if 0%{run_pgo_perf_comparison} +%global builddir_perf_pgo $RPM_BUILD_DIR/performance-of-pgoed-clang +%global builddir_perf_system $RPM_BUILD_DIR/performance-of-system-clang +%endif + #region LLVM lit %if %{with python_lit} pushd utils/lit @@ -1254,8 +1340,15 @@ popd -DCLANG_INCLUDE_TESTS:BOOL=ON \\\ -DCLANG_PLUGIN_SUPPORT:BOOL=ON \\\ -DCLANG_REPOSITORY_STRING="%{?dist_vendor} %{version}-%{release}" \\\ - -DLLVM_EXTERNAL_CLANG_TOOLS_EXTRA_SOURCE_DIR=../clang-tools-extra \\\ + -DLLVM_EXTERNAL_CLANG_TOOLS_EXTRA_SOURCE_DIR=../clang-tools-extra + +%if %{with compat_build} +%global cmake_config_args %{cmake_config_args} \\\ -DCLANG_RESOURCE_DIR=../../../lib/clang/%{maj_ver} +%else +%global cmake_config_args %{cmake_config_args} \\\ + -DCLANG_RESOURCE_DIR=../lib/clang/%{maj_ver} +%endif #endregion clang options #region compiler-rt options @@ -1424,6 +1517,10 @@ popd %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 + %if %{with gold} %global cmake_config_args %{cmake_config_args} -DLLVM_BINUTILS_INCDIR=%{_includedir} %endif @@ -1458,7 +1555,126 @@ if grep 'flags.*la57' /proc/cpuinfo; then fi #endregion cmake options -%cmake -G Ninja %cmake_config_args $extra_cmake_args +%if %{with pgo} +#region Instrument LLVM +%global __cmake_builddir %{builddir_instrumented} + +# For -Wno-backend-plugin see https://llvm.org/docs/HowToBuildWithPGO.html +#%%global optflags_for_instrumented %(echo %{optflags} -Wno-backend-plugin) + +%global cmake_config_args_instrumented %{cmake_config_args} \\\ + -DLLVM_ENABLE_PROJECTS:STRING="clang;lld" \\\ + -DLLVM_ENABLE_RUNTIMES="compiler-rt" \\\ + -DLLVM_TARGETS_TO_BUILD=Native \\\ + -DCMAKE_BUILD_TYPE:STRING=Release \\\ + -DCMAKE_INSTALL_PREFIX=%{builddir_instrumented} \\\ + -DCLANG_INCLUDE_DOCS:BOOL=OFF \\\ + -DLLVM_BUILD_DOCS:BOOL=OFF \\\ + -DLLVM_BUILD_UTILS:BOOL=OFF \\\ + -DLLVM_ENABLE_DOXYGEN:BOOL=OFF \\\ + -DLLVM_ENABLE_SPHINX:BOOL=OFF \\\ + -DLLVM_INCLUDE_DOCS:BOOL=OFF \\\ + -DLLVM_INCLUDE_TESTS:BOOL=OFF \\\ + -DLLVM_INSTALL_UTILS:BOOL=OFF \\\ + -DCLANG_BUILD_EXAMPLES:BOOL=OFF \\\ + \\\ + -DLLVM_BUILD_INSTRUMENTED=IR \\\ + -DLLVM_BUILD_RUNTIME=No \\\ + -DLLVM_ENABLE_LTO:BOOL=Thin \\\ + -DLLVM_USE_LINKER=lld + +# CLANG_INCLUDE_TESTS=ON is needed to make the target "generate-profdata" available +%global cmake_config_args_instrumented %{cmake_config_args_instrumented} \\\ + -DCLANG_INCLUDE_TESTS:BOOL=ON + +# LLVM_INCLUDE_UTILS=ON is needed because the tests enabled by CLANG_INCLUDE_TESTS=ON +# require "FileCheck", "not", "count", etc. +%global cmake_config_args_instrumented %{cmake_config_args_instrumented} \\\ + -DLLVM_INCLUDE_UTILS:BOOL=ON + +# LLVM Profile Warning: Unable to track new values: Running out of static counters. +# Consider using option -mllvm -vp-counters-per-site= to allocate more value profile +# counters at compile time. +%global cmake_config_args_instrumented %{cmake_config_args_instrumented} \\\ + -DLLVM_VP_COUNTERS_PER_SITE=8 + +# TODO(kkleine): Should we see warnings like: +# "function control flow change detected (hash mismatch)" +# then read https://issues.chromium.org/issues/40633598 again. +%cmake -G Ninja %{cmake_config_args_instrumented} $extra_cmake_args + +# Build all the tools we need in order to build generate-profdata and llvm-profdata +%cmake_build --target libclang-cpp.so +%cmake_build --target clang +%cmake_build --target lld +%cmake_build --target llvm-profdata +%cmake_build --target llvm-ar +%cmake_build --target llvm-ranlib +%cmake_build --target llvm-cxxfilt +#endregion Instrument LLVM + +#region Perf training +# Without these exports the function count is ~160 and with them it is ~200,000. +export LD_LIBRARY_PATH="%{builddir_instrumented}/%{_lib}:%{builddir_instrumented}/lib:$OLD_LD_LIBRARY_PATH" +export PATH="%{builddir_instrumented}/bin:$OLD_PATH" + +%cmake_build --target generate-profdata + +# Use the newly compiled llvm-profdata to avoid profile version mismatches like: +# "raw profile version mismatch: Profile uses raw profile format version = 10; expected version = 9" +%global llvm_profdata_bin %{builddir_instrumented}/bin/llvm-profdata +%global llvm_cxxfilt_bin %{builddir_instrumented}/bin/llvm-cxxfilt + +# Show top 10 functions in the profile +%llvm_profdata_bin show --topn=10 %{builddir_instrumented}/tools/clang/utils/perf-training/clang.profdata | %llvm_cxxfilt_bin + +cp %{builddir_instrumented}/tools/clang/utils/perf-training/clang.profdata $RPM_BUILD_DIR/result.profdata + +#endregion Perf training +%endif + +#region Final stage + +#region reset paths and globals +function reset_paths { + export PATH="$OLD_PATH" + export LD_LIBRARY_PATH="$OLD_LD_LIBRARY_PATH" +} +reset_paths + +cd $OLD_CWD +%global _vpath_srcdir . +%global __cmake_builddir %{_vpath_builddir} +#endregion reset paths and globals + +%global extra_cmake_opts %{nil} + +%if %{with pgo} + %global extra_cmake_opts %{extra_cmake_opts} -DLLVM_PROFDATA_FILE=$RPM_BUILD_DIR/result.profdata + # There were a couple of errors that I ran into. One basically said: + # + # Error: LLVM Profile Warning: Unable to track new values: Running out of + # static counters. Consider using option -mllvm -vp-counters-per-site= to + # allocate more value profile counters at compile time. + # + # As a solution I’ve added the --vp-counters-per-site option but this resulted + # in a follow-up error: + # + # Error: clang (LLVM option parsing): for the --vp-counters-per-site option: + # may only occur zero or one times! + # + # The solution was to modify vp-counters-per-site option through + # 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 +%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 +%endif + +%cmake -G Ninja %{cmake_config_args} %{extra_cmake_opts} $extra_cmake_args # Build libLLVM.so first. This ensures that when libLLVM.so is linking, there # are no other compile jobs running. This will help reduce OOM errors on the @@ -1484,8 +1700,74 @@ fi # /usr/lib64/libomptarget.devicertl.a # /usr/lib64/libomptarget-amdgpu-*.bc # /usr/lib64/libomptarget-nvptx-*.bc - %cmake_build --target runtimes +#endregion Final stage + +#region Performance comparison +%if 0%{run_pgo_perf_comparison} + +function run_perf_test { + local build_dir=$1 + + cd %{llvm_test_suite_dir} + %__cmake -G Ninja \ + -S "%{llvm_test_suite_dir}" \ + -B "${build_dir}" \ + -DCMAKE_GENERATOR=Ninja \ + -DCMAKE_C_COMPILER=clang \ + -DCMAKE_CXX_COMPILER=clang++ \ + -DTEST_SUITE_BENCHMARKING_ONLY=ON \ + -DTEST_SUITE_COLLECT_STATS=ON \ + -DTEST_SUITE_USE_PERF=OFF \ + -DTEST_SUITE_SUBDIRS=CTMark \ + -DTEST_SUITE_RUN_BENCHMARKS=OFF \ + -DTEST_SUITE_COLLECT_CODE_SIZE=OFF \ + -C%{llvm_test_suite_dir}/cmake/caches/O3.cmake + + # Build the test-suite + %__cmake --build "${build_dir}" -j1 --verbose + + # Run the tests with lit: + %{builddir_instrumented}/bin/llvm-lit -v -o ${build_dir}/results.json ${build_dir} || true + cd $OLD_CWD +} + +# Run performance test for system clang +reset_paths +run_perf_test %{builddir_perf_system} + +# Run performance test for PGOed clang +reset_paths +FINAL_BUILD_DIR=`pwd`/%{_vpath_builddir} +export LD_LIBRARY_PATH="${FINAL_BUILD_DIR}/lib:${FINAL_BUILD_DIR}/lib64:${LD_LIBRARY_PATH}" +export PATH="${FINAL_BUILD_DIR}/bin:${OLD_PATH}" +run_perf_test %{builddir_perf_pgo} + +# Compare the performance of system and PGOed clang +%if 0%{?rhel} +python3 -m venv compare-env +source ./compare-env/bin/activate +pip install "pandas>=2.2.3" +pip install "scipy>=1.13.1" +MY_PYTHON_BIN=./compare-env/bin/python3 +%endif + +system_llvm_release=$(/usr/bin/clang --version | grep -Po '[0-9]+\.[0-9]+\.[0-9]' | head -n1) +${MY_PYTHON_BIN} %{llvm_test_suite_dir}/utils/compare.py \ + --metric compile_time \ + --lhs-name ${system_llvm_release} \ + --rhs-name pgo-%{version} \ + %{builddir_perf_system}/results.json vs %{builddir_perf_pgo}/results.json > %{builddir_perf_pgo}/results-system-vs-pgo.txt || true + +echo "Result of Performance comparison between system and PGOed clang" +cat %{builddir_perf_pgo}/results-system-vs-pgo.txt + +%if 0%{?rhel} +# Deactivate virtual python environment created ealier +deactivate +%endif +%endif +#endregion Performance comparison #region compat lib cd .. @@ -1608,6 +1890,14 @@ EOF # Add a symlink in bindir to clang-format-diff ln -s ../share/clang/clang-format-diff.py %{buildroot}%{install_bindir}/clang-format-diff +# Install the PGO profile that was used to build this LLVM into the clang package +%if 0%{with pgo} +cp -v $RPM_BUILD_DIR/result.profdata %{buildroot}%{install_datadir}/llvm-pgo.profdata +%if 0%{run_pgo_perf_comparison} +cp -v %{builddir_perf_pgo}/results-system-vs-pgo.txt %{buildroot}%{install_datadir}/results-system-vs-pgo.txt +%endif +%endif + # File in the macros file for other packages to use. We are not doing this # in the compat package, because the version macros would # conflict with # eachother if both clang and the clang compat package were installed together. @@ -1628,7 +1918,7 @@ install -p -m644 clang/bindings/python/clang/* %{buildroot}%{python3_sitelib}/cl %py_byte_compile %{__python3} %{buildroot}%{python3_sitelib}/clang # install scanbuild-py to python sitelib. -mv %{buildroot}%{install_libdir}/{libear,libscanbuild} %{buildroot}%{python3_sitelib} +mv %{buildroot}%{install_prefix}/lib/{libear,libscanbuild} %{buildroot}%{python3_sitelib} # Cannot use {libear,libscanbuild} style expansion in py_byte_compile. %py_byte_compile %{__python3} %{buildroot}%{python3_sitelib}/libear %py_byte_compile %{__python3} %{buildroot}%{python3_sitelib}/libscanbuild @@ -1642,7 +1932,7 @@ done %else # Not sure where to put these python modules for the compat build. -rm -Rf %{buildroot}%{install_libdir}/{libear,libscanbuild} +rm -Rf %{buildroot}%{install_prefix}/lib/{libear,libscanbuild} rm %{buildroot}%{install_bindir}/scan-build-py # Not sure where to put the emacs integration files for the compat build. @@ -1669,8 +1959,12 @@ rm -Rvf %{buildroot}%{install_datadir}/clang-doc # TODO: What are the Fedora guidelines for packaging bash autocomplete files? rm -vf %{buildroot}%{install_datadir}/clang/bash-autocomplete.sh -# Create sub-directories in the clang resource directory that will be -# populated by other packages +%if %{without compat_build} +# Move clang resource directory to default prefix. +mkdir -p %{buildroot}%{_prefix}/lib/clang +mv %{buildroot}%{install_prefix}/lib/clang/%{maj_ver} %{buildroot}%{_prefix}/lib/clang/%{maj_ver} +%endif +# Create any missing sub-directories in the clang resource directory. mkdir -p %{buildroot}%{_prefix}/lib/clang/%{maj_ver}/{bin,include,lib,share}/ # Add versioned resource directory macro @@ -1756,7 +2050,7 @@ rmdir %{buildroot}%{install_prefix}/%{_lib}/python%{python3_version} # python: fix binary libraries location liblldb=$(basename $(readlink -e %{buildroot}%{install_libdir}/liblldb.so)) -ln -vsf "../../../llvm%{maj_ver}/lib/${liblldb}" %{buildroot}%{python3_sitearch}/lldb/_lldb.so +ln -vsf "../../../${liblldb}" %{buildroot}%{python3_sitearch}/lldb/_lldb.so %py_byte_compile %{__python3} %{buildroot}%{python3_sitearch}/lldb %endif %endif @@ -1797,45 +2091,9 @@ popd rm -f %{buildroot}%{install_libdir}/libLLVMBOLT*.a #endregion BOLT installation -# Do not create symlinks for i686 to avoid multilib conflicts. -# Don't ship man pages altogether. -%ifarch %{ix86} -rm -rf %{buildroot}%{install_mandir} -%else -# Create symlinks from the system install prefix to the llvm install prefix. -# Do this at the end so it includes any files added by preceding steps. -mkdir -p %{buildroot}%{_bindir} -for f in %{buildroot}%{install_bindir}/*; do - filename=`basename $f` - if [[ "$filename" == "clang-%{maj_ver}" ]]; then - continue - fi - # Add symlink for binaries with version suffix. - ln -s ../../%{install_bindir}/$filename %{buildroot}/%{_bindir}/$filename-%{maj_ver} - # For non-compat builds, also add a symlink without version suffix. - %if %{without compat_build} - ln -s ../../%{install_bindir}/$filename %{buildroot}/%{_bindir}/$filename - %endif -done - -# Move man pages to system install prefix. -mkdir -p %{buildroot}%{_mandir}/man1 -for f in %{buildroot}%{install_mandir}/man1/*; do - filename=`basename $f` - filename=${filename%.1} - mv $f %{buildroot}%{_mandir}/man1/$filename-%{maj_ver}.1 - %if %{without compat_build} - ln -s $filename-%{maj_ver}.1 %{buildroot}%{_mandir}/man1/$filename.1 - %endif -done -rmdir %{buildroot}%{install_mandir}/man1 -rmdir %{buildroot}%{install_mandir} - -%if %{without compat_build} -# We don't create directory symlinks, because RPM does not support -# switching between a directory and a symlink, causing upgrade/downgrade issues. -# Instead, recursively copy the directories while creating symlinks. -copy_with_relative_symlinks() { +# Move files from src to dest and replace the old files in src with relative +# symlinks. +move_and_replace_with_symlinks() { local src="$1" local dest="$2" mkdir -p "$dest" @@ -1843,22 +2101,65 @@ copy_with_relative_symlinks() { # Change to source directory to simplify relative paths (cd "$src" && \ find * -type d -exec mkdir -p "$dest/{}" \; && \ - find * \( -type f -o -type l \) -exec ln -s --relative "$src/{}" "$dest/{}" \;) + find * \( -type f -o -type l \) -exec mv "$src/{}" "$dest/{}" \; \ + -exec ln -s --relative "$dest/{}" "$src/{}" \;) } -# Add symlinks for libraries. -copy_with_relative_symlinks %{buildroot}%{install_libdir} %{buildroot}%{_libdir} -copy_with_relative_symlinks %{buildroot}%{install_libexecdir} %{buildroot}%{_libexecdir} -copy_with_relative_symlinks %{buildroot}%{install_includedir} %{buildroot}%{_includedir} -copy_with_relative_symlinks %{buildroot}%{install_datadir} %{buildroot}%{_datadir} +%if %{without compat_build} +# Move files from the llvm prefix to the system prefix and replace them with +# symlinks. We do it this way around because symlinks between multilib packages +# would conflict otherwise. +move_and_replace_with_symlinks %{buildroot}%{install_bindir} %{buildroot}%{_bindir} +move_and_replace_with_symlinks %{buildroot}%{install_libdir} %{buildroot}%{_libdir} +move_and_replace_with_symlinks %{buildroot}%{install_libexecdir} %{buildroot}%{_libexecdir} +move_and_replace_with_symlinks %{buildroot}%{install_includedir} %{buildroot}%{_includedir} +move_and_replace_with_symlinks %{buildroot}%{install_datadir} %{buildroot}%{_datadir} +%endif -%if %{maj_ver} >= 21 && %{with offload} -# Remove offload libaries since we only want to ship these in the configured -# install prefix. -rm -Rf %{buildroot}%{_libdir}/amdgcn-amd-amdhsa -rm -Rf %{buildroot}%{_libdir}/nvptx64-nvidia-cuda -%endif +# Create versioned symlinks for binaries. +# Do this at the end so it includes any files added by preceding steps. +mkdir -p %{buildroot}%{_bindir} +for f in %{buildroot}%{install_bindir}/*; do + filename=`basename $f` + if [[ "$filename" =~ ^(lit|ld|clang-%{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 + continue + fi + ln -s $filename %{buildroot}/%{_bindir}/$filename-%{maj_ver} + %endif +done + +mkdir -p %{buildroot}%{_mandir}/man1 +for f in %{buildroot}%{install_mandir}/man1/*; do + filename=`basename $f` + filename=${filename%.1} + %if %{with compat_build} + # Move man pages to system install prefix. + mv $f %{buildroot}%{_mandir}/man1/$filename-%{maj_ver}.1 + %else + # Create suffixed symlink. + ln -s $filename.1 %{buildroot}%{_mandir}/man1/$filename-%{maj_ver}.1 + %endif +done +rm -rf %{buildroot}%{install_mandir} + +# As an exception, always keep llvm-config in the versioned prefix. +# The llvm-config in the default prefix will be managed by alternatives. +%if %{without compat_build} +rm %{buildroot}%{install_bindir}/llvm-config +mv %{buildroot}%{_bindir}/llvm-config %{buildroot}%{install_bindir}/llvm-config %endif + +# ghost presence for llvm-config, managed by alternatives. +touch %{buildroot}%{_bindir}/llvm-config-%{maj_ver} +%if %{without compat_build} +touch %{buildroot}%{_bindir}/llvm-config %endif %if %{with bundle_compat_lib} @@ -2023,13 +2324,14 @@ export LIT_XFAIL="$LIT_XFAIL;api_tests/test_ompd_get_curr_parallel_handle.c" export LIT_XFAIL="$LIT_XFAIL;api_tests/test_ompd_get_display_control_vars.c" export LIT_XFAIL="$LIT_XFAIL;api_tests/test_ompd_get_thread_handle.c" +%if %{with pgo} +# TODO(kkleine): I unset LIT_XFAIL here because the tests above unexpectedly passed since Aug 16th on fedora-40-x86_64 +unset LIT_XFAIL +%endif + # The following test is flaky and we'll filter it out -test_list_filter_out+=("libomp :: ompt/teams/distribute_dispatch.c") test_list_filter_out+=("libomp :: affinity/kmp-abs-hw-subset.c") -test_list_filter_out+=("libomp :: parallel/bug63197.c") -test_list_filter_out+=("libomp :: tasking/issue-69733.c") -test_list_filter_out+=("libarcher :: races/task-taskgroup-unrelated.c") -test_list_filter_out+=("libarcher :: races/task-taskwait-nested.c") +test_list_filter_out+=("libomp :: ompt/teams/distribute_dispatch.c") # These tests fail more often than not, but not always. test_list_filter_out+=("libomp :: worksharing/for/omp_collapse_many_GELTGT_int.c") @@ -2037,22 +2339,31 @@ test_list_filter_out+=("libomp :: worksharing/for/omp_collapse_many_GTGEGT_int.c test_list_filter_out+=("libomp :: worksharing/for/omp_collapse_many_LTLEGE_int.c") test_list_filter_out+=("libomp :: worksharing/for/omp_collapse_one_int.c") +%if %{maj_ver} < 21 +# The following test is flaky and we'll filter it out +test_list_filter_out+=("libomp :: parallel/bug63197.c") +test_list_filter_out+=("libomp :: tasking/issue-69733.c") +test_list_filter_out+=("libarcher :: races/task-taskgroup-unrelated.c") + # The following tests have been failing intermittently. # Issue upstream: https://github.com/llvm/llvm-project/issues/127796 test_list_filter_out+=("libarcher :: races/task-two.c") test_list_filter_out+=("libarcher :: races/lock-nested-unrelated.c") +%endif %ifarch s390x test_list_filter_out+=("libomp :: flush/omp_flush.c") test_list_filter_out+=("libomp :: worksharing/for/omp_for_schedule_guided.c") %endif +%if %{maj_ver} < 21 %ifarch aarch64 s390x # The following test has been failing intermittently on aarch64 and s390x. # Re-enable it after https://github.com/llvm/llvm-project/issues/117773 # gets fixed. test_list_filter_out+=("libarcher :: races/taskwait-depend.c") %endif +%endif # The following tests seem pass on ppc64le and x86_64 and aarch64 only: %ifnarch ppc64le x86_64 s390x aarch64 @@ -2096,6 +2407,7 @@ export LIT_XFAIL="$LIT_XFAIL;races/task-dependency.c" export LIT_XFAIL="$LIT_XFAIL;races/task-taskgroup-unrelated.c" export LIT_XFAIL="$LIT_XFAIL;races/task-two.c" export LIT_XFAIL="$LIT_XFAIL;races/taskwait-depend.c" +export LIT_XFAIL="$LIT_XFAIL;races/task-taskwait-nested.c" export LIT_XFAIL="$LIT_XFAIL;reduction/parallel-reduction-nowait.c" export LIT_XFAIL="$LIT_XFAIL;reduction/parallel-reduction.c" export LIT_XFAIL="$LIT_XFAIL;task/omp_task_depend_all.c" @@ -2154,9 +2466,22 @@ export LIT_XFAIL="$LIT_XFAIL;offloading/thread_state_2.c" adjust_lit_filter_out test_list_filter_out +%if %{maj_ver} >= 21 +# This allows openmp tests to be re-run 4 times. Once they pass +# after being re-run, they are marked as FLAKYPASS. +# See https://github.com/llvm/llvm-project/pull/141851 for the +# --max-retries-per-test option. +# We don't know if 4 is the right number to use here we just +# need to start with some number. +# Once https://github.com/llvm/llvm-project/pull/142413 landed +# we can see the exact number of attempts the tests needed +# to pass. And then we can adapt this number. +export LIT_OPTS="$LIT_OPTS --max-retries-per-test=4" +%endif + %if 0%{?rhel} # libomp tests are often very slow on s390x brew builders -%ifnarch s390x +%ifnarch s390x riscv64 %cmake_build --target check-openmp %endif %else @@ -2281,14 +2606,42 @@ cp %{_vpath_builddir}/.ninja_log %{buildroot}%{_datadir} %ldconfig_scriptlets -n %{pkg_name_lld}-libs %endif +%post -n %{pkg_name_llvm}-devel +update-alternatives --install %{_bindir}/llvm-config-%{maj_ver} llvm-config-%{maj_ver} %{install_bindir}/llvm-config %{__isa_bits} %if %{without compat_build} -%pre -n %{pkg_name_llvm}-devel -# llvm-config used to be managed by alternatives. -# Remove them if they still exist. -update-alternatives --remove-all llvm-config 2>/dev/null || : -%if %{maj_ver} <= 20 -update-alternatives --remove-all llvm-config-%{maj_ver} 2>/dev/null || : +# Prioritize newer LLVM versions over older and 64-bit over 32-bit. +update-alternatives --install %{_bindir}/llvm-config llvm-config %{install_bindir}/llvm-config $((%{maj_ver}*100+%{__isa_bits})) + +# Remove old llvm-config-%{__isa_bits} alternative. This will only do something during the +# first upgrade from a version that used it. In all other cases it will error, so suppress the +# expected error message. +update-alternatives --remove llvm-config %{_bindir}/llvm-config-%{__isa_bits} 2>/dev/null ||: + +# During the upgrade from LLVM 16 (F38) to LLVM 17 (F39), we found out the +# main llvm-devel package was leaving entries in the alternatives system. +# Try to remove them now. +for v in 14 15 16; do + if [[ -e %{_bindir}/llvm-config-$v + && "x$(%{_bindir}/llvm-config-$v --version | awk -F . '{ print $1 }')" != "x$v" ]]; then + update-alternatives --remove llvm-config-$v %{install_bindir}/llvm-config%{exec_suffix}-%{__isa_bits} + fi +done %endif + +%postun -n %{pkg_name_llvm}-devel +if [ $1 -eq 0 ]; then + update-alternatives --remove llvm-config%{exec_suffix} %{install_bindir}/llvm-config +fi +%if %{without compat_build} +# There are a number of different cases here: +# Uninstall: Remove alternatives. +# Patch version upgrade: Keep alternatives. +# Major version upgrade with installation of compat package: Keep alternatives for compat package. +# Major version upgrade without installation of compat package: Remove alternatives. However, we +# can't distinguish it from the previous case, so we conservatively leave it behind. +if [ $1 -eq 0 ]; then + update-alternatives --remove llvm-config-%{maj_ver} %{install_bindir}/llvm-config +fi %endif %if %{without compat_build} @@ -2309,24 +2662,20 @@ fi local maj_ver = rpm.expand("%{maj_ver}") for arg in rpm.expand("%*"):gmatch("%S+") do print(install_bindir .. "/" .. arg .. "\\n") - if not rpm.expand("%{ix86}"):find(rpm.expand("%{_arch}")) then - print(bindir .. "/" .. arg .. "-" .. maj_ver .. "\\n") - if rpm.expand("%{without compat_build}") == "1" then - print(bindir .. "/" .. arg .. "\\n") - end + print(bindir .. "/" .. arg .. "-" .. maj_ver .. "\\n") + if rpm.expand("%{without compat_build}") == "1" then + print(bindir .. "/" .. arg .. "\\n") end end } %define expand_mans() %{lua: - if not rpm.expand("%{ix86}"):find(rpm.expand("%{_arch}")) then - local mandir = rpm.expand("%{_mandir}") - local maj_ver = rpm.expand("%{maj_ver}") - for arg in rpm.expand("%*"):gmatch("%S+") do - print(mandir .. "/man1/" .. arg .. "-" .. maj_ver .. ".1.gz\\n") - if rpm.expand("%{without compat_build}") == "1" then - print(mandir .. "/man1/" .. arg .. ".1.gz\\n") - end + local mandir = rpm.expand("%{_mandir}") + local maj_ver = rpm.expand("%{maj_ver}") + for arg in rpm.expand("%*"):gmatch("%S+") do + print(mandir .. "/man1/" .. arg .. "-" .. maj_ver .. ".1.gz\\n") + if rpm.expand("%{without compat_build}") == "1" then + print(mandir .. "/man1/" .. arg .. ".1.gz\\n") end end } @@ -2336,8 +2685,7 @@ fi local install_dir = rpm.expand("%{-i*}") for arg in rpm.expand("%*"):gmatch("%S+") do print(install_dir .. "/" .. arg .. "\\n") - if rpm.expand("%{without compat_build}") == "1" and - not rpm.expand("%{ix86}"):find(rpm.expand("%{_arch}")) then + if rpm.expand("%{without compat_build}") == "1" then print(dir .. "/" .. arg .. "\\n") end end @@ -2467,6 +2815,12 @@ fi }} %endif +%if %{maj_ver} >= 22 +%{expand_bins %{expand: + llvm-ir2vec +}} +%endif + %{expand_mans %{expand: bugpoint clang-tblgen @@ -2525,6 +2879,12 @@ fi tblgen }} +%if %{maj_ver} >= 22 +%{expand_mans %{expand: + llvm-ir2vec +}} +%endif + %expand_datas opt-viewer %files -n %{pkg_name_llvm}-libs @@ -2552,7 +2912,12 @@ fi %files -n %{pkg_name_llvm}-devel %license llvm/LICENSE.TXT -%expand_bins llvm-config +%{install_bindir}/llvm-config +%ghost %{_bindir}/llvm-config-%{maj_ver} +%if %{without compat_build} +%ghost %{_bindir}/llvm-config +%endif + %expand_mans llvm-config %expand_includes llvm llvm-c %{expand_libs %{expand: @@ -2570,11 +2935,9 @@ fi %exclude %{install_libdir}/libLLVMTestingSupport.a %exclude %{install_libdir}/libLLVMTestingAnnotations.a %if %{without compat_build} -%ifnarch %{ix86} %exclude %{_libdir}/libLLVMTestingSupport.a %exclude %{_libdir}/libLLVMTestingAnnotations.a %endif -%endif %files -n %{pkg_name_llvm}-cmake-utils %license llvm/LICENSE.TXT @@ -2590,6 +2953,14 @@ fi llvm-isel-fuzzer llvm-opt-fuzzer }} +%if %{maj_ver} >= 21 +%{expand_bins %{expand: + llvm-test-mustache-spec +}} +%{expand_mans %{expand: + llvm-test-mustache-spec +}} +%endif %files -n %{pkg_name_llvm}-googletest %license llvm/LICENSE.TXT @@ -2629,6 +3000,14 @@ fi %endif %{expand_mans clang clang++} +%if 0%{with pgo} +%{expand_datas %{expand: llvm-pgo.profdata }} +%if 0%{run_pgo_perf_comparison} +%{expand_datas %{expand: results-system-vs-pgo.txt }} +%endif +%endif + + %files -n %{pkg_name_clang}-libs %license clang/LICENSE.TXT %{_prefix}/lib/clang/%{maj_ver}/include/* @@ -2659,10 +3038,8 @@ fi %expand_bins clang-tblgen %dir %{install_datadir}/clang/ %if %{without compat_build} -%ifnarch %{ix86} %dir %{_datadir}/clang %endif -%endif %files -n %{pkg_name_clang}-resource-filesystem %license clang/LICENSE.TXT @@ -2791,7 +3168,7 @@ fi %{_prefix}/lib/clang/%{maj_ver}/lib/%{compiler_rt_triple}/clang_rt.crtend.o %endif -%ifnarch %{ix86} s390x +%ifnarch %{ix86} s390x riscv64 %{_prefix}/lib/clang/%{maj_ver}/lib/%{compiler_rt_triple}/liborc_rt.a %endif @@ -2837,10 +3214,12 @@ fi libomptarget-nvptx*.bc }} %else -%{install_libdir}/amdgcn-amd-amdhsa/libompdevice.a -%{install_libdir}/amdgcn-amd-amdhsa/libomptarget-amdgpu.bc -%{install_libdir}/nvptx64-nvidia-cuda/libompdevice.a -%{install_libdir}/nvptx64-nvidia-cuda/libomptarget-nvptx.bc +%{expand_libs %{expand: + amdgcn-amd-amdhsa/libompdevice.a + amdgcn-amd-amdhsa/libomptarget-amdgpu.bc + nvptx64-nvidia-cuda/libompdevice.a + nvptx64-nvidia-cuda/libomptarget-nvptx.bc +}} %endif %expand_includes offload @@ -3076,6 +3455,9 @@ fi #region changelog %changelog +* Wed Jul 30 2025 Tom Stellard - 20.1.8-1 +- LLVM 20.1.8 relase + * Mon Jul 28 2025 Tom Stellard - 20.1.4-2 - Remove bundled llvm19 compat package diff --git a/rpminspect.yaml b/rpminspect.yaml index 18c241f..3f5febc 100644 --- a/rpminspect.yaml +++ b/rpminspect.yaml @@ -1,4 +1,9 @@ --- +inspections: + # We need to disable abidiff due to abidiff+testing-farm issues. Ref link: + # https://docs.testing-farm.io/Testing%20Farm/0.1/errors.html#TFE-1 + abidiff: off + badfuncs: # For compiler-rt, we allow the following forbidden functions: # - gethostbyname diff --git a/sources b/sources index 280ad53..e7847bf 100644 --- a/sources +++ b/sources @@ -1,4 +1,2 @@ -SHA512 (llvm-project-20.1.4.src.tar.xz) = acace8175a5468c7e84a89d1564e147e81fe92b6d910f22b058edf72094b27176677c06dbe141fccfbabdad77165f957bbf1ec8aff7bffc85f0757c0103f7e59 -SHA512 (llvm-project-20.1.4.src.tar.xz.sig) = 634414ea877724ebdeeabe3bb1079d78938aa05dba2243d5458cf211c35444124dc01fa73a593548290196f8c0e40e1e6a4a72571dba4b716b5781c656c6f9b2 -SHA512 (llvm-project-19.1.7.src.tar.xz) = c7d63286d662707a9cd54758c9e3aaf52794a91900c484c4a6efa62d90bc719d5e7a345e4192feeb0c9fd11c82570d64677c781e5be1d645556b6aa018e47ec8 -SHA512 (llvm-project-19.1.7.src.tar.xz.sig) = 195797b06ac80a742e0ccbc03a50dc06dd2e04377d783d5474e3e72c5a75203b60292b047929312a411d22b137a239943fba414a4d136a2be14cbff978eb6bda +SHA512 (llvm-project-20.1.8.src.tar.xz) = f330e72e6a1da468569049437cc0ba7a41abb816ccece7367189344f7ebfef730f4788ac7af2bef0aa8a49341c15ab1d31e941ffa782f264d11fe0dc05470773 +SHA512 (llvm-project-20.1.8.src.tar.xz.sig) = d74369bdb4d1b82775161ea53c9c5f3a23ce810f4df5ff617123023f9d8ce720e7d6ecc9e17f8ebd39fd9e7a9de79560abdf2ffe73bcb907a43148d43665d619 diff --git a/tests/README.md b/tests/README.md index 26a7ffb..042b179 100644 --- a/tests/README.md +++ b/tests/README.md @@ -1,9 +1,9 @@ # Gating testplans for LLVM -The tests for LLVM are in a dedicated, separate repo: https://gitlab.com/redhat/centos-stream/tests/llvm.git +The tests for LLVM are in a separate repo: + +* llvm: https://src.fedoraproject.org/tests/llvm.git/ This directory should contain only fmf plans (such as build-gating.fmf) which import the tests from the tests repo. This can be done using the "url" parameter of the -plan's "discover" step. - -Reference: https://tmt.readthedocs.io/en/stable/spec/plans.html#fmf +plan's "discover" step. Reference: https://tmt.readthedocs.io/en/stable/spec/plans.html#fmf