[compiler-rt] r356281 - [TSan][libdispatch] Enable linking and running of tests on Linux
Julian Lettner via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 15 10:52:28 PDT 2019
Author: yln
Date: Fri Mar 15 10:52:27 2019
New Revision: 356281
URL: http://llvm.org/viewvc/llvm-project?rev=356281&view=rev
Log:
[TSan][libdispatch] Enable linking and running of tests on Linux
When COMPILER_RT_INTERCEPT_LIBDISPATCH is ON the TSan runtime library
now has a dependency on the blocks runtime and libdispatch. Make sure we
set all the required linking options.
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.
`CMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY` is necessary to avoid
aborting the build due to failing the link step in CMake's
check_c_compiler test.
Reviewed By: dvyukov, kubamracek
Differential Revision: https://reviews.llvm.org/D59334
Modified:
compiler-rt/trunk/CMakeLists.txt
compiler-rt/trunk/cmake/Modules/AddCompilerRT.cmake
compiler-rt/trunk/lib/tsan/CMakeLists.txt
compiler-rt/trunk/lib/tsan/tests/CMakeLists.txt
compiler-rt/trunk/test/tsan/CMakeLists.txt
Modified: compiler-rt/trunk/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/CMakeLists.txt?rev=356281&r1=356280&r2=356281&view=diff
==============================================================================
--- compiler-rt/trunk/CMakeLists.txt (original)
+++ compiler-rt/trunk/CMakeLists.txt Fri Mar 15 10:52:27 2019
@@ -182,7 +182,26 @@ option(COMPILER_RT_EXTERNALIZE_DEBUGINFO
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)
+option(COMPILER_RT_BLOCKS_RUNTIME_LIBRARY_PATH
+ "Library search path for blocks runtime (-lBlocksRuntime)" "")
+option(COMPILER_RT_LIBDISPATCH_LIBRARY_PATH
+ "Library search path for libdispatch (-ldispatch)" "")
+if (COMPILER_RT_INTERCEPT_LIBDISPATCH)
+ set(COMPILER_RT_INTERCEPT_LIBDISPATCH_CFLAGS -fblocks)
+ set(COMPILER_RT_INTERCEPT_LIBDISPATCH_LINK_FLAGS)
+ if (COMPILER_RT_BLOCKS_RUNTIME_LIBRARY_PATH)
+ list(APPEND COMPILER_RT_INTERCEPT_LIBDISPATCH_LINK_FLAGS
+ -L${COMPILER_RT_BLOCKS_RUNTIME_LIBRARY_PATH}
+ -Wl,-rpath=${COMPILER_RT_BLOCKS_RUNTIME_LIBRARY_PATH})
+ endif()
+ if (COMPILER_RT_LIBDISPATCH_LIBRARY_PATH)
+ list(APPEND COMPILER_RT_INTERCEPT_LIBDISPATCH_LINK_FLAGS
+ -L${COMPILER_RT_LIBDISPATCH_LIBRARY_PATH}
+ -Wl,-rpath=${COMPILER_RT_LIBDISPATCH_LIBRARY_PATH})
+ endif()
+ list(APPEND COMPILER_RT_INTERCEPT_LIBDISPATCH_LINK_FLAGS -lBlocksRuntime -ldispatch)
+endif()
if (APPLE) # Always enable on Apple platforms.
set(COMPILER_RT_INTERCEPT_LIBDISPATCH ON)
endif()
Modified: compiler-rt/trunk/cmake/Modules/AddCompilerRT.cmake
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/cmake/Modules/AddCompilerRT.cmake?rev=356281&r1=356280&r2=356281&view=diff
==============================================================================
--- compiler-rt/trunk/cmake/Modules/AddCompilerRT.cmake (original)
+++ compiler-rt/trunk/cmake/Modules/AddCompilerRT.cmake Fri Mar 15 10:52:27 2019
@@ -595,6 +595,7 @@ macro(add_custom_libcxx name prefix)
-DCMAKE_C_FLAGS=${LIBCXX_C_FLAGS}
-DCMAKE_CXX_FLAGS=${LIBCXX_CXX_FLAGS}
-DCMAKE_BUILD_TYPE=Release
+ -DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY
-DLLVM_PATH=${LLVM_MAIN_SRC_DIR}
-DLLVM_BINARY_DIR=${prefix}
-DLLVM_LIBRARY_OUTPUT_INTDIR=${prefix}/lib
Modified: compiler-rt/trunk/lib/tsan/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/CMakeLists.txt?rev=356281&r1=356280&r2=356281&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/CMakeLists.txt (original)
+++ compiler-rt/trunk/lib/tsan/CMakeLists.txt Fri Mar 15 10:52:27 2019
@@ -72,10 +72,7 @@ endif()
if(COMPILER_RT_INTERCEPT_LIBDISPATCH)
list(APPEND TSAN_SOURCES rtl/tsan_libdispatch.cc)
- # Libdispatch support for non-Apple platforms requires '-fblocks'.
- if (NOT APPLE)
- list(APPEND TSAN_RTL_CFLAGS "-fblocks")
- endif()
+ list(APPEND TSAN_RTL_CFLAGS ${COMPILER_RT_INTERCEPT_LIBDISPATCH_CFLAGS})
endif()
set(TSAN_HEADERS
Modified: compiler-rt/trunk/lib/tsan/tests/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/tests/CMakeLists.txt?rev=356281&r1=356280&r2=356281&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/tests/CMakeLists.txt (original)
+++ compiler-rt/trunk/lib/tsan/tests/CMakeLists.txt Fri Mar 15 10:52:27 2019
@@ -45,6 +45,7 @@ if(APPLE)
else()
list(APPEND LINK_FLAGS -fsanitize=thread)
list(APPEND LINK_FLAGS -lm)
+ list(APPEND LINK_FLAGS ${COMPILER_RT_INTERCEPT_LIBDISPATCH_LINK_FLAGS})
endif()
set(TSAN_RTL_HEADERS)
Modified: compiler-rt/trunk/test/tsan/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/tsan/CMakeLists.txt?rev=356281&r1=356280&r2=356281&view=diff
==============================================================================
--- compiler-rt/trunk/test/tsan/CMakeLists.txt (original)
+++ compiler-rt/trunk/test/tsan/CMakeLists.txt Fri Mar 15 10:52:27 2019
@@ -31,6 +31,9 @@ foreach(arch ${TSAN_TEST_ARCH})
string(TOLOWER "-${arch}" TSAN_TEST_CONFIG_SUFFIX)
get_test_cc_for_arch(${arch} TSAN_TEST_TARGET_CC TSAN_TEST_TARGET_CFLAGS)
+ string(REPLACE ";" " " LIBDISPATCH_LINK_FLAGS_STRING " ${COMPILER_RT_INTERCEPT_LIBDISPATCH_LINK_FLAGS}")
+ string(APPEND TSAN_TEST_TARGET_CFLAGS ${LIBDISPATCH_LINK_FLAGS_STRING})
+
string(TOUPPER ${arch} ARCH_UPPER_CASE)
set(CONFIG_NAME ${ARCH_UPPER_CASE}Config)
More information about the llvm-commits
mailing list