From d76a0f39630e0f38b95e6dd1a1be7e7cbe33604a Mon Sep 17 00:00:00 2001 From: David Abdurachmanov Date: Wed, 27 Mar 2024 17:12:37 +0200 Subject: [PATCH] Add riscv64 support Signed-off-by: David Abdurachmanov --- clang-fedora-riscv64.patch | 23 +++++++++++++++++++++++ clang17.spec | 15 ++++++++++----- 2 files changed, 33 insertions(+), 5 deletions(-) create mode 100644 clang-fedora-riscv64.patch diff --git a/clang-fedora-riscv64.patch b/clang-fedora-riscv64.patch new file mode 100644 index 0000000..adcb6d5 --- /dev/null +++ b/clang-fedora-riscv64.patch @@ -0,0 +1,23 @@ +diff --git a/lib/Driver/ToolChains/Gnu.cpp b/lib/Driver/ToolChains/Gnu.cpp +index 4325cbb4..86ae0f21 100644 +--- a/lib/Driver/ToolChains/Gnu.cpp ++++ b/lib/Driver/ToolChains/Gnu.cpp +@@ -2065,6 +2065,7 @@ static llvm::StringRef getGCCToolchainDir(const ArgList &Args, + /// triple. + static const char *ConvertToGccTriple(StringRef CandidateTriple) { + return llvm::StringSwitch(CandidateTriple) ++ .Case("riscv64-redhat-linux-gnu", "riscv64-redhat-linux") + .Case("aarch64-redhat-linux-gnu", "aarch64-redhat-linux") + .Case("i686-redhat-linux-gnu", "i686-redhat-linux") + .Case("ppc64le-redhat-linux-gnu", "ppc64le-redhat-linux") +@@ -2426,7 +2427,9 @@ 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-redhat-linux-gnu", ++ "riscv64-redhat-linux"}; + + static const char *const SPARCv8LibDirs[] = {"/lib32", "/lib"}; + static const char *const SPARCv8Triples[] = {"sparc-linux-gnu", diff --git a/clang17.spec b/clang17.spec index db7f413..c070902 100644 --- a/clang17.spec +++ b/clang17.spec @@ -67,7 +67,7 @@ Name: %pkg_name Version: %{clang_version}%{?rc_ver:~rc%{rc_ver}}%{?llvm_snapshot_version_suffix:~%{llvm_snapshot_version_suffix}} -Release: 7%{?dist} +Release: 7.0.riscv64%{?dist} Summary: A C language family front-end for LLVM License: Apache-2.0 WITH LLVM-exception OR NCSA @@ -105,6 +105,8 @@ Patch7: tsa.patch Patch8: 0001-Clang-Fix-build-with-GCC-14-on-ARM.patch Patch9: 0001-Clang-Defer-the-instantiation-of-explicit-specifier-.patch +# RISCV (riscv64) +Patch20: clang-fedora-riscv64.patch # RHEL specific patches # Avoid unwanted dependency on python-recommonmark @@ -335,7 +337,7 @@ rm test/CodeGen/profile-filter.c %build # And disable LTO on AArch64 entirely. -%ifarch aarch64 +%ifarch aarch64 riscv64 %define _lto_cflags %{nil} %endif @@ -344,13 +346,13 @@ rm test/CodeGen/profile-filter.c %global _lto_cflags %nil %endif -%ifarch s390 s390x aarch64 %ix86 ppc64le +%ifarch s390 s390x aarch64 %ix86 ppc64le riscv64 # Decrease debuginfo verbosity to reduce memory consumption during final library linking %global optflags %(echo %{optflags} | sed 's/-g /-g1 /') %endif # Disable dwz on aarch64, because it takes a huge amount of time to decide not to optimize things. -%ifarch aarch64 +%ifarch aarch64 riscv64 %define _find_debuginfo_dwz_opts %{nil} %endif @@ -366,7 +368,7 @@ rm test/CodeGen/profile-filter.c -DCMAKE_BUILD_TYPE=RelWithDebInfo \ -DPYTHON_EXECUTABLE=%{__python3} \ -DCMAKE_SKIP_RPATH:BOOL=ON \ -%ifarch s390 s390x %ix86 ppc64le +%ifarch s390 s390x %ix86 ppc64le riscv64 -DCMAKE_C_FLAGS_RELWITHDEBINFO="%{optflags} -DNDEBUG" \ -DCMAKE_CXX_FLAGS_RELWITHDEBINFO="%{optflags} -DNDEBUG" \ %endif @@ -692,6 +694,9 @@ LD_LIBRARY_PATH=%{buildroot}/%{install_libdir} %{__ninja} check-all -C %{__cmake %endif %changelog +* Wed Mar 27 2024 David Abdurachmanov - 17.0.6-7.0.riscv64 +- Add support for riscv64 + * Wed Mar 06 2024 Tom Stellard - 17.0.6-7 - Fix clang resource directory to match compiler-rt - Fix provides for clang-resource-filesystem