[compiler-rt] 3aecf4b - On FreeBSD, add -pthread to ASan dynamic compile flags for tests

Dimitry Andric via llvm-commits llvm-commits at lists.llvm.org
Sat Aug 15 04:05:46 PDT 2020


Author: Dimitry Andric
Date: 2020-08-15T13:05:31+02:00
New Revision: 3aecf4bdf3f87e674724ad58d94c4b728feecb2e

URL: https://github.com/llvm/llvm-project/commit/3aecf4bdf3f87e674724ad58d94c4b728feecb2e
DIFF: https://github.com/llvm/llvm-project/commit/3aecf4bdf3f87e674724ad58d94c4b728feecb2e.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

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-commits mailing list