From 5eec27726e1d6e307fa21fd17580a370f9621e0a Mon Sep 17 00:00:00 2001 From: Guost123 Date: Fri, 25 Apr 2025 15:32:21 +0800 Subject: [PATCH] adapt for riscv64 --- ...ng-back-riscv64-anolis-linux-triplet.patch | 27 +++++++++++++++++++ clang.spec | 14 +++++++--- 2 files changed, 38 insertions(+), 3 deletions(-) create mode 100644 0001-Bring-back-riscv64-anolis-linux-triplet.patch diff --git a/0001-Bring-back-riscv64-anolis-linux-triplet.patch b/0001-Bring-back-riscv64-anolis-linux-triplet.patch new file mode 100644 index 0000000..5e2690c --- /dev/null +++ b/0001-Bring-back-riscv64-anolis-linux-triplet.patch @@ -0,0 +1,27 @@ +From 2dcf8703706e0a5b7b45991e5cd10dd38f1d8c4b Mon Sep 17 00:00:00 2001 +From: David Abdurachmanov +Date: Thu, 24 Nov 2022 06:26:46 +0200 +Subject: [PATCH] Bring back riscv64-redhat-linux triplet + +Signed-off-by: David Abdurachmanov +--- + clang/lib/Driver/ToolChains/Gnu.cpp | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/clang/lib/Driver/ToolChains/Gnu.cpp b/clang/lib/Driver/ToolChains/Gnu.cpp +index e955835b..e5c17544 100644 +--- a/clang/lib/Driver/ToolChains/Gnu.cpp ++++ b/clang/lib/Driver/ToolChains/Gnu.cpp +@@ -2302,7 +2302,8 @@ void Generic_GCC::GCCInstallationDetector::AddDefaultGCCPrefixes( + static const char *const RISCV64LibDirs[] = {"/lib64", "/lib"}; + static const char *const RISCV64Triples[] = {"riscv64-unknown-linux-gnu", + "riscv64-linux-gnu", +- "riscv64-unknown-elf"}; ++ "riscv64-unknown-elf", ++ "riscv64-anolis-linux"}; + + static const char *const SPARCv8LibDirs[] = {"/lib32", "/lib"}; + static const char *const SPARCv8Triples[] = {"sparc-linux-gnu", +-- +2.37.1 + diff --git a/clang.spec b/clang.spec index b66b91c..864de19 100644 --- a/clang.spec +++ b/clang.spec @@ -1,4 +1,4 @@ -%define anolis_release 6 +%define anolis_release 7 %global toolchain clang @@ -80,6 +80,7 @@ Patch37: 0024-LoongArch-Support-march-la64v1.0-and-march-la64v1.1-.patch Patch38: 0025-LoongArch-Support-la664-100068.patch Patch39: 0026-LoongArch-Fix-test-issue-of-init-loongarch.c.patch +Patch100: 0001-Bring-back-riscv64-anolis-linux-triplet.patch # Patches for clang-tools-extra # See https://reviews.llvm.org/D120301 Patch201: 0001-clang-tools-extra-Make-test-dependency-on-LLVMHello-.patch @@ -272,13 +273,13 @@ rm test/CodeGen/profile-filter.c # Use ThinLTO to limit build time. %define _lto_cflags -flto=thin # And disable LTO on AArch64 entirely. -%ifarch aarch64 +%ifarch aarch64 riscv64 %define _lto_cflags %{nil} %endif sed -i 's/\@FEDORA_LLVM_LIB_SUFFIX\@/64/g' test/lit.cfg.py -%ifarch aarch64 +%ifarch aarch64 riscv64 # Decrease debuginfo verbosity to reduce memory consumption during final library linking %global optflags %(echo %{optflags} | sed 's/-g /-g1 /') @@ -289,6 +290,10 @@ sed -i 's/\@FEDORA_LLVM_LIB_SUFFIX\@/64/g' test/lit.cfg.py # We set CLANG_DEFAULT_PIE_ON_LINUX=OFF and PPC_LINUX_DEFAULT_IEEELONGDOUBLE=ON to match the # defaults used by our GCC. %cmake -G Ninja \ +%ifarch riscv64 + -DCMAKE_C_FLAGS_RELWITHDEBINFO="%{optflags} -DNDEBUG" \ + -DCMAKE_CXX_FLAGS_RELWITHDEBINFO="%{optflags} -DNDEBUG" \ +%endif -DCLANG_DEFAULT_PIE_ON_LINUX=OFF \ -DPPC_LINUX_DEFAULT_IEEELONGDOUBLE=ON \ -DLLVM_PARALLEL_LINK_JOBS=1 \ @@ -501,6 +506,9 @@ LD_LIBRARY_PATH=%{buildroot}/%{_libdir} %{__ninja} check-all -C %{__cmake_buildd %{python3_sitelib}/clang/ %changelog +* Fri Apr 25 2025 Shangtong Guo - 17.0.6-7 +- add support for riscv64 build + * Thu Oct 31 2024 Chen Li - 17.0.6-6 - LoongArch Backport: Add support for option `-msimd=` and macro `__loongarch_simd_width` -- Gitee