summaryrefslogtreecommitdiffstats
path: root/clang/test
diff options
context:
space:
mode:
authorMichal Gorny <mgorny@gentoo.org>2016-10-10 12:23:40 +0000
committerMichal Gorny <mgorny@gentoo.org>2016-10-10 12:23:40 +0000
commit7cfe480122b81a3b19f0a0d9a4d22f68da161f08 (patch)
tree038749703bfcdafcc2f0d69252a8528149cfdf78 /clang/test
parentc9edc2ee8d97618ebb0702f66202720b3b8cb29a (diff)
downloadbcm5719-llvm-7cfe480122b81a3b19f0a0d9a4d22f68da161f08.tar.gz
bcm5719-llvm-7cfe480122b81a3b19f0a0d9a4d22f68da161f08.zip
[Driver] Make -print-libgcc-file-name print compiler-rt lib when used
Make the -print-libgcc-file-name option print an appropriate compiler runtime library, that is libgcc.a if gcc runtime is used and an appropriate compiler-rt library if that runtime is used. The main use for this is to allow linking executables built with -nodefaultlibs (e.g. to avoid linking to the standard C++ library) to the compiler runtime library, e.g. using: clang++ ... -nodefaultlibs $(clang++ ... -print-libgcc-file-name) in which case currently a program built like this linked to the gcc runtime unconditionally. The patch fixes it to use compiler-rt libraries instead when compiler-rt is the active runtime. Differential Revision: https://reviews.llvm.org/D25338 llvm-svn: 283746
Diffstat (limited to 'clang/test')
-rw-r--r--clang/test/Driver/montavista-gcc-toolchain.c2
-rw-r--r--clang/test/Driver/print-libgcc-file-name-clangrt.c11
-rw-r--r--clang/test/Driver/print-libgcc-file-name-libgcc.c7
-rw-r--r--clang/test/lit.cfg5
4 files changed, 24 insertions, 1 deletions
diff --git a/clang/test/Driver/montavista-gcc-toolchain.c b/clang/test/Driver/montavista-gcc-toolchain.c
index da76e957943..402e53b63c5 100644
--- a/clang/test/Driver/montavista-gcc-toolchain.c
+++ b/clang/test/Driver/montavista-gcc-toolchain.c
@@ -1,6 +1,6 @@
// Test that the montavista gcc-toolchain is correctly detected
//
-// RUN: %clang -print-libgcc-file-name 2>&1 \
+// RUN: %clang -rtlib=platform -print-libgcc-file-name 2>&1 \
// RUN: --target=i686-montavista-linux \
// RUN: --gcc-toolchain=%S/Inputs/montavista_i686_tree/usr \
// RUN: | FileCheck %s
diff --git a/clang/test/Driver/print-libgcc-file-name-clangrt.c b/clang/test/Driver/print-libgcc-file-name-clangrt.c
new file mode 100644
index 00000000000..9f8120c31d9
--- /dev/null
+++ b/clang/test/Driver/print-libgcc-file-name-clangrt.c
@@ -0,0 +1,11 @@
+// Test that -print-libgcc-file-name correctly respects -rtlib=compiler-rt.
+
+// RUN: %clang -rtlib=compiler-rt -print-libgcc-file-name 2>&1 \
+// RUN: --target=x86_64-pc-linux \
+// RUN: | FileCheck --check-prefix=CHECK-CLANGRT-X8664 %s
+// CHECK-CLANGRT-X8664: libclang_rt.builtins-x86_64.a
+
+// RUN: %clang -rtlib=compiler-rt -print-libgcc-file-name 2>&1 \
+// RUN: --target=i686-pc-linux \
+// RUN: | FileCheck --check-prefix=CHECK-CLANGRT-I686 %s
+// CHECK-CLANGRT-I686: libclang_rt.builtins-i686.a
diff --git a/clang/test/Driver/print-libgcc-file-name-libgcc.c b/clang/test/Driver/print-libgcc-file-name-libgcc.c
new file mode 100644
index 00000000000..3ca8fb900e3
--- /dev/null
+++ b/clang/test/Driver/print-libgcc-file-name-libgcc.c
@@ -0,0 +1,7 @@
+// Test that -print-libgcc-file-name correctly respects -rtlib=libgcc.
+
+// REQUIRES: libgcc
+
+// RUN: %clang -rtlib=libgcc -print-libgcc-file-name 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-LIBGCC %s
+// CHECK-LIBGCC: libgcc.a
diff --git a/clang/test/lit.cfg b/clang/test/lit.cfg
index ad4cf834f91..aea4d6aa316 100644
--- a/clang/test/lit.cfg
+++ b/clang/test/lit.cfg
@@ -375,6 +375,11 @@ if platform.system() not in ['Windows']:
if platform.system() not in ['Windows']:
config.available_features.add('utf8-capable-terminal')
+# Support for libgcc runtime. Used to rule out tests that require
+# clang to run with -rtlib=libgcc.
+if platform.system() not in ['Darwin', 'Fuchsia']:
+ config.available_features.add('libgcc')
+
# Native compilation: Check if triples match.
# FIXME: Consider cases that target can be executed
# even if host_triple were different from target_triple.
OpenPOWER on IntegriCloud