Skip to content

Commit 3aecf4b

Browse files
committed
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
1 parent f134fc4 commit 3aecf4b

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,12 @@ def push_dynamic_library_lookup_path(config, new_path):
9191
asan_dynamic_flags = []
9292
if config.asan_dynamic:
9393
asan_dynamic_flags = ["-shared-libasan"]
94-
# On Windows, we need to simulate "clang-cl /MD" on the clang driver side.
9594
if platform.system() == 'Windows':
95+
# On Windows, we need to simulate "clang-cl /MD" on the clang driver side.
9696
asan_dynamic_flags += ["-D_MT", "-D_DLL", "-Wl,-nodefaultlib:libcmt,-defaultlib:msvcrt,-defaultlib:oldnames"]
97+
elif platform.system() == 'FreeBSD':
98+
# On FreeBSD, we need to add -pthread to ensure pthread functions are available.
99+
asan_dynamic_flags += ['-pthread']
97100
config.available_features.add("asan-dynamic-runtime")
98101
else:
99102
config.available_features.add("asan-static-runtime")

0 commit comments

Comments
 (0)