[PATCH] D14509: Enable tsan-instrumented libcxx on Darwin
Ismail Pazarbasi via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 9 12:27:09 PST 2015
ismailp created this revision.
ismailp added reviewers: kubabrecka, dvyukov, glider, samsonov, kcc.
ismailp added subscribers: llvm-commits, zaks.anna.
Instrumented libcxx depends on symbols that are exported by TSan RTL.
http://reviews.llvm.org/D14509
Files:
cmake/Modules/AddCompilerRT.cmake
test/tsan/CMakeLists.txt
test/tsan/lit.cfg
Index: test/tsan/lit.cfg
===================================================================
--- test/tsan/lit.cfg
+++ test/tsan/lit.cfg
@@ -37,6 +37,9 @@
clang_tsan_cflags = ["-fsanitize=thread",
"-Wall",
"-m64"] + config.debug_info_flags + extra_cflags
+if config.host_os == 'Darwin':
+ clang_tsan_cflags.extend(["-isystem", os.path.join(config.test_source_root)])
+
clang_tsan_cxxflags = config.cxx_mode_flags + clang_tsan_cflags
# Add additional flags if we're using instrumented libc++.
# Instrumented libcxx currently not supported on Darwin.
@@ -46,11 +49,16 @@
"tsan", "libcxx_tsan")
libcxx_incdir = os.path.join(libcxx_path, "include", "c++", "v1")
libcxx_libdir = os.path.join(libcxx_path, "lib")
- libcxx_so = os.path.join(libcxx_libdir, "libc++.so")
+ if config.host_os == 'Darwin':
+ libcxx_so = os.path.join(libcxx_libdir, "libc++.dylib")
+ rpath_flag = '-Wl,-rpath,%s' % libcxx_so
+ else:
+ libcxx_so = os.path.join(libcxx_libdir, "libc++.so")
+ rpath_flag = '-Wl,-rpath=%s' % libcxx_so
clang_tsan_cxxflags += ["-std=c++11",
"-I%s" % libcxx_incdir,
libcxx_so,
- "-Wl,-rpath=%s" % libcxx_libdir]
+ rpath_flag]
def build_invocation(compile_flags):
return " " + " ".join([config.clang] + compile_flags) + " "
Index: test/tsan/CMakeLists.txt
===================================================================
--- test/tsan/CMakeLists.txt
+++ test/tsan/CMakeLists.txt
@@ -6,8 +6,7 @@
list(APPEND TSAN_TEST_DEPS tsan)
endif()
if(COMPILER_RT_HAS_LIBCXX_SOURCES AND
- COMPILER_RT_TEST_COMPILER_ID STREQUAL "Clang"
- AND NOT APPLE)
+ COMPILER_RT_TEST_COMPILER_ID STREQUAL "Clang")
list(APPEND TSAN_TEST_DEPS libcxx_tsan)
set(TSAN_HAS_LIBCXX True)
else()
Index: cmake/Modules/AddCompilerRT.cmake
===================================================================
--- cmake/Modules/AddCompilerRT.cmake
+++ cmake/Modules/AddCompilerRT.cmake
@@ -280,6 +280,10 @@
if(NOT COMPILER_RT_STANDALONE_BUILD)
list(APPEND LIBCXX_DEPS clang)
endif()
+ set(LIBCXX_SHARED_LINKER_FLAGS)
+ if (APPLE)
+ set(LIBCXX_SHARED_LINKER_FLAGS "-undefined dynamic_lookup")
+ endif()
ExternalProject_Add(${name}
PREFIX ${prefix}
@@ -289,6 +293,7 @@
-DCMAKE_C_FLAGS=${LIBCXX_CFLAGS}
-DCMAKE_CXX_FLAGS=${LIBCXX_CFLAGS}
-DCMAKE_BUILD_TYPE=Release
+ -DCMAKE_SHARED_LINKER_FLAGS=${LIBCXX_SHARED_LINKER_FLAGS}
-DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
LOG_BUILD 1
LOG_CONFIGURE 1
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D14509.39738.patch
Type: text/x-patch
Size: 2698 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151109/de2661cb/attachment.bin>
More information about the llvm-commits
mailing list