[llvm-branch-commits] [compiler-rt] a3e8436 - On FreeBSD, add -pthread to ASan dynamic compile flags for tests

Hans Wennborg via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Tue Aug 18 03:41:25 PDT 2020


Author: Dimitry Andric
Date: 2020-08-18T12:41:06+02:00
New Revision: a3e8436475242e4d4b8669840f3bf954a538f23f

URL: https://github.com/llvm/llvm-project/commit/a3e8436475242e4d4b8669840f3bf954a538f23f
DIFF: https://github.com/llvm/llvm-project/commit/a3e8436475242e4d4b8669840f3bf954a538f23f.diff

LOG: On FreeBSD, add -pthread to ASan dynamic compile flags for tests

Otherwise, lots of these tests fail with a CHECK error similar to:

==12345==AddressSanitizer CHECK failed: compiler-rt/lib/asan/asan_posix.cpp:120 "((0)) == ((pthread_key_create(&tsd_key, destructor)))" (0x0, 0x4e)

This is because the default pthread stubs in FreeBSD's libc always
return failures (such as ENOSYS for pthread_key_create) in case the
pthread library is not linked in.

Reviewed By: arichardson

Differential Revision: https://reviews.llvm.org/D85082

(cherry picked from commit 3aecf4bdf3f87e674724ad58d94c4b728feecb2e)

Added: 
    

Modified: 
    compiler-rt/test/asan/lit.cfg.py

Removed: 
    


################################################################################
diff  --git a/compiler-rt/test/asan/lit.cfg.py b/compiler-rt/test/asan/lit.cfg.py
index 9045c6ec8f9c..63c02f7ddeeb 100644
--- a/compiler-rt/test/asan/lit.cfg.py
+++ b/compiler-rt/test/asan/lit.cfg.py
@@ -91,9 +91,12 @@ def push_dynamic_library_lookup_path(config, new_path):
 asan_dynamic_flags = []
 if config.asan_dynamic:
   asan_dynamic_flags = ["-shared-libasan"]
-  # On Windows, we need to simulate "clang-cl /MD" on the clang driver side.
   if platform.system() == 'Windows':
+    # On Windows, we need to simulate "clang-cl /MD" on the clang driver side.
     asan_dynamic_flags += ["-D_MT", "-D_DLL", "-Wl,-nodefaultlib:libcmt,-defaultlib:msvcrt,-defaultlib:oldnames"]
+  elif platform.system() == 'FreeBSD':
+    # On FreeBSD, we need to add -pthread to ensure pthread functions are available.
+    asan_dynamic_flags += ['-pthread']
   config.available_features.add("asan-dynamic-runtime")
 else:
   config.available_features.add("asan-static-runtime")


        


More information about the llvm-branch-commits mailing list