aboutsummaryrefslogtreecommitdiff
path: root/cmake/Modules
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2015-01-07 19:55:37 +0000
committerDimitry Andric <dim@FreeBSD.org>2015-01-07 19:55:37 +0000
commitca9211ecdede9bdedb812b2243a4abdb8dacd1b9 (patch)
tree9b19e801150082c33e9152275829a6ce90614b55 /cmake/Modules
parent8ef50bf3d1c287b5013c3168de77a462dfce3495 (diff)
downloadsrc-ca9211ecdede9bdedb812b2243a4abdb8dacd1b9.tar.gz
src-ca9211ecdede9bdedb812b2243a4abdb8dacd1b9.zip
Import compiler-rt trunk r224034.vendor/compiler-rt/compiler-rt-r224034
Notes
Notes: svn path=/vendor/compiler-rt/dist/; revision=276789 svn path=/vendor/compiler-rt/compiler-rt-r224034/; revision=276790; tag=vendor/compiler-rt/compiler-rt-r224034
Diffstat (limited to 'cmake/Modules')
-rw-r--r--cmake/Modules/AddCompilerRT.cmake164
-rw-r--r--cmake/Modules/CompilerRTCompile.cmake71
-rw-r--r--cmake/Modules/CompilerRTLink.cmake10
-rw-r--r--cmake/Modules/CompilerRTUtils.cmake37
-rw-r--r--cmake/Modules/SanitizerUtils.cmake32
5 files changed, 263 insertions, 51 deletions
diff --git a/cmake/Modules/AddCompilerRT.cmake b/cmake/Modules/AddCompilerRT.cmake
index fd117ac522ca..3edd854fdee7 100644
--- a/cmake/Modules/AddCompilerRT.cmake
+++ b/cmake/Modules/AddCompilerRT.cmake
@@ -1,4 +1,5 @@
include(AddLLVM)
+include(ExternalProject)
include(LLVMParseArguments)
include(CompilerRTUtils)
@@ -13,7 +14,7 @@ macro(add_compiler_rt_object_library name arch)
parse_arguments(LIB "SOURCES;CFLAGS;DEFS" "" ${ARGN})
add_library(${name}.${arch} OBJECT ${LIB_SOURCES})
set_target_compile_flags(${name}.${arch}
- ${TARGET_${arch}_CFLAGS} ${LIB_CFLAGS})
+ ${CMAKE_CXX_FLAGS} ${TARGET_${arch}_CFLAGS} ${LIB_CFLAGS})
set_property(TARGET ${name}.${arch} APPEND PROPERTY
COMPILE_DEFINITIONS ${LIB_DEFS})
else()
@@ -37,34 +38,47 @@ macro(add_compiler_rt_darwin_object_library name os)
COMPILE_DEFINITIONS ${LIB_DEFS})
endmacro()
-# Adds static runtime for a given architecture and puts it in the proper
-# directory in the build and install trees.
-# add_compiler_rt_static_runtime(<name> <arch>
-# SOURCES <source files>
-# CFLAGS <compile flags>
-# DEFS <compile definitions>)
-macro(add_compiler_rt_static_runtime name arch)
+# Adds static or shared runtime for a given architecture and puts it in the
+# proper directory in the build and install trees.
+# add_compiler_rt_runtime(<name> <arch> {STATIC,SHARED}
+# SOURCES <source files>
+# CFLAGS <compile flags>
+# DEFS <compile definitions>
+# OUTPUT_NAME <output library name>)
+macro(add_compiler_rt_runtime name arch type)
if(CAN_TARGET_${arch})
- parse_arguments(LIB "SOURCES;CFLAGS;DEFS" "" ${ARGN})
- add_library(${name} STATIC ${LIB_SOURCES})
+ parse_arguments(LIB "SOURCES;CFLAGS;DEFS;OUTPUT_NAME" "" ${ARGN})
+ add_library(${name} ${type} ${LIB_SOURCES})
# Setup compile flags and definitions.
set_target_compile_flags(${name}
${TARGET_${arch}_CFLAGS} ${LIB_CFLAGS})
+ set_target_link_flags(${name}
+ ${TARGET_${arch}_CFLAGS} ${LIB_CFLAGS})
set_property(TARGET ${name} APPEND PROPERTY
COMPILE_DEFINITIONS ${LIB_DEFS})
# Setup correct output directory in the build tree.
set_target_properties(${name} PROPERTIES
- ARCHIVE_OUTPUT_DIRECTORY ${COMPILER_RT_LIBRARY_OUTPUT_DIR})
+ ARCHIVE_OUTPUT_DIRECTORY ${COMPILER_RT_LIBRARY_OUTPUT_DIR}
+ LIBRARY_OUTPUT_DIRECTORY ${COMPILER_RT_LIBRARY_OUTPUT_DIR}
+ RUNTIME_OUTPUT_DIRECTORY ${COMPILER_RT_LIBRARY_OUTPUT_DIR})
+ if ("${LIB_OUTPUT_NAME}" STREQUAL "")
+ set_target_properties(${name} PROPERTIES
+ OUTPUT_NAME ${name}${COMPILER_RT_OS_SUFFIX})
+ else()
+ set_target_properties(${name} PROPERTIES
+ OUTPUT_NAME ${LIB_OUTPUT_NAME})
+ endif()
# Add installation command.
install(TARGETS ${name}
- ARCHIVE DESTINATION ${COMPILER_RT_LIBRARY_INSTALL_DIR})
- add_dependencies(compiler-rt ${name})
+ ARCHIVE DESTINATION ${COMPILER_RT_LIBRARY_INSTALL_DIR}
+ LIBRARY DESTINATION ${COMPILER_RT_LIBRARY_INSTALL_DIR}
+ RUNTIME DESTINATION ${COMPILER_RT_LIBRARY_INSTALL_DIR})
else()
message(FATAL_ERROR "Archtecture ${arch} can't be targeted")
endif()
endmacro()
-# Same as add_compiler_rt_static_runtime, but creates a universal library
+# Same as add_compiler_rt_runtime(... STATIC), but creates a universal library
# for several architectures.
# add_compiler_rt_osx_static_runtime(<name> ARCH <architectures>
# SOURCES <source files>
@@ -81,7 +95,6 @@ macro(add_compiler_rt_osx_static_runtime name)
ARCHIVE_OUTPUT_DIRECTORY ${COMPILER_RT_LIBRARY_OUTPUT_DIR})
install(TARGETS ${name}
ARCHIVE DESTINATION ${COMPILER_RT_LIBRARY_INSTALL_DIR})
- add_dependencies(compiler-rt ${name})
endmacro()
# Adds dynamic runtime library on osx/iossim, which supports multiple
@@ -104,20 +117,43 @@ macro(add_compiler_rt_darwin_dynamic_runtime name os)
LIBRARY_OUTPUT_DIRECTORY ${COMPILER_RT_LIBRARY_OUTPUT_DIR})
install(TARGETS ${name}
LIBRARY DESTINATION ${COMPILER_RT_LIBRARY_INSTALL_DIR})
- add_dependencies(compiler-rt ${name})
endmacro()
+set(COMPILER_RT_TEST_CFLAGS)
+
# Unittests support.
set(COMPILER_RT_GTEST_PATH ${LLVM_MAIN_SRC_DIR}/utils/unittest/googletest)
set(COMPILER_RT_GTEST_SOURCE ${COMPILER_RT_GTEST_PATH}/src/gtest-all.cc)
-set(COMPILER_RT_GTEST_INCLUDE_CFLAGS
+set(COMPILER_RT_GTEST_CFLAGS
-DGTEST_NO_LLVM_RAW_OSTREAM=1
+ -DGTEST_HAS_RTTI=0
-I${COMPILER_RT_GTEST_PATH}/include
-I${COMPILER_RT_GTEST_PATH}
)
-# Use Clang to link objects into a single executable with just-built
-# Clang, using specific link flags. Make executable a part of provided
+if(MSVC)
+ # clang doesn't support exceptions on Windows yet.
+ list(APPEND COMPILER_RT_TEST_CFLAGS
+ -D_HAS_EXCEPTIONS=0)
+
+ # We should teach clang to understand "#pragma intrinsic", see PR19898.
+ list(APPEND COMPILER_RT_TEST_CFLAGS -Wno-undefined-inline)
+
+ # Clang doesn't support SEH on Windows yet.
+ list(APPEND COMPILER_RT_GTEST_CFLAGS -DGTEST_HAS_SEH=0)
+
+ # gtest use a lot of stuff marked as deprecated on Windows.
+ list(APPEND COMPILER_RT_GTEST_CFLAGS -Wno-deprecated-declarations)
+
+ # Visual Studio 2012 only supports up to 8 template parameters in
+ # std::tr1::tuple by default, but gtest requires 10
+ if(MSVC_VERSION EQUAL 1700)
+ list(APPEND COMPILER_RT_GTEST_CFLAGS -D_VARIADIC_MAX=10)
+ endif()
+endif()
+
+# Link objects into a single executable with COMPILER_RT_TEST_COMPILER,
+# using specified link flags. Make executable a part of provided
# test_suite.
# add_compiler_rt_test(<test_suite> <test_name>
# OBJECTS <object files>
@@ -126,20 +162,98 @@ set(COMPILER_RT_GTEST_INCLUDE_CFLAGS
macro(add_compiler_rt_test test_suite test_name)
parse_arguments(TEST "OBJECTS;DEPS;LINK_FLAGS" "" ${ARGN})
set(output_bin "${CMAKE_CURRENT_BINARY_DIR}/${test_name}")
+ # Use host compiler in a standalone build, and just-built Clang otherwise.
+ if(NOT COMPILER_RT_STANDALONE_BUILD)
+ list(APPEND TEST_DEPS clang)
+ endif()
+ # If we're not on MSVC, include the linker flags from CMAKE but override them
+ # with the provided link flags. This ensures that flags which are required to
+ # link programs at all are included, but the changes needed for the test
+ # trump. With MSVC we can't do that because CMake is set up to run link.exe
+ # when linking, not the compiler. Here, we hack it to use the compiler
+ # because we want to use -fsanitize flags.
+ if(NOT MSVC)
+ set(TEST_LINK_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${TEST_LINK_FLAGS}")
+ separate_arguments(TEST_LINK_FLAGS)
+ endif()
add_custom_target(${test_name}
- COMMAND clang ${TEST_OBJECTS} -o "${output_bin}"
+ COMMAND ${COMPILER_RT_TEST_COMPILER} ${TEST_OBJECTS}
+ -o "${output_bin}"
${TEST_LINK_FLAGS}
- DEPENDS clang ${TEST_DEPS})
+ DEPENDS ${TEST_DEPS})
# Make the test suite depend on the binary.
add_dependencies(${test_suite} ${test_name})
endmacro()
macro(add_compiler_rt_resource_file target_name file_name)
set(src_file "${CMAKE_CURRENT_SOURCE_DIR}/${file_name}")
- set(dst_file "${CLANG_RESOURCE_DIR}/${file_name}")
- add_custom_target(${target_name}
+ set(dst_file "${COMPILER_RT_OUTPUT_DIR}/${file_name}")
+ add_custom_command(OUTPUT ${dst_file}
+ DEPENDS ${src_file}
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${src_file} ${dst_file}
- DEPENDS ${file_name})
+ COMMENT "Copying ${file_name}...")
+ add_custom_target(${target_name} DEPENDS ${dst_file})
# Install in Clang resource directory.
- install(FILES ${file_name} DESTINATION ${LIBCLANG_INSTALL_PATH})
+ install(FILES ${file_name} DESTINATION ${COMPILER_RT_INSTALL_PATH})
+endmacro()
+
+macro(add_compiler_rt_script name)
+ set(dst ${COMPILER_RT_EXEC_OUTPUT_DIR}/${name})
+ set(src ${CMAKE_CURRENT_SOURCE_DIR}/${name})
+ add_custom_command(OUTPUT ${dst}
+ DEPENDS ${src}
+ COMMAND ${CMAKE_COMMAND} -E copy_if_different ${src} ${dst}
+ COMMENT "Copying ${name}...")
+ add_custom_target(${name} DEPENDS ${dst})
+ install(FILES ${dst}
+ PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
+ DESTINATION ${COMPILER_RT_INSTALL_PATH}/bin)
+endmacro(add_compiler_rt_script src name)
+
+# Builds custom version of libc++ and installs it in <prefix>.
+# Can be used to build sanitized versions of libc++ for running unit tests.
+# add_custom_libcxx(<name> <prefix>
+# DEPS <list of build deps>
+# CFLAGS <list of compile flags>)
+macro(add_custom_libcxx name prefix)
+ if(NOT COMPILER_RT_HAS_LIBCXX_SOURCES)
+ message(FATAL_ERROR "libcxx not found!")
+ endif()
+
+ parse_arguments(LIBCXX "DEPS;CFLAGS" "" ${ARGN})
+ foreach(flag ${LIBCXX_CFLAGS})
+ set(flagstr "${flagstr} ${flag}")
+ endforeach()
+ set(LIBCXX_CFLAGS ${flagstr})
+
+ if(NOT COMPILER_RT_STANDALONE_BUILD)
+ list(APPEND LIBCXX_DEPS clang)
+ endif()
+
+ ExternalProject_Add(${name}
+ PREFIX ${prefix}
+ SOURCE_DIR ${COMPILER_RT_LIBCXX_PATH}
+ CMAKE_ARGS -DCMAKE_C_COMPILER=${COMPILER_RT_TEST_COMPILER}
+ -DCMAKE_CXX_COMPILER=${COMPILER_RT_TEST_COMPILER}
+ -DCMAKE_C_FLAGS=${LIBCXX_CFLAGS}
+ -DCMAKE_CXX_FLAGS=${LIBCXX_CFLAGS}
+ -DCMAKE_BUILD_TYPE=Release
+ -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
+ LOG_BUILD 1
+ LOG_CONFIGURE 1
+ LOG_INSTALL 1
+ )
+
+ ExternalProject_Add_Step(${name} force-reconfigure
+ DEPENDERS configure
+ ALWAYS 1
+ )
+
+ ExternalProject_Add_Step(${name} clobber
+ COMMAND ${CMAKE_COMMAND} -E remove_directory <BINARY_DIR>
+ COMMAND ${CMAKE_COMMAND} -E make_directory <BINARY_DIR>
+ COMMENT "Clobberring ${name} build directory..."
+ DEPENDERS configure
+ DEPENDS ${LIBCXX_DEPS}
+ )
endmacro()
diff --git a/cmake/Modules/CompilerRTCompile.cmake b/cmake/Modules/CompilerRTCompile.cmake
index 2794cabe59c5..af3df8ff4f44 100644
--- a/cmake/Modules/CompilerRTCompile.cmake
+++ b/cmake/Modules/CompilerRTCompile.cmake
@@ -1,6 +1,6 @@
include(LLVMParseArguments)
-# Compile a source into an object file with just-built Clang using
+# Compile a source into an object file with COMPILER_RT_TEST_COMPILER using
# a provided compile flags and dependenices.
# clang_compile(<object> <source>
# CFLAGS <list of compile flags>
@@ -8,9 +8,74 @@ include(LLVMParseArguments)
macro(clang_compile object_file source)
parse_arguments(SOURCE "CFLAGS;DEPS" "" ${ARGN})
get_filename_component(source_rpath ${source} REALPATH)
+ if(NOT COMPILER_RT_STANDALONE_BUILD)
+ list(APPEND SOURCE_DEPS clang)
+ endif()
+ if (TARGET CompilerRTUnitTestCheckCxx)
+ list(APPEND SOURCE_DEPS CompilerRTUnitTestCheckCxx)
+ endif()
+ string(REGEX MATCH "[.](cc|cpp)$" is_cxx ${source_rpath})
+ if(is_cxx)
+ string(REPLACE " " ";" global_flags "${CMAKE_CXX_FLAGS}")
+ else()
+ string(REPLACE " " ";" global_flags "${CMAKE_C_FLAGS}")
+ endif()
+ # On Windows, CMAKE_*_FLAGS are built for MSVC but we use the GCC clang.exe
+ # which doesn't support flags starting with "/smth". Replace those with
+ # "-smth" equivalents.
+ if(MSVC)
+ string(REGEX REPLACE "^/" "-" global_flags "${global_flags}")
+ string(REPLACE ";/" ";-" global_flags "${global_flags}")
+ endif()
+ # Ignore unknown warnings. CMAKE_CXX_FLAGS may contain GCC-specific options
+ # which are not supported by Clang.
+ list(APPEND global_flags -Wno-unknown-warning-option)
+ set(compile_flags ${global_flags} ${SOURCE_CFLAGS})
add_custom_command(
OUTPUT ${object_file}
- COMMAND clang ${SOURCE_CFLAGS} -c -o "${object_file}" ${source_rpath}
+ COMMAND ${COMPILER_RT_TEST_COMPILER} ${compile_flags} -c
+ -o "${object_file}"
+ ${source_rpath}
MAIN_DEPENDENCY ${source}
- DEPENDS clang ${SOURCE_DEPS})
+ DEPENDS ${SOURCE_DEPS})
+endmacro()
+
+# On Darwin, there are no system-wide C++ headers and the just-built clang is
+# therefore not able to compile C++ files unless they are copied/symlinked into
+# ${LLVM_BINARY_DIR}/include/c++
+# The just-built clang is used to build compiler-rt unit tests. Let's detect
+# this before we try to build the tests and print out a suggestion how to fix
+# it.
+# On other platforms, this is currently not an issue.
+macro(clang_compiler_add_cxx_check)
+ if (APPLE)
+ set(CMD
+ "echo '#include <iostream>' | ${COMPILER_RT_TEST_COMPILER} -E -x c++ - > /dev/null"
+ "if [ $? != 0 ] "
+ " then echo"
+ " echo 'Your just-built clang cannot find C++ headers, which are needed to build and run compiler-rt tests.'"
+ " echo 'You should copy or symlink your system C++ headers into ${LLVM_BINARY_DIR}/include/c++'"
+ " if [ -d $(dirname $(dirname $(xcrun -f clang)))/include/c++ ]"
+ " then echo 'e.g. with:'"
+ " echo ' cp -r' $(dirname $(dirname $(xcrun -f clang)))/include/c++ '${LLVM_BINARY_DIR}/include/'"
+ " elif [ -d $(dirname $(dirname $(xcrun -f clang)))/lib/c++ ]"
+ " then echo 'e.g. with:'"
+ " echo ' cp -r' $(dirname $(dirname $(xcrun -f clang)))/lib/c++ '${LLVM_BINARY_DIR}/include/'"
+ " fi"
+ " echo 'This can also be fixed by checking out the libcxx project from llvm.org and installing the headers'"
+ " echo 'into your build directory:'"
+ " echo ' cd ${LLVM_SOURCE_DIR}/projects && svn co http://llvm.org/svn/llvm-project/libcxx/trunk libcxx'"
+ " echo ' cd ${LLVM_BINARY_DIR} && make -C ${LLVM_SOURCE_DIR}/projects/libcxx installheaders HEADER_DIR=${LLVM_BINARY_DIR}/include'"
+ " echo"
+ " false"
+ "fi"
+ )
+ add_custom_target(CompilerRTUnitTestCheckCxx
+ COMMAND bash -c "${CMD}"
+ COMMENT "Checking that just-built clang can find C++ headers..."
+ VERBATIM)
+ if (TARGET clang)
+ ADD_DEPENDENCIES(CompilerRTUnitTestCheckCxx clang)
+ endif()
+ endif()
endmacro()
diff --git a/cmake/Modules/CompilerRTLink.cmake b/cmake/Modules/CompilerRTLink.cmake
index 85030a725e19..0f0e53a3b2f4 100644
--- a/cmake/Modules/CompilerRTLink.cmake
+++ b/cmake/Modules/CompilerRTLink.cmake
@@ -1,14 +1,18 @@
include(LLVMParseArguments)
-# Link a shared library with just-built Clang.
+# Link a shared library with COMPILER_RT_TEST_COMPILER.
# clang_link_shared(<output.so>
# OBJECTS <list of input objects>
# LINKFLAGS <list of link flags>
# DEPS <list of dependencies>)
macro(clang_link_shared so_file)
parse_arguments(SOURCE "OBJECTS;LINKFLAGS;DEPS" "" ${ARGN})
+ if(NOT COMPILER_RT_STANDALONE_BUILD)
+ list(APPEND SOURCE_DEPS clang)
+ endif()
add_custom_command(
OUTPUT ${so_file}
- COMMAND clang -o "${so_file}" -shared ${SOURCE_LINKFLAGS} ${SOURCE_OBJECTS}
- DEPENDS clang ${SOURCE_DEPS})
+ COMMAND ${COMPILER_RT_TEST_COMPILER} -o "${so_file}" -shared
+ ${SOURCE_LINKFLAGS} ${SOURCE_OBJECTS}
+ DEPENDS ${SOURCE_DEPS})
endmacro()
diff --git a/cmake/Modules/CompilerRTUtils.cmake b/cmake/Modules/CompilerRTUtils.cmake
index fce37e3eb49a..ae59732928a1 100644
--- a/cmake/Modules/CompilerRTUtils.cmake
+++ b/cmake/Modules/CompilerRTUtils.cmake
@@ -2,6 +2,7 @@
# define a handy helper function for it. The compile flags setting in CMake
# has serious issues that make its syntax challenging at best.
function(set_target_compile_flags target)
+ set(argstring "")
foreach(arg ${ARGN})
set(argstring "${argstring} ${arg}")
endforeach()
@@ -9,24 +10,13 @@ function(set_target_compile_flags target)
endfunction()
function(set_target_link_flags target)
+ set(argstring "")
foreach(arg ${ARGN})
set(argstring "${argstring} ${arg}")
endforeach()
set_property(TARGET ${target} PROPERTY LINK_FLAGS "${argstring}")
endfunction()
-# Check if a given flag is present in a space-separated flag_string.
-# Store the result in out_var.
-function(find_flag_in_string flag_string flag out_var)
- string(REPLACE " " ";" flag_list ${flag_string})
- list(FIND flag_list ${flag} flag_pos)
- if(NOT flag_pos EQUAL -1)
- set(${out_var} TRUE PARENT_SCOPE)
- else()
- set(${out_var} FALSE PARENT_SCOPE)
- endif()
-endfunction()
-
# Set the variable var_PYBOOL to True if var holds a true-ish string,
# otherwise set it to False.
macro(pythonize_bool var)
@@ -36,3 +26,26 @@ macro(pythonize_bool var)
set(${var}_PYBOOL False)
endif()
endmacro()
+
+# Appends value to all lists in ARGN, if the condition is true.
+macro(append_list_if condition value)
+ if(${condition})
+ foreach(list ${ARGN})
+ list(APPEND ${list} ${value})
+ endforeach()
+ endif()
+endmacro()
+
+# Appends value to all strings in ARGN, if the condition is true.
+macro(append_string_if condition value)
+ if(${condition})
+ foreach(str ${ARGN})
+ set(${str} "${${str}} ${value}")
+ endforeach()
+ endif()
+endmacro()
+
+macro(append_no_rtti_flag list)
+ append_list_if(COMPILER_RT_HAS_FNO_RTTI_FLAG -fno-rtti ${list})
+ append_list_if(COMPILER_RT_HAS_GR_FLAG /GR- ${list})
+endmacro()
diff --git a/cmake/Modules/SanitizerUtils.cmake b/cmake/Modules/SanitizerUtils.cmake
index 0836edee2644..1ebc7030a57b 100644
--- a/cmake/Modules/SanitizerUtils.cmake
+++ b/cmake/Modules/SanitizerUtils.cmake
@@ -12,21 +12,36 @@ set(SANITIZER_LINT_SCRIPT
# symbol names that should be exported as well.
# add_sanitizer_rt_symbols(<name> <files with extra symbols to export>)
macro(add_sanitizer_rt_symbols name)
- get_target_property(libfile ${name} LOCATION)
- set(symsfile "${libfile}.syms")
- add_custom_command(OUTPUT ${symsfile}
+ set(stamp ${CMAKE_CURRENT_BINARY_DIR}/${name}.syms-stamp)
+ add_custom_command(OUTPUT ${stamp}
COMMAND ${PYTHON_EXECUTABLE}
- ${SANITIZER_GEN_DYNAMIC_LIST} ${libfile} ${ARGN}
- > ${symsfile}
+ ${SANITIZER_GEN_DYNAMIC_LIST} $<TARGET_FILE:${name}> ${ARGN}
+ > $<TARGET_FILE:${name}>.syms
+ COMMAND ${CMAKE_COMMAND} -E touch ${stamp}
DEPENDS ${name} ${SANITIZER_GEN_DYNAMIC_LIST} ${ARGN}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMENT "Generating exported symbols for ${name}"
VERBATIM)
add_custom_target(${name}-symbols ALL
- DEPENDS ${symsfile}
+ DEPENDS ${stamp}
SOURCES ${SANITIZER_GEN_DYNAMIC_LIST} ${ARGN})
- install(FILES ${symsfile} DESTINATION ${COMPILER_RT_LIBRARY_INSTALL_DIR})
- add_dependencies(compiler-rt ${name}-symbols)
+
+ if(NOT CMAKE_VERSION VERSION_LESS 3.0)
+ install(FILES $<TARGET_FILE:${name}>.syms
+ DESTINATION ${COMPILER_RT_LIBRARY_INSTALL_DIR})
+ else()
+ # Per-config install location.
+ if(CMAKE_CONFIGURATION_TYPES)
+ foreach(c ${CMAKE_CONFIGURATION_TYPES})
+ get_target_property(libfile ${name} LOCATION_${c})
+ install(FILES ${libfile}.syms CONFIGURATIONS ${c}
+ DESTINATION ${COMPILER_RT_LIBRARY_INSTALL_DIR})
+ endforeach()
+ else()
+ get_target_property(libfile ${name} LOCATION_${CMAKE_BUILD_TYPE})
+ install(FILES ${libfile}.syms DESTINATION ${COMPILER_RT_LIBRARY_INSTALL_DIR})
+ endif()
+ endif()
endmacro()
# Add target to check code style for sanitizer runtimes.
@@ -34,6 +49,7 @@ if(UNIX)
add_custom_target(SanitizerLintCheck
COMMAND LLVM_CHECKOUT=${LLVM_MAIN_SRC_DIR} SILENT=1 TMPDIR=
PYTHON_EXECUTABLE=${PYTHON_EXECUTABLE}
+ COMPILER_RT=${COMPILER_RT_SOURCE_DIR}
${SANITIZER_LINT_SCRIPT}
DEPENDS ${SANITIZER_LINT_SCRIPT}
COMMENT "Running lint check for sanitizer sources..."