The package rpms/llvm.git has added or updated architecture specific content in its spec file (ExclusiveArch/ExcludeArch or %ifarch/%ifnarch) in commit(s): https://src.fedoraproject.org/cgit/rpms/llvm.git/commit/?id=a7997da77298f4e8....
Change: +%ifarch %{ix86}
Thanks.
Full change: ============
commit c27c4368842ba45e03e40bd762235a1ff9dc39cb Author: Nikita Popov npopov@redhat.com Date: Fri May 30 10:35:50 2025 +0200
Update to LLVM 20.1.6
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 tstellar@redhat.com -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/3f29acb51739a3e6bfb8cc623eb37cb734c98a63.patch b/3f29acb51739a3e6bfb8cc623eb37cb734c98a63.patch deleted file mode 100644 index 2ce6f4b..0000000 --- a/3f29acb51739a3e6bfb8cc623eb37cb734c98a63.patch +++ /dev/null @@ -1,28 +0,0 @@ -From 3f29acb51739a3e6bfb8cc623eb37cb734c98a63 Mon Sep 17 00:00:00 2001 -From: Nikita Popov npopov@redhat.com -Date: Mon, 26 May 2025 09:43:00 +0200 -Subject: [PATCH] [MachO] Improve bounds check (#141083) - -The current check may fail if the addition overflows. I've observed -failures of macho-invalid.test on 32-bit due to this. - -Instead, compare against the remaining bytes until the end of the -object. ---- - llvm/lib/Object/MachOObjectFile.cpp | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -diff --git a/llvm/lib/Object/MachOObjectFile.cpp b/llvm/lib/Object/MachOObjectFile.cpp -index 69d36e6a77db7..5db264207ffb7 100644 ---- a/llvm/lib/Object/MachOObjectFile.cpp -+++ b/llvm/lib/Object/MachOObjectFile.cpp -@@ -192,7 +192,8 @@ static ExpectedMachOObjectFile::LoadCommandInfo - getLoadCommandInfo(const MachOObjectFile &Obj, const char *Ptr, - uint32_t LoadCommandIndex) { - if (auto CmdOrErr = getStructOrErrMachO::load_command(Obj, Ptr)) { -- if (CmdOrErr->cmdsize + Ptr > Obj.getData().end()) -+ assert(Ptr <= Obj.getData().end() && "Start must be before end"); -+ if (CmdOrErr->cmdsize > (uintptr_t)(Obj.getData().end() - Ptr)) - return malformedError("load command " + Twine(LoadCommandIndex) + - " extends past end of file"); - if (CmdOrErr->cmdsize < 8) diff --git a/ff2e8f93f6090965e82d799af43f6dfef52baa66.patch b/ff2e8f93f6090965e82d799af43f6dfef52baa66.patch deleted file mode 100644 index e93b84c..0000000 --- a/ff2e8f93f6090965e82d799af43f6dfef52baa66.patch +++ /dev/null @@ -1,22 +0,0 @@ -From ff2e8f93f6090965e82d799af43f6dfef52baa66 Mon Sep 17 00:00:00 2001 -From: Douglas Yung douglas.yung@sony.com -Date: Wed, 7 May 2025 06:13:07 +0000 -Subject: [PATCH] Fix test pfalse-v4i1.ll added in #138712 to require asserts. - -Should fix build bot failure: https://lab.llvm.org/buildbot/#/builders/202/builds/1102 - -(cherry picked from commit 194a4a333a95f9e001d2c8abe82c3d4cf8894acf) ---- - llvm/test/CodeGen/Hexagon/isel/pfalse-v4i1.ll | 1 + - 1 file changed, 1 insertion(+) - -diff --git a/llvm/test/CodeGen/Hexagon/isel/pfalse-v4i1.ll b/llvm/test/CodeGen/Hexagon/isel/pfalse-v4i1.ll -index c0904b8b4fdd6..2c26bb1e310ea 100644 ---- a/llvm/test/CodeGen/Hexagon/isel/pfalse-v4i1.ll -+++ b/llvm/test/CodeGen/Hexagon/isel/pfalse-v4i1.ll -@@ -1,4 +1,5 @@ - ; RUN: llc -march=hexagon -debug-only=isel 2>&1 < %s - | FileCheck %s -+; REQUIRES: asserts - - ; CHECK: [[R0:%[0-9]+]]:intregs = A2_tfrsi 0 - ; CHECK-NEXT: predregs = C2_tfrrp killed [[R0]]:intregs diff --git a/llvm.spec b/llvm.spec index 953631c..f32aebd 100644 --- a/llvm.spec +++ b/llvm.spec @@ -2,7 +2,7 @@ #region version %global maj_ver 20 %global min_ver 1 -%global patch_ver 5 +%global patch_ver 6 #global rc_ver 3
%bcond_with snapshot_build @@ -328,7 +328,7 @@ #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 @@ -399,19 +399,10 @@ 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 release build test failure on LLVM 20.1.5. -Patch2009: ff2e8f93f6090965e82d799af43f6dfef52baa66.patch -# Fix macho-invalid.test failure on i686. -Patch2010: 3f29acb51739a3e6bfb8cc623eb37cb734c98a63.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 @@ -3402,6 +3393,9 @@ fi
#region changelog %changelog +* Fri May 30 2025 Nikita Popov npopov@redhat.com - 20.1.6-1 +- Update to LLVM 20.1.6 + * Mon May 26 2025 Konrad Kleine kkleine@redhat.com - 20.1.5-2 - Build with PGO
diff --git a/sources b/sources index 8b54d1f..5f8b3c5 100644 --- a/sources +++ b/sources @@ -1,2 +1,2 @@ -SHA512 (llvm-project-20.1.5.src.tar.xz) = 3b7e657714fa9b943c75ec9eeb903018ab4713b1c3370746ba68893220729f178dabb971515741519f24e7ad0fa1dbce1345572bcf1d1fc1e5de97e4d2900a6b -SHA512 (llvm-project-20.1.5.src.tar.xz.sig) = c1bd30af5f7bfa6cac73994e9068d2791d9d27e86375fb15ad426422ad00cb43ade226c1b91ecc7daa950efae62c86300e4290d59649310f4e8fab5bdcb264fe +SHA512 (llvm-project-20.1.6.src.tar.xz) = aae652fdc61bda3f80b1340a3270b687355bfb6817f4bc05dac2268a2f8c5fc677eadb515cda7c8518005f1dc39e7ce5d1c34bbc5a25f106ef8e6c8f1ecfdf6d +SHA512 (llvm-project-20.1.6.src.tar.xz.sig) = 0884048ff164a1f5caed0f1aabec173630a08ece98cf793d21b77fc969501e4f03daec39ae0fb124ad34a3436ceae66452e36a42c309f19790b7a87652482691
commit f422c621c686267d51338e032ee9d135ec76a083 Author: Konrad Kleine kkleine@redhat.com Date: Fri May 23 10:16:34 2025 +0200
[make] Add mock-install-debugging-tools target
diff --git a/Makefile b/Makefile index 4f62243..ced0465 100644 --- a/Makefile +++ b/Makefile @@ -108,6 +108,17 @@ mockbuild-rerun-last-script: get-last-run-script 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.
commit a7997da77298f4e81519f6db7817b9ed102cc981 Author: Konrad Kleine kkleine@redhat.com Date: Mon Oct 7 20:05:33 2024 +0000
Bring in PGO (Profile Guided Optimization)
This enable PGO (Profile Guided Optimization) on Fedora >=41 and RHEL >= 9 for non x86 machines.
This is a four step process:
1. We use the system clang compiler to build an instrumented version of LLVM. The first build of LLVM is rather small because it only features the native subset of targets to build (`LLVM_TARGETS_TO_BUILD=Native`) and no tests or whatsoever is built. 2. We run a special `cmake` target (`generate-profdata`) that collects profile data information. Eventually this information is also packaged as `llvm-pgo.profdata`. 3. We feed the profile information into another final build of LLVM that gets packaged later. 4. If we are on a platform that provides the `llvm-test-suite` package we run a performance comparison of the system compiler against the PGOed compiler. This is meant as a sanity check. We package the output of that comparison (if available) as `results-system-vs-pgo.txt`. The criteria to run this performance comparison is influenced by the `run_pgo_perf_comparison` global. For snapshot builds we even run the comparison for RHEL platforms where usually the `llvm-test-suite` is not available. There we provide it through this COPR project: [@fedora-llvm-team/llvm-test-suite](https://copr.fedorainfracloud.org/coprs/g/fedora-llvm-team/llvm-test-suite/).
We pass `--build-id=sha1` to lld when building final stage with PGO 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: We decided to not do a bootstrap build of clang.
NOTE: To disable PGO change `%bcond_without pgo` to `%bcond_with pgo` in the one line where it is conditionally defined. All the relevant changes are build-condition fenced with `%if %{with pgo}`.
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/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 kkleine@redhat.com +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/Makefile b/Makefile index 902d857..4f62243 100644 --- a/Makefile +++ b/Makefile @@ -103,6 +103,11 @@ 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 + .PHONY: help # Based on https://gist.github.com/rcmachado/af3db315e31383502660 ## Display this help text. diff --git a/llvm.spec b/llvm.spec index 01cde13..953631c 100644 --- a/llvm.spec +++ b/llvm.spec @@ -94,6 +94,33 @@ %bcond_with polly %endif
+#region pgo +%ifarch %{ix86} +%bcond_with pgo +%else +%if 0%{?fedora} >= 43 || 0%{?rhel} >= 9 +%bcond_without pgo +%else +%bcond_with pgo +%endif +%endif + +%if %{with pgo} && (0%{undefined rhel} || 0%{with snapshot_build}) +%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 +128,25 @@ %bcond_without lto_build %endif
-%if %{without lto_build} +# For easier reasoning about the build configuration, print all build conditions +%{echo:Build conditions:} +%{echo:build_bolt = %{with build_bolt}} +%{echo:bundle_compat_lib = %{with bundle_compat_lib}} +%{echo:check = %{with check}} +%{echo:compat_build = %{with compat_build}} +%{echo:gold = %{with gold}} +%{echo:libcxx = %{with libcxx}} +%{echo:lldb = %{with lldb}} +%{echo:lto_build = %{with lto_build}} +%{echo:mlir = %{with mlir}} +%{echo:pgo = %{with pgo}} +%{echo:polly = %{with polly}} +%{echo:python_lit = %{with python_lit}} +%{echo:snapshot_build = %{with snapshot_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 +196,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} @@ -261,13 +315,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: 1%{?dist} +Release: 2%{?dist} Summary: The Low Level Virtual Machine
License: Apache-2.0 WITH LLVM-exception OR NCSA @@ -324,6 +385,10 @@ 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 +# Can be removed if https://github.com/llvm/llvm-project/pull/131099 lands in v21: +Patch2102: 20-131099.patch +#endregion CLANG patches
# Workaround a bug in ORC on ppc64le. # More info is available here: https://reviews.llvm.org/D159115#4641826 @@ -394,6 +459,27 @@ BuildRequires: zlib-devel BuildRequires: libzstd-devel BuildRequires: libffi-devel BuildRequires: ncurses-devel + +%if %{with pgo} +BuildRequires: lld +BuildRequires: compiler-rt + +%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 @@ -1217,6 +1303,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 @@ -1463,7 +1560,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=<n> 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=<n> 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 @@ -1489,8 +1705,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 .. @@ -1613,6 +1895,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. @@ -2028,6 +2318,11 @@ 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") @@ -2654,6 +2949,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/* @@ -3099,6 +3402,9 @@ fi
#region changelog %changelog +* Mon May 26 2025 Konrad Kleine kkleine@redhat.com - 20.1.5-2 +- Build with PGO + * Thu May 22 2025 Nikita Popov npopov@redhat.com - 20.1.5-1 - Update to LLVM 20.1.5
commit f924fc03691b1f53f4df833b03567583dcc61532 Author: Nikita Popov npopov@redhat.com Date: Mon May 26 11:31:32 2025 +0200
Backport patch for i686 test failure
Backport of https://github.com/llvm/llvm-project/pull/141083, which fixes the test failure observed on i686 rawhide when building LLVM 20.1.5.
diff --git a/3f29acb51739a3e6bfb8cc623eb37cb734c98a63.patch b/3f29acb51739a3e6bfb8cc623eb37cb734c98a63.patch new file mode 100644 index 0000000..2ce6f4b --- /dev/null +++ b/3f29acb51739a3e6bfb8cc623eb37cb734c98a63.patch @@ -0,0 +1,28 @@ +From 3f29acb51739a3e6bfb8cc623eb37cb734c98a63 Mon Sep 17 00:00:00 2001 +From: Nikita Popov npopov@redhat.com +Date: Mon, 26 May 2025 09:43:00 +0200 +Subject: [PATCH] [MachO] Improve bounds check (#141083) + +The current check may fail if the addition overflows. I've observed +failures of macho-invalid.test on 32-bit due to this. + +Instead, compare against the remaining bytes until the end of the +object. +--- + llvm/lib/Object/MachOObjectFile.cpp | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/llvm/lib/Object/MachOObjectFile.cpp b/llvm/lib/Object/MachOObjectFile.cpp +index 69d36e6a77db7..5db264207ffb7 100644 +--- a/llvm/lib/Object/MachOObjectFile.cpp ++++ b/llvm/lib/Object/MachOObjectFile.cpp +@@ -192,7 +192,8 @@ static ExpectedMachOObjectFile::LoadCommandInfo + getLoadCommandInfo(const MachOObjectFile &Obj, const char *Ptr, + uint32_t LoadCommandIndex) { + if (auto CmdOrErr = getStructOrErrMachO::load_command(Obj, Ptr)) { +- if (CmdOrErr->cmdsize + Ptr > Obj.getData().end()) ++ assert(Ptr <= Obj.getData().end() && "Start must be before end"); ++ if (CmdOrErr->cmdsize > (uintptr_t)(Obj.getData().end() - Ptr)) + return malformedError("load command " + Twine(LoadCommandIndex) + + " extends past end of file"); + if (CmdOrErr->cmdsize < 8) diff --git a/llvm.spec b/llvm.spec index 6e6fa97..01cde13 100644 --- a/llvm.spec +++ b/llvm.spec @@ -344,6 +344,8 @@ Patch2108: 0001-sanitizer_common-Disable-termio-ioctls-on-PowerPC.patch
# Fix release build test failure on LLVM 20.1.5. Patch2009: ff2e8f93f6090965e82d799af43f6dfef52baa66.patch +# Fix macho-invalid.test failure on i686. +Patch2010: 3f29acb51739a3e6bfb8cc623eb37cb734c98a63.patch
# Fix LLVMConfig.cmake when symlinks are used. # (https://github.com/llvm/llvm-project/pull/124743 landed in LLVM 21)
arch-excludes@lists.fedoraproject.org