From 76a1db95360d1d0a82d4edb5fa69c2e3f281d616 Mon Sep 17 00:00:00 2001 From: liyunfei Date: Wed, 20 Aug 2025 16:43:18 +0800 Subject: [PATCH 1/6] fix missing hardening compiler options --- llvm.spec | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/llvm.spec b/llvm.spec index 6df2842..920e997 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 @@ -100,8 +104,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 @@ -152,7 +154,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 @@ -800,9 +802,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. @@ -1018,6 +1017,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}" @@ -2881,6 +2885,9 @@ fi #endregion files %changelog +* Wed Aug 20 2025 liyunfei - 17.0.6-48 +- fix missing hardening compiler options + * Tue Jul 01 2025 liyunfei - 17.0.6-47 - fix for mlir build failure after numpy 2.3.0 -- Gitee From b8c28c71e6eca98ec87749c5ed39ec287f19b16c Mon Sep 17 00:00:00 2001 From: liyunfei Date: Wed, 27 Aug 2025 17:06:15 +0800 Subject: [PATCH 2/6] 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 0008-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/0008-Propeller-bugfix-for-MachineBasicBlock-hash-set.patch b/0008-Propeller-bugfix-for-MachineBasicBlock-hash-set.patch new file mode 100644 index 0000000..e91b8c4 --- /dev/null +++ b/0008-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 920e997..94110be 100644 --- a/llvm.spec +++ b/llvm.spec @@ -32,7 +32,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 @@ -154,7 +154,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 @@ -178,6 +178,7 @@ Patch0005: 0005-Fix-for-building-autotuner-with-mlir.patch %endif Patch0006: 0006-backport-mlir-Make-it-possible-to-build-a-DenseResou.patch Patch0007: 0007-backport-mlir-Add-Python-bindings-for-DenseResourceE.patch +Patch0008: 0008-Propeller-bugfix-for-MachineBasicBlock-hash-set.patch BuildRequires: gcc BuildRequires: gcc-c++ @@ -1666,7 +1667,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 @@ -2885,6 +2886,10 @@ fi #endregion files %changelog +* Wed Aug 27 2025 liyunfei - 17.0.6-49 +- 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-48 - fix missing hardening compiler options -- Gitee From da3d000396fe9b176c797138855d2c619978419b Mon Sep 17 00:00:00 2001 From: liyunfei Date: Tue, 2 Sep 2025 11:25:57 +0800 Subject: [PATCH 3/6] add fix for pie hardening --- llvm.spec | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/llvm.spec b/llvm.spec index 94110be..0f08db6 100644 --- a/llvm.spec +++ b/llvm.spec @@ -154,7 +154,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 @@ -837,7 +837,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 \\\ @@ -2886,6 +2886,9 @@ fi #endregion files %changelog +* Tue Sep 02 2025 liyunfei - 17.0.6-50 +- add fix for pie hardening + * Wed Aug 27 2025 liyunfei - 17.0.6-49 - 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 a41e4815f4614a3b5a8e2842d03a36e72512047b Mon Sep 17 00:00:00 2001 From: Xu Jin Date: Wed, 3 Sep 2025 15:38:46 +0800 Subject: [PATCH 4/6] remove rpath for openmp library --- llvm.spec | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/llvm.spec b/llvm.spec index 0f08db6..94a9695 100644 --- a/llvm.spec +++ b/llvm.spec @@ -154,7 +154,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 @@ -1223,6 +1223,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 @@ -2886,6 +2895,9 @@ fi #endregion files %changelog +* Tue Sep 02 2025 Xu Jin - 17.0.6-51 +- remove rpath for openmp library + * Tue Sep 02 2025 liyunfei - 17.0.6-50 - add fix for pie hardening -- Gitee From c052b27c7fb07d6ce186070c3cb98c88e6f7da9e Mon Sep 17 00:00:00 2001 From: liyunfei Date: Tue, 9 Sep 2025 20:22:35 +0800 Subject: [PATCH 5/6] 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 94a9695..54fe324 100644 --- a/llvm.spec +++ b/llvm.spec @@ -32,7 +32,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 @@ -154,7 +154,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 @@ -1676,7 +1676,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 @@ -2895,6 +2895,10 @@ fi #endregion files %changelog +* Tue Sep 09 2025 liyunfei - 17.0.6-52 +- 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-51 - remove rpath for openmp library -- Gitee From 9c7c25dbd73d00453bb60a6efc200e73d8d221f8 Mon Sep 17 00:00:00 2001 From: liyunfei Date: Tue, 23 Sep 2025 14:24:50 +0800 Subject: [PATCH 6/6] add bolt --- llvm.spec | 119 +++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 118 insertions(+), 1 deletion(-) diff --git a/llvm.spec b/llvm.spec index 54fe324..9eea59a 100644 --- a/llvm.spec +++ b/llvm.spec @@ -26,6 +26,12 @@ %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 @@ -146,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} @@ -154,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 @@ -754,6 +764,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 @@ -796,6 +824,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 @@ -1497,6 +1528,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. @@ -1966,6 +2002,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 @@ -2892,9 +2976,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-53 +- Add bolt + * Tue Sep 09 2025 liyunfei - 17.0.6-52 - 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