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 0000000000000000000000000000000000000000..e91b8c404a7e25ca4652e25850c16194218cd0f3 --- /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.2.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.2.tar.gz index 171f896de39b0f6dac45da2dda89362360f79b53..d5697597bf528ed2c63f842912561ab7fae2de18 100644 --- a/llvm-for-oE-17.0.6-2506.0.4.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:db05405706279885e543dd562d7f2887fd433eb10dae819811df7d588e8548b3 -size 212541296 +oid sha256:717518c4ddf31b5d141fce1bdac7ede96a59de292f09f72482277ca0a49f489b +size 212666397 diff --git a/llvm.spec b/llvm.spec index 6df284239ef09a7f420744d766f51c7ad8cf2f47..9eea59a5b0dcd652e70b4146b8cf36d4d04aaf1c 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 @@ -22,13 +26,19 @@ %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 %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.2 %global src_tarball_dir llvm-project-%{src_tarball} #region LLVM globals @@ -100,8 +110,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 @@ -144,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} @@ -152,7 +164,7 @@ Name: llvm Name: llvm-toolset-%{maj_ver} %endif Version: %{maj_ver}.%{min_ver}.%{patch_ver} -Release: 47 +Release: 53 Summary: The Low Level Virtual Machine License: NCSA @@ -176,6 +188,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++ @@ -751,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 @@ -793,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 @@ -800,9 +834,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. @@ -837,7 +868,7 @@ export ASMFLAGS="%{build_cflags}" %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 \\\ @@ -1018,6 +1049,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}" @@ -1218,6 +1254,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 @@ -1483,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. @@ -1952,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 @@ -2878,9 +2976,59 @@ 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 + +* 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 + +* 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 + * Tue Jul 01 2025 liyunfei - 17.0.6-47 - fix for mlir build failure after numpy 2.3.0