[compiler-rt] r332254 - Fix another case where libstdc++ is being inappropriately requested (see
Dan Liew via llvm-commits
llvm-commits at lists.llvm.org
Mon May 14 08:48:49 PDT 2018
Author: delcypher
Date: Mon May 14 08:48:49 2018
New Revision: 332254
URL: http://llvm.org/viewvc/llvm-project?rev=332254&view=rev
Log:
Fix another case where libstdc++ is being inappropriately requested (see
r328775) for all platforms.
Given that this is the second occurance of this problem it seemed worth
fixing this problem in a more generic way. r328775 has been reverted and
now a substitution `%linux_static_libstdcplusplus` has been provided.
This substitution expands to Clang driver arguments to use a static
libstdc++ on Linux and on all other platforms it expands to nothing.
The `asan/TestCases/throw_invoke_test.cc` and
`test/tsan/static_init6.cc` test cases now use this substitution.
rdar://problem/39948818
Differential Revision: https://reviews.llvm.org/D46401
Removed:
compiler-rt/trunk/test/asan/TestCases/Linux/throw_invoke_test_libstdcxx.cc
Modified:
compiler-rt/trunk/test/asan/TestCases/throw_invoke_test.cc
compiler-rt/trunk/test/lit.common.cfg
compiler-rt/trunk/test/tsan/static_init6.cc
Removed: compiler-rt/trunk/test/asan/TestCases/Linux/throw_invoke_test_libstdcxx.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/Linux/throw_invoke_test_libstdcxx.cc?rev=332253&view=auto
==============================================================================
--- compiler-rt/trunk/test/asan/TestCases/Linux/throw_invoke_test_libstdcxx.cc (original)
+++ compiler-rt/trunk/test/asan/TestCases/Linux/throw_invoke_test_libstdcxx.cc (removed)
@@ -1,48 +0,0 @@
-// This the basically the `throw_invoke_test.cc` test but using libstdc++
-// instead of the default.
-// RUN: %clangxx_asan %s -o %t -stdlib=libstdc++ -static-libstdc++ && %run %t
-
-#include <stdio.h>
-static volatile int zero = 0;
-inline void pretend_to_do_something(void *x) {
- __asm__ __volatile__("" : : "r"(x) : "memory");
-}
-
-__attribute__((noinline)) void ReallyThrow() {
- fprintf(stderr, "ReallyThrow\n");
- try {
- if (zero == 0)
- throw 42;
- else if (zero == 1)
- throw 1.;
- } catch (double x) {
- }
-}
-
-__attribute__((noinline)) void Throw() {
- int a, b, c, d, e;
- pretend_to_do_something(&a);
- pretend_to_do_something(&b);
- pretend_to_do_something(&c);
- pretend_to_do_something(&d);
- pretend_to_do_something(&e);
- fprintf(stderr, "Throw stack = %p\n", &a);
- ReallyThrow();
-}
-
-__attribute__((noinline)) void CheckStack() {
- int ar[100];
- pretend_to_do_something(ar);
- for (int i = 0; i < 100; i++)
- ar[i] = i;
- fprintf(stderr, "CheckStack stack = %p, %p\n", ar, ar + 100);
-}
-
-int main(int argc, char **argv) {
- try {
- Throw();
- } catch (int a) {
- fprintf(stderr, "a = %d\n", a);
- }
- CheckStack();
-}
Modified: compiler-rt/trunk/test/asan/TestCases/throw_invoke_test.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/throw_invoke_test.cc?rev=332254&r1=332253&r2=332254&view=diff
==============================================================================
--- compiler-rt/trunk/test/asan/TestCases/throw_invoke_test.cc (original)
+++ compiler-rt/trunk/test/asan/TestCases/throw_invoke_test.cc Mon May 14 08:48:49 2018
@@ -1,4 +1,5 @@
// RUN: %clangxx_asan %s -o %t && %run %t
+// RUN: %clangxx_asan %s -o %t %linux_static_libstdcplusplus && %run %t
#include <stdio.h>
static volatile int zero = 0;
Modified: compiler-rt/trunk/test/lit.common.cfg
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/lit.common.cfg?rev=332254&r1=332253&r2=332254&view=diff
==============================================================================
--- compiler-rt/trunk/test/lit.common.cfg (original)
+++ compiler-rt/trunk/test/lit.common.cfg Mon May 14 08:48:49 2018
@@ -322,6 +322,14 @@ elif config.host_os == 'SunOS':
config.substitutions.append( ("%ld_flags_rpath_exe", "-Wl,-R\$ORIGIN -L%T -l%xdynamiclib_namespec") )
config.substitutions.append( ("%ld_flags_rpath_so", '') )
+# Provide a substituion that can be used to tell Clang to use a static libstdc++.
+# The substitution expands to nothing on non Linux platforms.
+# FIXME: This should check the target OS, not the host OS.
+if config.host_os == 'Linux':
+ config.substitutions.append( ("%linux_static_libstdcplusplus", "-stdlib=libstdc++ -static-libstdc++") )
+else:
+ config.substitutions.append( ("%linux_static_libstdcplusplus", "") )
+
# Must be defined after the substitutions that use %dynamiclib.
config.substitutions.append( ("%dynamiclib", '%T/%xdynamiclib_filename') )
config.substitutions.append( ("%xdynamiclib_filename", 'lib%xdynamiclib_namespec.so') )
Modified: compiler-rt/trunk/test/tsan/static_init6.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/tsan/static_init6.cc?rev=332254&r1=332253&r2=332254&view=diff
==============================================================================
--- compiler-rt/trunk/test/tsan/static_init6.cc (original)
+++ compiler-rt/trunk/test/tsan/static_init6.cc Mon May 14 08:48:49 2018
@@ -1,4 +1,5 @@
-// RUN: %clangxx_tsan -stdlib=libstdc++ -static-libstdc++ -O1 %s -o %t && %run %t 2>&1 | FileCheck %s
+// RUN: %clangxx_tsan %linux_static_libstdcplusplus -O1 %s -o %t && %run %t 2>&1 \
+// RUN: | FileCheck %s
#include <pthread.h>
#include <stdlib.h>
#include <stdio.h>
More information about the llvm-commits
mailing list