[compiler-rt] r354231 - [compiler-rt] Fix broken sanitizer bots (hopefully)

Jonas Hahnfeld via llvm-commits llvm-commits at lists.llvm.org
Sun Feb 17 10:47:34 PST 2019


Author: hahnfeld
Date: Sun Feb 17 10:47:33 2019
New Revision: 354231

URL: http://llvm.org/viewvc/llvm-project?rev=354231&view=rev
Log:
[compiler-rt] Fix broken sanitizer bots (hopefully)

According to the logs and local debugging there were two issues:
1) tsan tests listed libc++.a before the source file. That's usually
   ok for shared libraries, but the linker will not add symbols from
   a static library unless needed at that time. As a result the tests
   that rely upon symbols from the library (and not only include the
   headers) had undefined references.
   To solve this I'm adding a new substitution %link_libcxx_tsan which
   expands to libc++.a if available.
2) The target Fuzzer-x86_64-Test linked in SANITIZER_TEST_CXX_LIBRARIES
   which defaults to -lstdc++. This resulted in error messages like
     hidden symbol '_ZdlPv' is not defined locally
     hidden symbol '_Znwm' is not defined locally
   when using GNU gold (ld.bfd and lld are fine). Removing the linkage
   is fine because we build a custom libc++ for that purpose.

Modified:
    compiler-rt/trunk/lib/fuzzer/tests/CMakeLists.txt
    compiler-rt/trunk/test/tsan/dl_iterate_phdr.cc
    compiler-rt/trunk/test/tsan/dlclose.cc
    compiler-rt/trunk/test/tsan/ignore_lib0.cc
    compiler-rt/trunk/test/tsan/ignore_lib1.cc
    compiler-rt/trunk/test/tsan/ignore_lib2.cc
    compiler-rt/trunk/test/tsan/ignore_lib3.cc
    compiler-rt/trunk/test/tsan/ignore_lib4.cc
    compiler-rt/trunk/test/tsan/ignore_lib5.cc
    compiler-rt/trunk/test/tsan/libcxx/std_shared_ptr.cc
    compiler-rt/trunk/test/tsan/lit.cfg
    compiler-rt/trunk/test/tsan/load_shared_lib.cc
    compiler-rt/trunk/test/tsan/real_deadlock_detector_stress_test.cc

