From 1fc2a47f0b6c415312593e43489cf9ea2507d902 Mon Sep 17 00:00:00 2001 From: Sam Elliott Date: Thu, 1 Aug 2019 14:23:56 +0000 Subject: [PATCH] Add support for openSUSE RISC-V triple Reviewers: asb Reviewed By: asb Subscribers: lenary, rbar, johnrusso, simoncook, apazos, sabuasal, niosHD, jrtc27, zzheng, edward-jones, MartinMosbeck, brucehoult, the_o, PkmX, jocewei, lebedev.ri, kito-cheng, shiva0217, rogfer01, dexonsmith, rkruppe, cfe-commits, llvm-commits Tags: #clang, #llvm Differential Revision: https://reviews.llvm.org/D63497 Patch by Andreas Schwab (schwab) llvm-svn: 367565 --- clang/lib/Driver/ToolChains/Gnu.cpp | 3 ++- .../usr/lib64/crt1.o | 0 .../usr/lib64/crti.o | 0 .../usr/lib64/crtn.o | 0 .../usr/lib64/gcc/riscv64-suse-linux/9/crtbegin.o | 0 .../usr/lib64/gcc/riscv64-suse-linux/9/crtend.o | 0 clang/test/Driver/linux-ld.c | 20 ++++++++++++++++++++ llvm/unittests/ADT/TripleTest.cpp | 6 ++++++ 8 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 clang/test/Driver/Inputs/opensuse_tumbleweed_riscv64_tree/usr/lib64/crt1.o create mode 100644 clang/test/Driver/Inputs/opensuse_tumbleweed_riscv64_tree/usr/lib64/crti.o create mode 100644 clang/test/Driver/Inputs/opensuse_tumbleweed_riscv64_tree/usr/lib64/crtn.o create mode 100644 clang/test/Driver/Inputs/opensuse_tumbleweed_riscv64_tree/usr/lib64/gcc/riscv64-suse-linux/9/crtbegin.o create mode 100644 clang/test/Driver/Inputs/opensuse_tumbleweed_riscv64_tree/usr/lib64/gcc/riscv64-suse-linux/9/crtend.o diff --git a/clang/lib/Driver/ToolChains/Gnu.cpp b/clang/lib/Driver/ToolChains/Gnu.cpp index 33cdd35..30518a5 100644 --- a/clang/lib/Driver/ToolChains/Gnu.cpp +++ b/clang/lib/Driver/ToolChains/Gnu.cpp @@ -2017,7 +2017,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-suse-linux"}; static const char *const SPARCv8LibDirs[] = {"/lib32", "/lib"}; static const char *const SPARCv8Triples[] = {"sparc-linux-gnu", diff --git a/clang/test/Driver/Inputs/opensuse_tumbleweed_riscv64_tree/usr/lib64/crt1.o b/clang/test/Driver/Inputs/opensuse_tumbleweed_riscv64_tree/usr/lib64/crt1.o new file mode 100644 index 0000000..e69de29 diff --git a/clang/test/Driver/Inputs/opensuse_tumbleweed_riscv64_tree/usr/lib64/crti.o b/clang/test/Driver/Inputs/opensuse_tumbleweed_riscv64_tree/usr/lib64/crti.o new file mode 100644 index 0000000..e69de29 diff --git a/clang/test/Driver/Inputs/opensuse_tumbleweed_riscv64_tree/usr/lib64/crtn.o b/clang/test/Driver/Inputs/opensuse_tumbleweed_riscv64_tree/usr/lib64/crtn.o new file mode 100644 index 0000000..e69de29 diff --git a/clang/test/Driver/Inputs/opensuse_tumbleweed_riscv64_tree/usr/lib64/gcc/riscv64-suse-linux/9/crtbegin.o b/clang/test/Driver/Inputs/opensuse_tumbleweed_riscv64_tree/usr/lib64/gcc/riscv64-suse-linux/9/crtbegin.o new file mode 100644 index 0000000..e69de29 diff --git a/clang/test/Driver/Inputs/opensuse_tumbleweed_riscv64_tree/usr/lib64/gcc/riscv64-suse-linux/9/crtend.o b/clang/test/Driver/Inputs/opensuse_tumbleweed_riscv64_tree/usr/lib64/gcc/riscv64-suse-linux/9/crtend.o new file mode 100644 index 0000000..e69de29 diff --git a/clang/test/Driver/linux-ld.c b/clang/test/Driver/linux-ld.c index 70fc178..7aba660 100644 --- a/clang/test/Driver/linux-ld.c +++ b/clang/test/Driver/linux-ld.c @@ -859,6 +859,26 @@ // CHECK-OPENSUSE-TW-ARMV7HL: "{{.*}}/usr/lib/gcc/armv7hl-suse-linux-gnueabi/5{{/|\\\\}}crtend.o" // CHECK-OPENSUSE-TW-ARMV7HL: "{{.*}}/usr/lib/gcc/armv7hl-suse-linux-gnueabi/5/../../../../lib{{/|\\\\}}crtn.o" // +// Check openSUSE Tumbleweed on riscv64 +// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ +// RUN: --target=riscv64-suse-linux -rtlib=platform \ +// RUN: --gcc-toolchain="" \ +// RUN: --sysroot=%S/Inputs/opensuse_tumbleweed_riscv64_tree \ +// RUN: | FileCheck --check-prefix=CHECK-OPENSUSE-TW-RISCV64 %s +// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ +// RUN: --target=riscv64-suse-linux -rtlib=platform \ +// RUN: --gcc-toolchain="" \ +// RUN: --sysroot=%S/Inputs/opensuse_tumbleweed_riscv64_tree \ +// RUN: | FileCheck --check-prefix=CHECK-OPENSUSE-TW-RISCV64 %s +// CHECK-OPENSUSE-TW-RISCV64: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]" +// CHECK-OPENSUSE-TW-RISCV64: "{{.*}}/usr/lib64/gcc/riscv64-suse-linux/9/../../../../lib64{{/|\\\\}}crt1.o" +// CHECK-OPENSUSE-TW-RISCV64: "{{.*}}/usr/lib64/gcc/riscv64-suse-linux/9/../../../../lib64{{/|\\\\}}crti.o" +// CHECK-OPENSUSE-TW-RISCV64: "{{.*}}/usr/lib64/gcc/riscv64-suse-linux/9{{/|\\\\}}crtbegin.o" +// CHECK-OPENSUSE-TW-RISCV64: "-L[[SYSROOT]]/usr/lib64/gcc/riscv64-suse-linux/9" +// CHECK-OPENSUSE-TW-RISCV64: "-L[[SYSROOT]]/usr/lib64/gcc/riscv64-suse-linux/9/../../../../lib64" +// CHECK-OPENSUSE-TW-RISCV64: "{{.*}}/usr/lib64/gcc/riscv64-suse-linux/9{{/|\\\\}}crtend.o" +// CHECK-OPENSUSE-TW-RISCV64: "{{.*}}/usr/lib64/gcc/riscv64-suse-linux/9/../../../../lib64{{/|\\\\}}crtn.o" +// // Check dynamic-linker for different archs // RUN: %clang %s -### -o %t.o 2>&1 \ // RUN: --target=arm-linux-gnueabi \ diff --git a/llvm/unittests/ADT/TripleTest.cpp b/llvm/unittests/ADT/TripleTest.cpp index 37ebe5d..d8123bb 100644 --- a/llvm/unittests/ADT/TripleTest.cpp +++ b/llvm/unittests/ADT/TripleTest.cpp @@ -330,6 +330,12 @@ TEST(TripleTest, ParsedIDs) { EXPECT_EQ(Triple::FreeBSD, T.getOS()); EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment()); + T = Triple("riscv64-suse-linux"); + EXPECT_EQ(Triple::riscv64, T.getArch()); + EXPECT_EQ(Triple::SUSE, T.getVendor()); + EXPECT_EQ(Triple::Linux, T.getOS()); + EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment()); + T = Triple("armv7hl-suse-linux-gnueabi"); EXPECT_EQ(Triple::arm, T.getArch()); EXPECT_EQ(Triple::SUSE, T.getVendor()); -- 2.7.4