From a9f6c9b581ca6113b0cc56db66992cab69e1a3c2 Mon Sep 17 00:00:00 2001 From: liyunfei Date: Wed, 20 Aug 2025 16:43:18 +0800 Subject: [PATCH 1/8] fix missing hardening compiler options --- llvm.spec | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/llvm.spec b/llvm.spec index 20a1311..9a340bb 100644 --- a/llvm.spec +++ b/llvm.spec @@ -6,6 +6,10 @@ %global os_version %{lua: print(tonumber(rpm.expand("%{dist}"):match("oe(%d+)") or 9999))} +%if %{os_version} == 1 +%global os_version 9999 +%endif + # Build sys_llvm packages or compat packages %bcond_without sys_llvm %bcond_without check @@ -99,8 +103,6 @@ %global pkg_name_compiler_rt %{?scl_prefix}compiler-rt -%global optflags %(echo %{optflags} | sed 's/-fgcc-compatible//') -%global optflags %(echo %{optflags} | sed 's/-specs=\/usr\/lib\/rpm\/generic-hardened-cc1//') %ifnarch x86_64 %global optflags %(echo %{optflags} | sed 's/-fstack-clash-protection//') # may affect cmake check for fpic @@ -151,7 +153,7 @@ Name: llvm Name: llvm-toolset-%{maj_ver} %endif Version: %{maj_ver}.%{min_ver}.%{patch_ver} -Release: 45 +Release: 46 Summary: The Low Level Virtual Machine License: NCSA @@ -797,9 +799,6 @@ Documentation for LLVM libunwind %global runtimes %{runtimes};libcxx;libcxxabi;libunwind %endif -# Copy CFLAGS into ASMFLAGS, so -fcf-protection is used when compiling assembly files. -export ASMFLAGS="%{build_cflags}" - # We set CLANG_DEFAULT_PIE_ON_LINUX=OFF and PPC_LINUX_DEFAULT_IEEELONGDOUBLE=ON to match the # defaults used by Fedora's GCC. @@ -1015,6 +1014,11 @@ export ASMFLAGS="%{build_cflags}" extra_cmake_args='' #endregion cmake options +# set flags for build +export CFLAGS="%{build_cflags}" +export CXXFLAGS="%{build_cxxflags}" +export ASMFLAGS="%{build_cflags}" + %if %{with ACPO} echo "enable ACPO" export CFLAGS="-Wp,-DENABLE_ACPO ${CFLAGS}" @@ -2878,6 +2882,9 @@ fi #endregion files %changelog +* Wed Aug 20 2025 liyunfei - 17.0.6-46 +- fix missing hardening compiler options + * Wed Jun 18 2025 liyunfei - 17.0.6-45 - update to llvm-for-oe-17.0.6-2506.0.4 - release-note https://gitee.com/openeuler/llvm-project/releases/tag/llvm-for-oE-17.0.6-2506.0.4 -- Gitee From 945758f5cd8c220726547246622c5a0220e1499b Mon Sep 17 00:00:00 2001 From: liyunfei Date: Wed, 27 Aug 2025 17:06:15 +0800 Subject: [PATCH 2/8] update to llvm-for-oe-17.0.6-2509.0.1 --- ...er-bugfix-for-MachineBasicBlock-hash-set.patch | 15 +++++++++++++++ ...4.tar.gz => llvm-for-oE-17.0.6-2509.0.1.tar.gz | 4 ++-- llvm.spec | 11 ++++++++--- 3 files changed, 25 insertions(+), 5 deletions(-) create mode 100644 0006-Propeller-bugfix-for-MachineBasicBlock-hash-set.patch rename llvm-for-oE-17.0.6-2506.0.4.tar.gz => llvm-for-oE-17.0.6-2509.0.1.tar.gz (32%) diff --git a/0006-Propeller-bugfix-for-MachineBasicBlock-hash-set.patch b/0006-Propeller-bugfix-for-MachineBasicBlock-hash-set.patch new file mode 100644 index 0000000..e91b8c4 --- /dev/null +++ b/0006-Propeller-bugfix-for-MachineBasicBlock-hash-set.patch @@ -0,0 +1,15 @@ +diff --git a/llvm/lib/CodeGen/BasicBlockSections.cpp b/llvm/lib/CodeGen/BasicBlockSections.cpp +index 9b985f9f0aff..6e58c8fb2946 100644 +--- a/llvm/lib/CodeGen/BasicBlockSections.cpp ++++ b/llvm/lib/CodeGen/BasicBlockSections.cpp +@@ -319,7 +319,8 @@ void computeBBHash(MachineFunction &MF) { + } + } + } +- MBB.setHash(Hash); ++ if (MBB.getBBID()) ++ MBB.setHash(Hash); + } + } + +-- \ No newline at end of file diff --git a/llvm-for-oE-17.0.6-2506.0.4.tar.gz b/llvm-for-oE-17.0.6-2509.0.1.tar.gz similarity index 32% rename from llvm-for-oE-17.0.6-2506.0.4.tar.gz rename to llvm-for-oE-17.0.6-2509.0.1.tar.gz index 171f896..df9aef5 100644 --- a/llvm-for-oE-17.0.6-2506.0.4.tar.gz +++ b/llvm-for-oE-17.0.6-2509.0.1.tar.gz @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:db05405706279885e543dd562d7f2887fd433eb10dae819811df7d588e8548b3 -size 212541296 +oid sha256:3437c2ca8c6e2fc0083e3db05e884bd5cd2c124ba51b902a8cb2e5bb13312a04 +size 212672038 diff --git a/llvm.spec b/llvm.spec index 9a340bb..f77fbe3 100644 --- a/llvm.spec +++ b/llvm.spec @@ -31,7 +31,7 @@ %undefine __cmake_in_source_build -%global src_tarball llvm-for-oE-17.0.6-2506.0.4 +%global src_tarball llvm-for-oE-17.0.6-2509.0.1 %global src_tarball_dir llvm-project-%{src_tarball} #region LLVM globals @@ -153,7 +153,7 @@ Name: llvm Name: llvm-toolset-%{maj_ver} %endif Version: %{maj_ver}.%{min_ver}.%{patch_ver} -Release: 46 +Release: 47 Summary: The Low Level Virtual Machine License: NCSA @@ -175,6 +175,7 @@ Patch0004: 0004-remove-cmake_minimum_required.patch %if %{with bisheng_autotuner} Patch0005: 0005-Fix-for-building-autotuner-with-mlir.patch %endif +Patch0006: 0006-Propeller-bugfix-for-MachineBasicBlock-hash-set.patch BuildRequires: gcc BuildRequires: gcc-c++ @@ -1663,7 +1664,7 @@ reset_test_opts #region Test LLVM reset_test_opts # Xfail testing of update utility tools -export LIT_XFAIL="tools/UpdateTestChecks" +export LIT_XFAIL="tools/UpdateTestChecks;CodeGen/Hexagon/loop-prefetch.ll" %build_tool %cmake_target_opts check-llvm #endregion Test LLVM @@ -2882,6 +2883,10 @@ fi #endregion files %changelog +* Wed Aug 27 2025 liyunfei - 17.0.6-47 +- update to llvm-for-oe-17.0.6-2509.0.1 +- release-note https://gitee.com/openeuler/llvm-project/releases/tag/llvm-for-oE-17.0.6-2509.0.1 + * Wed Aug 20 2025 liyunfei - 17.0.6-46 - fix missing hardening compiler options -- Gitee From 1b25e920df0bdde06850f30b2c8f8e930d758b89 Mon Sep 17 00:00:00 2001 From: liyunfei Date: Tue, 2 Sep 2025 11:25:57 +0800 Subject: [PATCH 3/8] add fix for pie hardening --- llvm.spec | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/llvm.spec b/llvm.spec index f77fbe3..33fcd86 100644 --- a/llvm.spec +++ b/llvm.spec @@ -153,7 +153,7 @@ Name: llvm Name: llvm-toolset-%{maj_ver} %endif Version: %{maj_ver}.%{min_ver}.%{patch_ver} -Release: 47 +Release: 48 Summary: The Low Level Virtual Machine License: NCSA @@ -834,7 +834,7 @@ Documentation for LLVM libunwind %global cmake_config_args %{cmake_config_args} \\\ -DCLANG_BUILD_EXAMPLES:BOOL=OFF \\\ -DCLANG_CONFIG_FILE_SYSTEM_DIR=%{_sysconfdir}/%{pkg_name_clang}/ \\\ - -DCLANG_DEFAULT_PIE_ON_LINUX=OFF \\\ + -DCLANG_DEFAULT_PIE_ON_LINUX=ON \\\ -DCLANG_DEFAULT_UNWINDLIB=libgcc \\\ -DCLANG_ENABLE_ARCMT:BOOL=ON \\\ -DCLANG_ENABLE_STATIC_ANALYZER:BOOL=ON \\\ @@ -2883,6 +2883,9 @@ fi #endregion files %changelog +* Tue Sep 02 2025 liyunfei - 17.0.6-48 +- add fix for pie hardening + * Wed Aug 27 2025 liyunfei - 17.0.6-47 - update to llvm-for-oe-17.0.6-2509.0.1 - release-note https://gitee.com/openeuler/llvm-project/releases/tag/llvm-for-oE-17.0.6-2509.0.1 -- Gitee From 1448b04681f6c490eb40d97f40a0e9b93841c0b4 Mon Sep 17 00:00:00 2001 From: Xu Jin Date: Wed, 3 Sep 2025 15:38:46 +0800 Subject: [PATCH 4/8] remove rpath for openmp library --- llvm.spec | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/llvm.spec b/llvm.spec index 33fcd86..f8cb12d 100644 --- a/llvm.spec +++ b/llvm.spec @@ -153,7 +153,7 @@ Name: llvm Name: llvm-toolset-%{maj_ver} %endif Version: %{maj_ver}.%{min_ver}.%{patch_ver} -Release: 48 +Release: 49 Summary: The Low Level Virtual Machine License: NCSA @@ -1220,6 +1220,15 @@ cd %{build_src_dir} mkdir -p %{buildroot}/%{_bindir} +# Remove rpath for openmp library +%ifnarch %{ix86} %{arm} riscv64 loongarch64 +%global openmp_library libomptarget.rtl.cuda.so.17 libomptarget.rtl.%{_arch}.so.17 libomptarget.so.17 +for f in %{openmp_library} +do + chrpath --delete %{buildroot}%{install_libdir}/$f +done +%endif + # Install binaries needed for lit tests %global test_binaries llvm-isel-fuzzer llvm-opt-fuzzer @@ -2883,6 +2892,9 @@ fi #endregion files %changelog +* Tue Sep 02 2025 Xu Jin - 17.0.6-49 +- remove rpath for openmp library + * Tue Sep 02 2025 liyunfei - 17.0.6-48 - add fix for pie hardening -- Gitee From aabda0e7f7a0c15dd5c01c58e66e8e3ee7e9d266 Mon Sep 17 00:00:00 2001 From: liyunfei Date: Tue, 9 Sep 2025 20:22:35 +0800 Subject: [PATCH 5/8] update to llvm-for-oe-17.0.6-2509.0.2 --- ...09.0.1.tar.gz => llvm-for-oE-17.0.6-2509.0.2.tar.gz | 4 ++-- llvm.spec | 10 +++++++--- 2 files changed, 9 insertions(+), 5 deletions(-) rename llvm-for-oE-17.0.6-2509.0.1.tar.gz => llvm-for-oE-17.0.6-2509.0.2.tar.gz (32%) diff --git a/llvm-for-oE-17.0.6-2509.0.1.tar.gz b/llvm-for-oE-17.0.6-2509.0.2.tar.gz similarity index 32% rename from llvm-for-oE-17.0.6-2509.0.1.tar.gz rename to llvm-for-oE-17.0.6-2509.0.2.tar.gz index df9aef5..d569759 100644 --- a/llvm-for-oE-17.0.6-2509.0.1.tar.gz +++ b/llvm-for-oE-17.0.6-2509.0.2.tar.gz @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:3437c2ca8c6e2fc0083e3db05e884bd5cd2c124ba51b902a8cb2e5bb13312a04 -size 212672038 +oid sha256:717518c4ddf31b5d141fce1bdac7ede96a59de292f09f72482277ca0a49f489b +size 212666397 diff --git a/llvm.spec b/llvm.spec index f8cb12d..abeda6f 100644 --- a/llvm.spec +++ b/llvm.spec @@ -31,7 +31,7 @@ %undefine __cmake_in_source_build -%global src_tarball llvm-for-oE-17.0.6-2509.0.1 +%global src_tarball llvm-for-oE-17.0.6-2509.0.2 %global src_tarball_dir llvm-project-%{src_tarball} #region LLVM globals @@ -153,7 +153,7 @@ Name: llvm Name: llvm-toolset-%{maj_ver} %endif Version: %{maj_ver}.%{min_ver}.%{patch_ver} -Release: 49 +Release: 50 Summary: The Low Level Virtual Machine License: NCSA @@ -1673,7 +1673,7 @@ reset_test_opts #region Test LLVM reset_test_opts # Xfail testing of update utility tools -export LIT_XFAIL="tools/UpdateTestChecks;CodeGen/Hexagon/loop-prefetch.ll" +export LIT_XFAIL="tools/UpdateTestChecks" %build_tool %cmake_target_opts check-llvm #endregion Test LLVM @@ -2892,6 +2892,10 @@ fi #endregion files %changelog +* Tue Sep 09 2025 liyunfei - 17.0.6-50 +- update to llvm-for-oe-17.0.6-2509.0.2 +- release-note https://gitee.com/openeuler/llvm-project/releases/tag/llvm-for-oE-17.0.6-2509.0.2 + * Tue Sep 02 2025 Xu Jin - 17.0.6-49 - remove rpath for openmp library -- Gitee From 3ddcee01429dd5e896cbcc22b682e9c77cf4d652 Mon Sep 17 00:00:00 2001 From: liyunfei Date: Tue, 23 Sep 2025 14:24:50 +0800 Subject: [PATCH 6/8] add bolt --- llvm.spec | 120 +++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 119 insertions(+), 1 deletion(-) diff --git a/llvm.spec b/llvm.spec index abeda6f..0d58d41 100644 --- a/llvm.spec +++ b/llvm.spec @@ -25,6 +25,13 @@ %endif %bcond_without lldb %bcond_without libcxx + +%ifarch aarch64 x86_64 +%bcond_without bolt +%else +%bcond_with bolt +%endif + %if %{with toolchain_clang} %global toolchain clang %endif @@ -145,6 +152,10 @@ %global pkg_name_llvm_libunwind %{?scl_prefix}llvm-libunwind #endregion libcxx globals +#region BOLT globals +%global pkg_name_bolt %{?scl_prefix}llvm-bolt +#endregion BOLT globals + #region packages #region main package %if %{with sys_llvm} @@ -153,7 +164,7 @@ Name: llvm Name: llvm-toolset-%{maj_ver} %endif Version: %{maj_ver}.%{min_ver}.%{patch_ver} -Release: 50 +Release: 51 Summary: The Low Level Virtual Machine License: NCSA @@ -751,6 +762,24 @@ Documentation for LLVM libunwind %endif #endregion libcxx packages +#region BOLT packages +%if %{with bolt} +%package -n %{pkg_name_bolt} +Summary: A post-link optimizer developed to speed up large applications +License: Apache-2.0 WITH LLVM-exception +URL: https://github.com/llvm/llvm-project/tree/main/bolt + +# As hinted by bolt documentation +Recommends: gperftools-devel + +%description -n %{pkg_name_bolt} + +BOLT is a post-link optimizer developed to speed up large applications. +It achieves the improvements by optimizing application's code layout based on +execution profile gathered by sampling profiler, such as Linux `perf` tool. +%endif +#endregion BOLT packages + #endregion packages #region prep @@ -793,6 +822,9 @@ Documentation for LLVM libunwind %if %{with mlir} %global projects %{projects};mlir %endif +%if %{with bolt} +%global projects %{projects};bolt +%endif %global runtimes compiler-rt;openmp @@ -1494,6 +1526,11 @@ popd %endif #endregion libcxx installation +#region BOLT installation +# We don't ship libLLVMBOLT*.a +rm -f %{buildroot}%{_libdir}/libLLVMBOLT*.a +#endregion BOLT installation + %if %{without sys_llvm} && %{os_version} < 2403 # Add version suffix to binaries. Do this at the end so it includes any # additional binaries that may be been added by other steps. @@ -1963,6 +2000,54 @@ export LD_LIBRARY_PATH=%{buildroot}/%{install_libdir}:%{buildroot}/%{python3_sit %endif #endregion Test MLIR +#region BOLT tests +%if %{with bolt} +%if %{maj_ver} < 20 +export LIT_XFAIL="$LIT_XFAIL;AArch64/build_id.c" +export LIT_XFAIL="$LIT_XFAIL;AArch64/plt-call.test" +export LIT_XFAIL="$LIT_XFAIL;X86/linux-static-keys.s" +export LIT_XFAIL="$LIT_XFAIL;X86/plt-call.test" +%endif + +# Beginning with LLVM 20 this test has the "non-root-user" requirement +# and then the test should pass. But now it is flaky, hence we can only +# filter it out. +test_list_filter_out+=("BOLT :: unreadable-profile.test") + +%ifarch aarch64 +# Failing test cases on aarch64 +# TODO(kkleine): The following used to fail on aarch64 but passed today. +#export LIT_XFAIL="$LIT_XFAIL;cache+-deprecated.test" +#export LIT_XFAIL="$LIT_XFAIL;bolt-icf.test" +#export LIT_XFAIL="$LIT_XFAIL;R_ABS.pic.lld.cpp" + +# The following tests require LSE in order to run. +# More info at: https://github.com/llvm/llvm-project/issues/86485 +if ! grep -q atomics /proc/cpuinfo; then + test_list_filter_out+=("BOLT :: runtime/AArch64/basic-instrumentation.test") + test_list_filter_out+=("BOLT :: runtime/AArch64/hook-fini.test") + test_list_filter_out+=("BOLT :: runtime/AArch64/instrumentation-ind-call.c") + test_list_filter_out+=("BOLT :: runtime/exceptions-instrumentation.test") + test_list_filter_out+=("BOLT :: runtime/instrumentation-indirect-2.c") + test_list_filter_out+=("BOLT :: runtime/pie-exceptions-split.test") +fi +%endif + +%if %{maj_ver} < 20 +%ifarch x86_64 +# BOLT-ERROR: instrumentation of static binary currently does not support profile output on binary +# finalization, so it requires -instrumentation-sleep-time=N (N>0) usage +# export LIT_XFAIL="$LIT_XFAIL;X86/internal-call-instrument.s" +%endif +%endif + +# Failing test cases for RISCV +export LIT_XFAIL="$LIT_XFAIL;RISCV/mapping-syms.s" + +%cmake_build --target check-bolt +%endif +#endregion BOLT tests + %endif #endregion check @@ -2889,9 +2974,42 @@ fi %doc %{_pkgdocdir}/html #endregion libcxx files +#region BOLT files +%if %{with bolt} +%files -n %{pkg_name_bolt} +%license bolt/LICENSE.TXT +%{install_bindir}/llvm-bolt +%if %{maj_ver} >= 20 +%{install_bindir}/llvm-bolt-binary-analysis +%endif +%{install_bindir}/llvm-boltdiff +%{install_bindir}/llvm-bolt-heatmap +%{install_bindir}/merge-fdata +%{install_bindir}/perf2bolt + +%{install_libdir}/libbolt_rt_hugify.a +%{install_libdir}/libbolt_rt_instr.a + +%if %{without sys_llvm} +%{_bindir}/llvm-bolt-%{maj_ver} +%if %{maj_ver} >= 20 +%{_bindir}/llvm-bolt-binary-analysis-%{maj_ver} +%endif +%{_bindir}/llvm-boltdiff-%{maj_ver} +%{_bindir}/llvm-bolt-heatmap-%{maj_ver} +%{_bindir}/merge-fdata-%{maj_ver} +%{_bindir}/perf2bolt-%{maj_ver} +%endif + +%endif +#endregion BOLT files + #endregion files %changelog +* Tue Sep 23 2025 liyunfei - 17.0.6-51 +- Add bolt + * Tue Sep 09 2025 liyunfei - 17.0.6-50 - update to llvm-for-oe-17.0.6-2509.0.2 - release-note https://gitee.com/openeuler/llvm-project/releases/tag/llvm-for-oE-17.0.6-2509.0.2 -- Gitee From f2f19d6b88e8686fd1d617f604ca9ff7a679e3ad Mon Sep 17 00:00:00 2001 From: liyunfei Date: Thu, 9 Oct 2025 11:46:55 +0800 Subject: [PATCH 7/8] Backport cmake fix for bolt libraries --- ...-Don-t-export-bolt-libraries-in-LLVM.patch | 186 ++++++++++++++++++ llvm.spec | 6 +- 2 files changed, 191 insertions(+), 1 deletion(-) create mode 100644 0007-Bolt-CMake-Don-t-export-bolt-libraries-in-LLVM.patch diff --git a/0007-Bolt-CMake-Don-t-export-bolt-libraries-in-LLVM.patch b/0007-Bolt-CMake-Don-t-export-bolt-libraries-in-LLVM.patch new file mode 100644 index 0000000..db4d8f8 --- /dev/null +++ b/0007-Bolt-CMake-Don-t-export-bolt-libraries-in-LLVM.patch @@ -0,0 +1,186 @@ +From ee0f56cff40b324bb06e034e247ec85ae9a846bf Mon Sep 17 00:00:00 2001 +From: Nikita Popov +Date: Wed, 8 Jan 2025 08:28:18 +0100 +Subject: [PATCH] [PATCH] [Bolt][CMake] Don't export bolt libraries in + LLVMExports.cmake + +Bolt makes use of add_llvm_library and as such ends up exporting +its libraries from LLVMExports.cmake, which is not correct. + +Bolt doesn't have its own exports file, and I assume that there +is no desire to have one either -- Bolt libraries are not intended +to be consumed as a cmake module, right? + +As such, this PR adds a NO_EXPORT option to simplify exclude these +libraries from the exports file. + +--- +This patch originates from this PR: + +https://patch-diff.githubusercontent.com/raw/llvm/llvm-project/pull/121936. + +The commit was: + +https://github.com/nikic/llvm-project/commit/4333a4dd270b5c046c5469b97846e3dae58fb221.patch + +And then it was rebased onto llvmorg-19.1.6. +--- + bolt/lib/Core/CMakeLists.txt | 1 + + bolt/lib/Passes/CMakeLists.txt | 1 + + bolt/lib/Profile/CMakeLists.txt | 1 + + bolt/lib/Rewrite/CMakeLists.txt | 1 + + bolt/lib/RuntimeLibs/CMakeLists.txt | 1 + + bolt/lib/Target/AArch64/CMakeLists.txt | 1 + + bolt/lib/Target/RISCV/CMakeLists.txt | 1 + + bolt/lib/Target/X86/CMakeLists.txt | 1 + + bolt/lib/Utils/CMakeLists.txt | 1 + + llvm/cmake/modules/AddLLVM.cmake | 12 +++++++++--- + 10 files changed, 18 insertions(+), 3 deletions(-) + +diff --git a/bolt/lib/Core/CMakeLists.txt b/bolt/lib/Core/CMakeLists.txt +index c913179ebcc5..f45ce15afaac 100644 +--- a/bolt/lib/Core/CMakeLists.txt ++++ b/bolt/lib/Core/CMakeLists.txt +@@ -30,6 +30,7 @@ add_llvm_library(LLVMBOLTCore + ParallelUtilities.cpp + Relocation.cpp + ++ NO_EXPORT + DISABLE_LLVM_LINK_LLVM_DYLIB + LINK_LIBS + ${LLVM_PTHREAD_LIB} +diff --git a/bolt/lib/Passes/CMakeLists.txt b/bolt/lib/Passes/CMakeLists.txt +index b8bbe59a6448..80fce073d0f7 100644 +--- a/bolt/lib/Passes/CMakeLists.txt ++++ b/bolt/lib/Passes/CMakeLists.txt +@@ -49,6 +49,7 @@ add_llvm_library(LLVMBOLTPasses + VeneerElimination.cpp + RetpolineInsertion.cpp + ++ NO_EXPORT + DISABLE_LLVM_LINK_LLVM_DYLIB + + LINK_LIBS +diff --git a/bolt/lib/Profile/CMakeLists.txt b/bolt/lib/Profile/CMakeLists.txt +index 3a31a9cc1919..9bbd9f39b7bb 100644 +--- a/bolt/lib/Profile/CMakeLists.txt ++++ b/bolt/lib/Profile/CMakeLists.txt +@@ -8,6 +8,7 @@ add_llvm_library(LLVMBOLTProfile + YAMLProfileReader.cpp + YAMLProfileWriter.cpp + ++ NO_EXPORT + DISABLE_LLVM_LINK_LLVM_DYLIB + + LINK_COMPONENTS +diff --git a/bolt/lib/Rewrite/CMakeLists.txt b/bolt/lib/Rewrite/CMakeLists.txt +index b0e2b7f46bef..676c41a3b691 100644 +--- a/bolt/lib/Rewrite/CMakeLists.txt ++++ b/bolt/lib/Rewrite/CMakeLists.txt +@@ -23,6 +23,7 @@ add_llvm_library(LLVMBOLTRewrite + RewriteInstance.cpp + SDTRewriter.cpp + ++ NO_EXPORT + DISABLE_LLVM_LINK_LLVM_DYLIB + + LINK_LIBS +diff --git a/bolt/lib/RuntimeLibs/CMakeLists.txt b/bolt/lib/RuntimeLibs/CMakeLists.txt +index d3ac71d3e797..b8db7e4a1553 100644 +--- a/bolt/lib/RuntimeLibs/CMakeLists.txt ++++ b/bolt/lib/RuntimeLibs/CMakeLists.txt +@@ -11,6 +11,7 @@ add_llvm_library(LLVMBOLTRuntimeLibs + HugifyRuntimeLibrary.cpp + InstrumentationRuntimeLibrary.cpp + ++ NO_EXPORT + DISABLE_LLVM_LINK_LLVM_DYLIB + ) + +diff --git a/bolt/lib/Target/AArch64/CMakeLists.txt b/bolt/lib/Target/AArch64/CMakeLists.txt +index be03e247aa96..526a9645cb54 100644 +--- a/bolt/lib/Target/AArch64/CMakeLists.txt ++++ b/bolt/lib/Target/AArch64/CMakeLists.txt +@@ -7,6 +7,7 @@ set(LLVM_LINK_COMPONENTS + add_llvm_library(LLVMBOLTTargetAArch64 + AArch64MCPlusBuilder.cpp + ++ NO_EXPORT + DISABLE_LLVM_LINK_LLVM_DYLIB + + DEPENDS +diff --git a/bolt/lib/Target/RISCV/CMakeLists.txt b/bolt/lib/Target/RISCV/CMakeLists.txt +index 7f9557606320..3955cfc0f089 100644 +--- a/bolt/lib/Target/RISCV/CMakeLists.txt ++++ b/bolt/lib/Target/RISCV/CMakeLists.txt +@@ -7,6 +7,7 @@ set(LLVM_LINK_COMPONENTS + add_llvm_library(LLVMBOLTTargetRISCV + RISCVMCPlusBuilder.cpp + ++ NO_EXPORT + DISABLE_LLVM_LINK_LLVM_DYLIB + + DEPENDS +diff --git a/bolt/lib/Target/X86/CMakeLists.txt b/bolt/lib/Target/X86/CMakeLists.txt +index 2b769bc7e7f5..00100e9b84c9 100644 +--- a/bolt/lib/Target/X86/CMakeLists.txt ++++ b/bolt/lib/Target/X86/CMakeLists.txt +@@ -9,6 +9,7 @@ add_llvm_library(LLVMBOLTTargetX86 + X86MCPlusBuilder.cpp + X86MCSymbolizer.cpp + ++ NO_EXPORT + DISABLE_LLVM_LINK_LLVM_DYLIB + + DEPENDS +diff --git a/bolt/lib/Utils/CMakeLists.txt b/bolt/lib/Utils/CMakeLists.txt +index d1403314274b..ceddcfc8f57a 100644 +--- a/bolt/lib/Utils/CMakeLists.txt ++++ b/bolt/lib/Utils/CMakeLists.txt +@@ -2,6 +2,7 @@ add_llvm_library(LLVMBOLTUtils + CommandLineOpts.cpp + Utils.cpp + ++ NO_EXPORT + DISABLE_LLVM_LINK_LLVM_DYLIB + + LINK_LIBS +diff --git a/llvm/cmake/modules/AddLLVM.cmake b/llvm/cmake/modules/AddLLVM.cmake +index 6d74e58aea6a..88225593ff3f 100644 +--- a/llvm/cmake/modules/AddLLVM.cmake ++++ b/llvm/cmake/modules/AddLLVM.cmake +@@ -838,7 +838,7 @@ endfunction() + + macro(add_llvm_library name) + cmake_parse_arguments(ARG +- "SHARED;BUILDTREE_ONLY;MODULE;INSTALL_WITH_TOOLCHAIN" ++ "SHARED;BUILDTREE_ONLY;MODULE;INSTALL_WITH_TOOLCHAIN;NO_EXPORT" + "" + "" + ${ARGN}) +@@ -873,7 +873,11 @@ macro(add_llvm_library name) + set(umbrella) + endif() + +- get_target_export_arg(${name} LLVM export_to_llvmexports ${umbrella}) ++ if(ARG_NO_EXPORT) ++ set(export_to_llvmexports) ++ else() ++ get_target_export_arg(${name} LLVM export_to_llvmexports ${umbrella}) ++ endif() + install(TARGETS ${name} + ${export_to_llvmexports} + LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX} COMPONENT ${name} +@@ -886,7 +890,9 @@ macro(add_llvm_library name) + COMPONENT ${name}) + endif() + endif() +- set_property(GLOBAL APPEND PROPERTY LLVM_EXPORTS ${name}) ++ if(NOT ARG_NO_EXPORT) ++ set_property(GLOBAL APPEND PROPERTY LLVM_EXPORTS ${name}) ++ endif() + endif() + if (ARG_MODULE) + set_target_properties(${name} PROPERTIES FOLDER "Loadable modules") +-- +2.47.1 diff --git a/llvm.spec b/llvm.spec index 0d58d41..4fe3736 100644 --- a/llvm.spec +++ b/llvm.spec @@ -164,7 +164,7 @@ Name: llvm Name: llvm-toolset-%{maj_ver} %endif Version: %{maj_ver}.%{min_ver}.%{patch_ver} -Release: 51 +Release: 52 Summary: The Low Level Virtual Machine License: NCSA @@ -187,6 +187,7 @@ Patch0004: 0004-remove-cmake_minimum_required.patch Patch0005: 0005-Fix-for-building-autotuner-with-mlir.patch %endif Patch0006: 0006-Propeller-bugfix-for-MachineBasicBlock-hash-set.patch +Patch0007: 0007-Bolt-CMake-Don-t-export-bolt-libraries-in-LLVM.patch BuildRequires: gcc BuildRequires: gcc-c++ @@ -3007,6 +3008,9 @@ fi #endregion files %changelog +* Thu Oct 09 2025 liyunfei - 17.0.6-52 +- Backport cmake fix for bolt libraries + * Tue Sep 23 2025 liyunfei - 17.0.6-51 - Add bolt -- Gitee From 2d420b08728cb88b87bba8ec95e9b80fedb67850 Mon Sep 17 00:00:00 2001 From: liyunfei Date: Fri, 17 Oct 2025 10:39:50 +0800 Subject: [PATCH 8/8] update target triples for all openEuler based distribution --- llvm.spec | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/llvm.spec b/llvm.spec index 4fe3736..ce29556 100644 --- a/llvm.spec +++ b/llvm.spec @@ -4,7 +4,7 @@ %global min_ver 0 %global patch_ver 6 -%global os_version %{lua: print(tonumber(rpm.expand("%{dist}"):match("oe(%d+)") or 9999))} +%global os_version %{lua: print(tonumber(rpm.expand("%{dist}"):match("oe(%d+)") or 2403))} %if %{os_version} == 1 %global os_version 9999 @@ -164,7 +164,7 @@ Name: llvm Name: llvm-toolset-%{maj_ver} %endif Version: %{maj_ver}.%{min_ver}.%{patch_ver} -Release: 52 +Release: 53 Summary: The Low Level Virtual Machine License: NCSA @@ -802,6 +802,11 @@ execution profile gathered by sampling profiler, such as Linux `perf` tool. # shebang_fix part removed +# update Gnu target triples, make it friendly to all openEuler based distribution +%if "%{_vendor}" != "openEuler" +sed -i 's/"\([a-zA-Z0-9_-]\+\)-openEuler-linux"/"\1-openEuler-linux", "\1-%{_vendor}-linux"/g' %{build_src_dir}/clang/lib/Driver/ToolChains/Gnu.cpp +%endif + #endregion prep #region build @@ -3008,6 +3013,9 @@ fi #endregion files %changelog +* Fri Oct 17 2025 liyunfei - 17.0.6-53 +- update target triples for all openEuler based distribution. + * Thu Oct 09 2025 liyunfei - 17.0.6-52 - Backport cmake fix for bolt libraries -- Gitee