From 4f2404c9803df8144992c4d4c4f76d4dceebc9e0 Mon Sep 17 00:00:00 2001 From: swcompiler Date: Mon, 15 Dec 2025 17:23:09 +0800 Subject: [PATCH] control sw64 not to build openmp and fix compiler-rt error --- ...-Fix-clear_cache.c-when-building-for.patch | 26 +++++++++++++++++++ llvm.spec | 24 ++++++++++++++--- 2 files changed, 47 insertions(+), 3 deletions(-) create mode 100755 0001-SW64-Compiler-RT-Fix-clear_cache.c-when-building-for.patch diff --git a/0001-SW64-Compiler-RT-Fix-clear_cache.c-when-building-for.patch b/0001-SW64-Compiler-RT-Fix-clear_cache.c-when-building-for.patch new file mode 100755 index 0000000..fc37a40 --- /dev/null +++ b/0001-SW64-Compiler-RT-Fix-clear_cache.c-when-building-for.patch @@ -0,0 +1,26 @@ +From 3b62790bdca38b3e5555cee478948e1b16a0c852 Mon Sep 17 00:00:00 2001 +From: swcompiler +Date: Thu, 11 Dec 2025 08:54:47 +0000 +Subject: [PATCH] [SW64][Compiler-RT] Fix clear_cache.c when building for sw_64 + on openEuler24 + +--- + compiler-rt/lib/builtins/clear_cache.c | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/compiler-rt/lib/builtins/clear_cache.c b/compiler-rt/lib/builtins/clear_cache.c +index af1f4a212..cb6f0dffa 100644 +--- a/compiler-rt/lib/builtins/clear_cache.c ++++ b/compiler-rt/lib/builtins/clear_cache.c +@@ -54,6 +54,8 @@ uintptr_t GetCurrentProcess(void); + //FIXME + #define __PNR_cacheflush -10104 + #define __NR_cacheflush __PNR_cacheflush ++ ++extern long int syscall (long int __sysno, ...) __THROW; + #endif + + #if defined(__linux__) && defined(__riscv) +-- +2.43.0 + diff --git a/llvm.spec b/llvm.spec index b6f5c6d..0dae27b 100644 --- a/llvm.spec +++ b/llvm.spec @@ -110,6 +110,10 @@ %global pkg_name_compiler_rt %{?scl_prefix}compiler-rt +%ifarch sw_64 +%global optflags %(echo %{optflags} | sed 's/-fgcc-compatible//') +%endif + %ifnarch x86_64 %global optflags %(echo %{optflags} | sed 's/-fstack-clash-protection//') # may affect cmake check for fpic @@ -164,7 +168,7 @@ Name: llvm Name: llvm-toolset-%{maj_ver} %endif Version: %{maj_ver}.%{min_ver}.%{patch_ver} -Release: 56 +Release: 57 Summary: The Low Level Virtual Machine License: NCSA @@ -186,6 +190,9 @@ Patch0004: 0004-remove-cmake_minimum_required.patch %if %{with bisheng_autotuner} Patch0005: 0005-Fix-for-building-autotuner-with-mlir.patch %endif +%ifarch sw_64 +Patch0006: 0001-SW64-Compiler-RT-Fix-clear_cache.c-when-building-for.patch +%endif BuildRequires: gcc BuildRequires: gcc-c++ @@ -830,7 +837,11 @@ sed -i 's/"\([a-zA-Z0-9_-]\+\)-openEuler-linux"/"\1-openEuler-linux", "\1-%{_ven %global projects %{projects};bolt %endif +%ifnarch sw_64 %global runtimes compiler-rt;openmp +%else +%global runtimes compiler-rt +%endif %if %{with libcxx} %global runtimes %{runtimes};libcxx;libcxxabi;libunwind @@ -1146,6 +1157,7 @@ cd %{build_src_dir}/_build_libcxx #region libomp build +%ifnarch sw_64 mkdir %{build_src_dir}/_build_openmp cd %{build_src_dir}/_build_openmp @@ -1173,6 +1185,7 @@ cd %{build_src_dir}/_build_openmp -DCMAKE_SKIP_RPATH:BOOL=ON %build_tool +%endif #endregion libomp build #region compiler-rt build @@ -1257,7 +1270,7 @@ cd %{build_src_dir} mkdir -p %{buildroot}/%{_bindir} # Remove rpath for openmp library -%ifnarch %{ix86} %{arm} riscv64 loongarch64 +%ifnarch %{ix86} %{arm} riscv64 loongarch64 sw_64 %global openmp_library libomptarget.rtl.cuda.so.17 libomptarget.rtl.%{_arch}.so.17 libomptarget.so.17 for f in %{openmp_library} do @@ -2698,7 +2711,7 @@ fi %{_prefix}/lib/clang/%{maj_ver}/lib/%{compiler_rt_triple}/clang_rt.crtend.o %endif -%ifnarch %{ix86} s390x riscv64 loongarch64 +%ifnarch %{ix86} s390x riscv64 loongarch64 sw_64 %{install_libdir}/clang/%{maj_ver}/lib/%{compiler_rt_triple}/liborc_rt.a %endif @@ -2711,6 +2724,7 @@ fi #region OPENMP files +%ifnarch sw_64 %files -n %{pkg_name_libomp} %license openmp/LICENSE.TXT %{install_libdir}/libomp.so @@ -2765,6 +2779,7 @@ fi %{install_includedir}/offload %endif %endif +%endif #endregion OPENMP files @@ -3012,6 +3027,9 @@ fi #endregion files %changelog +* Mon Dec 15 2025 swcompiler - 17.0.6-57 +- control sw64 not to build openmp and fix compiler-rt error + * Tue Dec 09 2025 liyunfei - 17.0.6-56 - update to llvm-for-oe-17.0.6-2512.0.2 - release-note https://gitee.com/openeuler/llvm-project/releases/tag/llvm-for-oE-17.0.6-2512.0.2 -- Gitee