Modified: compiler-rt/trunk/lib/fuzzer/tests/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/fuzzer/tests/CMakeLists.txt?rev=354231&r1=354230&r2=354231&view=diff
==============================================================================
--- compiler-rt/trunk/lib/fuzzer/tests/CMakeLists.txt (original)
+++ compiler-rt/trunk/lib/fuzzer/tests/CMakeLists.txt Sun Feb 17 10:47:33 2019
@@ -17,9 +17,6 @@ set_target_properties(FuzzerUnitTests PR
 set(LIBFUZZER_UNITTEST_LINK_FLAGS ${COMPILER_RT_UNITTEST_LINK_FLAGS})
 list(APPEND LIBFUZZER_UNITTEST_LINK_FLAGS --driver-mode=g++)
 
-foreach(lib ${SANITIZER_TEST_CXX_LIBRARIES})
-  list(APPEND LIBFUZZER_UNITTEST_LINK_FLAGS -l${lib})
-endforeach()
 if(NOT WIN32)
   list(APPEND LIBFUZZER_UNITTEST_LINK_FLAGS -lpthread)
 endif()

Modified: compiler-rt/trunk/test/tsan/dl_iterate_phdr.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/tsan/dl_iterate_phdr.cc?rev=354231&r1=354230&r2=354231&view=diff
==============================================================================
--- compiler-rt/trunk/test/tsan/dl_iterate_phdr.cc (original)
+++ compiler-rt/trunk/test/tsan/dl_iterate_phdr.cc Sun Feb 17 10:47:33 2019
@@ -1,5 +1,5 @@
 // RUN: %clangxx_tsan -O1 %s -DBUILD_SO -fPIC -shared -o %t-so.so
-// RUN: %clangxx_tsan -O1 %s -o %t && %run %t 2>&1 | FileCheck %s
+// RUN: %clangxx_tsan -O1 %s %link_libcxx_tsan -o %t && %run %t 2>&1 | FileCheck %s
 
 // dl_iterate_phdr doesn't exist on OS X.
 // UNSUPPORTED: darwin

Modified: compiler-rt/trunk/test/tsan/dlclose.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/tsan/dlclose.cc?rev=354231&r1=354230&r2=354231&view=diff
==============================================================================
--- compiler-rt/trunk/test/tsan/dlclose.cc (original)
+++ compiler-rt/trunk/test/tsan/dlclose.cc Sun Feb 17 10:47:33 2019
@@ -1,5 +1,5 @@
 // RUN: %clangxx_tsan -O1 %s -DBUILD_SO -fPIC -shared -o %t-so.so
-// RUN: %clangxx_tsan -O1 %s -o %t && %run %t 2>&1 | FileCheck %s
+// RUN: %clangxx_tsan -O1 %s %link_libcxx_tsan -o %t && %run %t 2>&1 | FileCheck %s
 
 // Test case for
 // https://github.com/google/sanitizers/issues/487

Modified: compiler-rt/trunk/test/tsan/ignore_lib0.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/tsan/ignore_lib0.cc?rev=354231&r1=354230&r2=354231&view=diff
==============================================================================
--- compiler-rt/trunk/test/tsan/ignore_lib0.cc (original)
+++ compiler-rt/trunk/test/tsan/ignore_lib0.cc Sun Feb 17 10:47:33 2019
@@ -2,7 +2,7 @@
 // RUN: mkdir %t-dir
 
 // RUN: %clangxx_tsan -O1 %s -DLIB -fPIC -fno-sanitize=thread -shared -o %t-dir/libignore_lib0.so
-// RUN: %clangxx_tsan -O1 %s -L%t-dir -lignore_lib0 -o %t
+// RUN: %clangxx_tsan -O1 %s -L%t-dir -lignore_lib0 %link_libcxx_tsan -o %t
 // RUN: echo running w/o suppressions:
 // RUN: env LD_LIBRARY_PATH=%t-dir${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH} %deflake %run %t | FileCheck %s --check-prefix=CHECK-NOSUPP
 // RUN: echo running with suppressions:

Modified: compiler-rt/trunk/test/tsan/ignore_lib1.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/tsan/ignore_lib1.cc?rev=354231&r1=354230&r2=354231&view=diff
==============================================================================
--- compiler-rt/trunk/test/tsan/ignore_lib1.cc (original)
+++ compiler-rt/trunk/test/tsan/ignore_lib1.cc Sun Feb 17 10:47:33 2019
@@ -2,7 +2,7 @@
 // RUN: mkdir %t-dir
 
 // RUN: %clangxx_tsan -O1 %s -DLIB -fPIC -fno-sanitize=thread -shared -o %t-dir/libignore_lib1.so
-// RUN: %clangxx_tsan -O1 %s -o %t-dir/executable
+// RUN: %clangxx_tsan -O1 %s %link_libcxx_tsan -o %t-dir/executable
 // RUN: echo running w/o suppressions:
 // RUN: %deflake %run %t-dir/executable | FileCheck %s --check-prefix=CHECK-NOSUPP
 // RUN: echo running with suppressions:

Modified: compiler-rt/trunk/test/tsan/ignore_lib2.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/tsan/ignore_lib2.cc?rev=354231&r1=354230&r2=354231&view=diff
==============================================================================
--- compiler-rt/trunk/test/tsan/ignore_lib2.cc (original)
+++ compiler-rt/trunk/test/tsan/ignore_lib2.cc Sun Feb 17 10:47:33 2019
@@ -3,7 +3,7 @@
 
 // RUN: %clangxx_tsan -O1 %s -DLIB -fPIC -fno-sanitize=thread -shared -o %t-dir/libignore_lib2_0.so
 // RUN: %clangxx_tsan -O1 %s -DLIB -fPIC -fno-sanitize=thread -shared -o %t-dir/libignore_lib2_1.so
-// RUN: %clangxx_tsan -O1 %s -o %t-dir/executable
+// RUN: %clangxx_tsan -O1 %s %link_libcxx_tsan -o %t-dir/executable
 // RUN: %env_tsan_opts=suppressions='%s.supp' %deflake %run %t-dir/executable | FileCheck %s
 
 // Tests that called_from_lib suppression matched against 2 libraries

Modified: compiler-rt/trunk/test/tsan/ignore_lib3.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/tsan/ignore_lib3.cc?rev=354231&r1=354230&r2=354231&view=diff
==============================================================================
--- compiler-rt/trunk/test/tsan/ignore_lib3.cc (original)
+++ compiler-rt/trunk/test/tsan/ignore_lib3.cc Sun Feb 17 10:47:33 2019
@@ -2,7 +2,7 @@
 // RUN: mkdir %t-dir
 
 // RUN: %clangxx_tsan -O1 %s -DLIB -fPIC -fno-sanitize=thread -shared -o %t-dir/libignore_lib3.so
-// RUN: %clangxx_tsan -O1 %s -o %t-dir/executable
+// RUN: %clangxx_tsan -O1 %s %link_libcxx_tsan -o %t-dir/executable
 // RUN: %env_tsan_opts=suppressions='%s.supp' %deflake %run %t-dir/executable | FileCheck %s
 
 // Tests that unloading of a library matched against called_from_lib suppression

Modified: compiler-rt/trunk/test/tsan/ignore_lib4.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/tsan/ignore_lib4.cc?rev=354231&r1=354230&r2=354231&view=diff
==============================================================================
--- compiler-rt/trunk/test/tsan/ignore_lib4.cc (original)
+++ compiler-rt/trunk/test/tsan/ignore_lib4.cc Sun Feb 17 10:47:33 2019
@@ -2,7 +2,7 @@
 // RUN: mkdir %t-dir
 
 // RUN: %clangxx_tsan -O1 %s -DLIB -fPIC -shared -o %t-dir/libignore_lib4.so
-// RUN: %clangxx_tsan -O1 %s -o %t-dir/executable
+// RUN: %clangxx_tsan -O1 %s %link_libcxx_tsan -o %t-dir/executable
 // RUN: echo "called_from_lib:libignore_lib4.so" > %t-dir/executable.supp
 // RUN: %env_tsan_opts=suppressions='%t-dir/executable.supp' %run %t-dir/executable 2>&1 | FileCheck %s
 

Modified: compiler-rt/trunk/test/tsan/ignore_lib5.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/tsan/ignore_lib5.cc?rev=354231&r1=354230&r2=354231&view=diff
==============================================================================
--- compiler-rt/trunk/test/tsan/ignore_lib5.cc (original)
+++ compiler-rt/trunk/test/tsan/ignore_lib5.cc Sun Feb 17 10:47:33 2019
@@ -2,7 +2,7 @@
 // RUN: mkdir %t-dir
 
 // RUN: %clangxx_tsan -O1 %s -DLIB -fPIC -fno-sanitize=thread -shared -o %t-dir/libignore_lib1.so
-// RUN: %clangxx_tsan -O1 %s -o %t-dir/executable
+// RUN: %clangxx_tsan -O1 %s %link_libcxx_tsan -o %t-dir/executable
 // RUN: echo running w/o suppressions:
 // RUN: %deflake %run %t-dir/executable | FileCheck %s --check-prefix=CHECK-NOSUPP
 // RUN: echo running with suppressions:

Modified: compiler-rt/trunk/test/tsan/libcxx/std_shared_ptr.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/tsan/libcxx/std_shared_ptr.cc?rev=354231&r1=354230&r2=354231&view=diff
==============================================================================
--- compiler-rt/trunk/test/tsan/libcxx/std_shared_ptr.cc (original)
+++ compiler-rt/trunk/test/tsan/libcxx/std_shared_ptr.cc Sun Feb 17 10:47:33 2019
@@ -1,4 +1,4 @@
-// RUN: %clangxx_tsan -O1 %s -o %t && %run %t 2>&1 | FileCheck %s
+// RUN: %clangxx_tsan -O1 %s %link_libcxx_tsan -o %t && %run %t 2>&1 | FileCheck %s
 #include <stdio.h>
 #include <memory>
 #include <thread>

Modified: compiler-rt/trunk/test/tsan/lit.cfg
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/tsan/lit.cfg?rev=354231&r1=354230&r2=354231&view=diff
==============================================================================
--- compiler-rt/trunk/test/tsan/lit.cfg (original)
+++ compiler-rt/trunk/test/tsan/lit.cfg Sun Feb 17 10:47:33 2019
@@ -61,8 +61,10 @@ if config.has_libcxx and config.host_os
   libcxx_libdir = os.path.join(libcxx_path, "lib")
   libcxx_a = os.path.join(libcxx_libdir, "libc++.a")
   clang_tsan_cxxflags += ["-nostdinc++",
-                          "-I%s" % libcxx_incdir,
-                          libcxx_a]
+                          "-I%s" % libcxx_incdir]
+  config.substitutions.append( ("%link_libcxx_tsan", libcxx_a) )
+else:
+  config.substitutions.append( ("%link_libcxx_tsan", "") )
 
 def build_invocation(compile_flags):
   return " " + " ".join([config.clang] + compile_flags) + " "

