[PATCH] D59334: [TSan][libdispatch] Enable linking of libcxx and tests on Linux
Julian Lettner via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 13 14:55:43 PDT 2019
yln created this revision.
Herald added subscribers: llvm-commits, Sanitizers, mgorny, kubamracek.
Herald added a reviewer: EricWF.
Herald added projects: Sanitizers, LLVM.
Also add cmake options for specifying additional library paths to
instruct the linker where to search for libdispatch and the blocks
runtime. This allows us to build TSan runtime with libdispatch support
without installing those libraries into default linker library paths.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D59334
Files:
compiler-rt/CMakeLists.txt
compiler-rt/lib/tsan/CMakeLists.txt
compiler-rt/lib/tsan/tests/CMakeLists.txt
Index: compiler-rt/lib/tsan/tests/CMakeLists.txt
===================================================================
--- compiler-rt/lib/tsan/tests/CMakeLists.txt
+++ compiler-rt/lib/tsan/tests/CMakeLists.txt
@@ -45,6 +45,11 @@
else()
list(APPEND LINK_FLAGS -fsanitize=thread)
list(APPEND LINK_FLAGS -lm)
+ if (COMPILER_RT_INTERCEPT_LIBDISPATCH)
+ list(APPEND LINK_FLAGS
+ ${COMPILER_RT_BLOCKS_RUNTIME_LIBRARY_PATH_LINK_FLAG} -lBlocksRuntime
+ ${COMPILER_RT_LIBDISPATCH_LIBRARY_PATH_LINK_FLAG} -ldispatch)
+ endif()
endif()
set(TSAN_RTL_HEADERS)
Index: compiler-rt/lib/tsan/CMakeLists.txt
===================================================================
--- compiler-rt/lib/tsan/CMakeLists.txt
+++ compiler-rt/lib/tsan/CMakeLists.txt
@@ -246,13 +246,18 @@
COMPILER_RT_LIBCXXABI_PATH AND
COMPILER_RT_TEST_COMPILER_ID STREQUAL "Clang" AND
NOT ANDROID)
+ if(COMPILER_RT_INTERCEPT_LIBDISPATCH AND NOT APPLE)
+ set(libdispatch_link_flags
+ ${COMPILER_RT_BLOCKS_RUNTIME_LIBRARY_PATH_LINK_FLAG} -lBlocksRuntime
+ ${COMPILER_RT_LIBDISPATCH_LIBRARY_PATH_LINK_FLAG} -ldispatch)
+ endif()
set(libcxx_tsan_deps)
foreach(arch ${TSAN_SUPPORTED_ARCH})
get_target_flags_for_arch(${arch} TARGET_CFLAGS)
set(LIBCXX_PREFIX ${CMAKE_CURRENT_BINARY_DIR}/libcxx_tsan_${arch})
add_custom_libcxx(libcxx_tsan_${arch} ${LIBCXX_PREFIX}
DEPS ${TSAN_RUNTIME_LIBRARIES}
- CFLAGS ${TARGET_CFLAGS} -fsanitize=thread
+ CFLAGS ${TARGET_CFLAGS} -fsanitize=thread ${libdispatch_link_flags}
USE_TOOLCHAIN)
list(APPEND libcxx_tsan_deps libcxx_tsan_${arch}-build)
endforeach()
Index: compiler-rt/CMakeLists.txt
===================================================================
--- compiler-rt/CMakeLists.txt
+++ compiler-rt/CMakeLists.txt
@@ -182,11 +182,21 @@
pythonize_bool(COMPILER_RT_DEBUG)
option(COMPILER_RT_INTERCEPT_LIBDISPATCH
- "Support interception of libdispatch (GCD). Requires '-fblocks'." OFF)
+ "Support interception of libdispatch (GCD). Requires '-fblocks'" OFF)
if (APPLE) # Always enable on Apple platforms.
set(COMPILER_RT_INTERCEPT_LIBDISPATCH ON)
endif()
pythonize_bool(COMPILER_RT_INTERCEPT_LIBDISPATCH)
+option(COMPILER_RT_BLOCKS_RUNTIME_LIBRARY_PATH
+ "Library search path for blocks runtime (-lBlocksRuntime)" "")
+if (COMPILER_RT_BLOCKS_RUNTIME_LIBRARY_PATH)
+ set(COMPILER_RT_BLOCKS_RUNTIME_LIBRARY_PATH_LINK_FLAG -L${COMPILER_RT_BLOCKS_RUNTIME_LIBRARY_PATH})
+endif()
+option(COMPILER_RT_LIBDISPATCH_LIBRARY_PATH
+ "Library search path for libdispatch (-ldispatch)" "")
+if (COMPILER_RT_LIBDISPATCH_LIBRARY_PATH)
+ set(COMPILER_RT_LIBDISPATCH_LIBRARY_PATH_LINK_FLAG -L${COMPILER_RT_LIBDISPATCH_LIBRARY_PATH})
+endif()
if(APPLE AND SANITIZER_MIN_OSX_VERSION AND SANITIZER_MIN_OSX_VERSION VERSION_LESS "10.9")
# Mac OS X prior to 10.9 had problems with exporting symbols from
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D59334.190516.patch
Type: text/x-patch
Size: 2905 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190313/6d53afda/attachment.bin>
More information about the llvm-commits
mailing list