Skip to content

Commit

Permalink
On FreeBSD, add -pthread to ASan dynamic compile flags for tests
Browse files Browse the repository at this point in the history
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 3aecf4b)
  • Loading branch information
DimitryAndric authored and zmodem committed Aug 18, 2020
1 parent 536f65f commit a3e8436
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion compiler-rt/test/asan/lit.cfg.py
Expand Up @@ -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")
Expand Down

0 comments on commit a3e8436

Please sign in to comment.