Modified: compiler-rt/trunk/test/tsan/load_shared_lib.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/tsan/load_shared_lib.cc?rev=354231&r1=354230&r2=354231&view=diff
==============================================================================
--- compiler-rt/trunk/test/tsan/load_shared_lib.cc (original)
+++ compiler-rt/trunk/test/tsan/load_shared_lib.cc Sun Feb 17 10:47:33 2019
@@ -3,7 +3,7 @@
 // symbolized correctly.
 
 // RUN: %clangxx_tsan -O1 %s -DBUILD_SO -fPIC -shared -o %t-so.so
-// RUN: %clangxx_tsan -O1 %s -o %t -rdynamic && %deflake %run %t | FileCheck %s
+// RUN: %clangxx_tsan -O1 %s %link_libcxx_tsan -o %t -rdynamic && %deflake %run %t | FileCheck %s
 
 #ifdef BUILD_SO
 

Modified: compiler-rt/trunk/test/tsan/real_deadlock_detector_stress_test.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/tsan/real_deadlock_detector_stress_test.cc?rev=354231&r1=354230&r2=354231&view=diff
==============================================================================
--- compiler-rt/trunk/test/tsan/real_deadlock_detector_stress_test.cc (original)
+++ compiler-rt/trunk/test/tsan/real_deadlock_detector_stress_test.cc Sun Feb 17 10:47:33 2019
@@ -1,4 +1,4 @@
-// RUN: %clangxx_tsan -O1 %s -o %t && %run %t 2>&1 | FileCheck %s
+// RUN: %clangxx_tsan -O1 %s %link_libcxx_tsan -o %t && %run %t 2>&1 | FileCheck %s
 
 #include <pthread.h>
 #include <stdlib.h>




More information about the llvm-commits mailing list