aboutsummaryrefslogtreecommitdiff
path: root/cmake/Modules
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2014-11-06 22:49:13 +0000
committerDimitry Andric <dim@FreeBSD.org>2014-11-06 22:49:13 +0000
commit8ef50bf3d1c287b5013c3168de77a462dfce3495 (patch)
tree3467f3372c1195b1546172d89af2205a50b1866d /cmake/Modules
parent11023dc647fd8f41418da90d59db138400d0f334 (diff)
downloadsrc-8ef50bf3d1c287b5013c3168de77a462dfce3495.tar.gz
src-8ef50bf3d1c287b5013c3168de77a462dfce3495.zip
Import compiler-rt release_34 branch r197381.vendor/compiler-rt/compiler-rt-r197381
Notes
Notes: svn path=/vendor/compiler-rt/dist/; revision=274201 svn path=/vendor/compiler-rt/compiler-rt-r197381/; revision=274202; tag=vendor/compiler-rt/compiler-rt-r197381
Diffstat (limited to 'cmake/Modules')
-rw-r--r--cmake/Modules/AddCompilerRT.cmake66
-rw-r--r--cmake/Modules/CompilerRTUtils.cmake10
-rw-r--r--cmake/Modules/SanitizerUtils.cmake42
3 files changed, 87 insertions, 31 deletions
diff --git a/cmake/Modules/AddCompilerRT.cmake b/cmake/Modules/AddCompilerRT.cmake
index bf114a401ef0..fd117ac522ca 100644
--- a/cmake/Modules/AddCompilerRT.cmake
+++ b/cmake/Modules/AddCompilerRT.cmake
@@ -6,29 +6,35 @@ include(CompilerRTUtils)
# with name "<name>.<arch>" if architecture can be targeted.
# add_compiler_rt_object_library(<name> <arch>
# SOURCES <source files>
-# CFLAGS <compile flags>)
+# CFLAGS <compile flags>
+# DEFS <compile definitions>)
macro(add_compiler_rt_object_library name arch)
if(CAN_TARGET_${arch})
- parse_arguments(LIB "SOURCES;CFLAGS" "" ${ARGN})
+ 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})
+ set_property(TARGET ${name}.${arch} APPEND PROPERTY
+ COMPILE_DEFINITIONS ${LIB_DEFS})
else()
message(FATAL_ERROR "Archtecture ${arch} can't be targeted")
endif()
endmacro()
-# Same as above, but adds universal osx library with name "<name>.osx"
-# targeting multiple architectures.
-# add_compiler_rt_osx_object_library(<name> ARCH <architectures>
-# SOURCES <source files>
-# CFLAGS <compile flags>)
-macro(add_compiler_rt_osx_object_library name)
- parse_arguments(LIB "ARCH;SOURCES;CFLAGS" "" ${ARGN})
- set(libname "${name}.osx")
+# Same as above, but adds universal osx library for either OSX or iOS simulator
+# with name "<name>.<os>" targeting multiple architectures.
+# add_compiler_rt_darwin_object_library(<name> <os> ARCH <architectures>
+# SOURCES <source files>
+# CFLAGS <compile flags>
+# DEFS <compile definitions>)
+macro(add_compiler_rt_darwin_object_library name os)
+ parse_arguments(LIB "ARCH;SOURCES;CFLAGS;DEFS" "" ${ARGN})
+ set(libname "${name}.${os}")
add_library(${libname} OBJECT ${LIB_SOURCES})
- set_target_compile_flags(${libname} ${LIB_CFLAGS})
+ set_target_compile_flags(${libname} ${LIB_CFLAGS} ${DARWIN_${os}_CFLAGS})
set_target_properties(${libname} PROPERTIES OSX_ARCHITECTURES "${LIB_ARCH}")
+ set_property(TARGET ${libname} APPEND PROPERTY
+ COMPILE_DEFINITIONS ${LIB_DEFS})
endmacro()
# Adds static runtime for a given architecture and puts it in the proper
@@ -36,11 +42,10 @@ endmacro()
# add_compiler_rt_static_runtime(<name> <arch>
# SOURCES <source files>
# CFLAGS <compile flags>
-# DEFS <compile definitions>
-# SYMS <symbols file>)
+# DEFS <compile definitions>)
macro(add_compiler_rt_static_runtime name arch)
if(CAN_TARGET_${arch})
- parse_arguments(LIB "SOURCES;CFLAGS;DEFS;SYMS" "" ${ARGN})
+ parse_arguments(LIB "SOURCES;CFLAGS;DEFS" "" ${ARGN})
add_library(${name} STATIC ${LIB_SOURCES})
# Setup compile flags and definitions.
set_target_compile_flags(${name}
@@ -53,13 +58,7 @@ macro(add_compiler_rt_static_runtime name arch)
# Add installation command.
install(TARGETS ${name}
ARCHIVE DESTINATION ${COMPILER_RT_LIBRARY_INSTALL_DIR})
- # Generate the .syms file if possible.
- if(LIB_SYMS)
- get_target_property(libfile ${name} LOCATION)
- configure_file(${LIB_SYMS} ${libfile}.syms)
- install(FILES ${libfile}.syms
- DESTINATION ${COMPILER_RT_LIBRARY_INSTALL_DIR})
- endif(LIB_SYMS)
+ add_dependencies(compiler-rt ${name})
else()
message(FATAL_ERROR "Archtecture ${arch} can't be targeted")
endif()
@@ -82,19 +81,22 @@ 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, which supports multiple architectures.
-# add_compiler_rt_osx_dynamic_runtime(<name> ARCH <architectures>
-# SOURCES <source files>
-# CFLAGS <compile flags>
-# DEFS <compile definitions>
-# LINKFLAGS <link flags>)
-macro(add_compiler_rt_osx_dynamic_runtime name)
+# Adds dynamic runtime library on osx/iossim, which supports multiple
+# architectures.
+# add_compiler_rt_darwin_dynamic_runtime(<name> <os>
+# ARCH <architectures>
+# SOURCES <source files>
+# CFLAGS <compile flags>
+# DEFS <compile definitions>
+# LINKFLAGS <link flags>)
+macro(add_compiler_rt_darwin_dynamic_runtime name os)
parse_arguments(LIB "ARCH;SOURCES;CFLAGS;DEFS;LINKFLAGS" "" ${ARGN})
add_library(${name} SHARED ${LIB_SOURCES})
- set_target_compile_flags(${name} ${LIB_CFLAGS})
- set_target_link_flags(${name} ${LIB_LINKFLAGS})
+ set_target_compile_flags(${name} ${LIB_CFLAGS} ${DARWIN_${os}_CFLAGS})
+ set_target_link_flags(${name} ${LIB_LINKFLAGS} ${DARWIN_${os}_LINKFLAGS})
set_property(TARGET ${name} APPEND PROPERTY
COMPILE_DEFINITIONS ${LIB_DEFS})
set_target_properties(${name} PROPERTIES
@@ -102,14 +104,16 @@ macro(add_compiler_rt_osx_dynamic_runtime name)
LIBRARY_OUTPUT_DIRECTORY ${COMPILER_RT_LIBRARY_OUTPUT_DIR})
install(TARGETS ${name}
LIBRARY DESTINATION ${COMPILER_RT_LIBRARY_INSTALL_DIR})
+ add_dependencies(compiler-rt ${name})
endmacro()
# Unittests support.
set(COMPILER_RT_GTEST_PATH ${LLVM_MAIN_SRC_DIR}/utils/unittest/googletest)
-set(COMPILER_RT_GTEST_SOURCE ${COMPILER_RT_GTEST_PATH}/gtest-all.cc)
+set(COMPILER_RT_GTEST_SOURCE ${COMPILER_RT_GTEST_PATH}/src/gtest-all.cc)
set(COMPILER_RT_GTEST_INCLUDE_CFLAGS
-DGTEST_NO_LLVM_RAW_OSTREAM=1
-I${COMPILER_RT_GTEST_PATH}/include
+ -I${COMPILER_RT_GTEST_PATH}
)
# Use Clang to link objects into a single executable with just-built
diff --git a/cmake/Modules/CompilerRTUtils.cmake b/cmake/Modules/CompilerRTUtils.cmake
index f9760f40dbd5..fce37e3eb49a 100644
--- a/cmake/Modules/CompilerRTUtils.cmake
+++ b/cmake/Modules/CompilerRTUtils.cmake
@@ -26,3 +26,13 @@ function(find_flag_in_string flag_string flag out_var)
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)
+ if (${var})
+ set(${var}_PYBOOL True)
+ else()
+ set(${var}_PYBOOL False)
+ endif()
+endmacro()
diff --git a/cmake/Modules/SanitizerUtils.cmake b/cmake/Modules/SanitizerUtils.cmake
new file mode 100644
index 000000000000..0836edee2644
--- /dev/null
+++ b/cmake/Modules/SanitizerUtils.cmake
@@ -0,0 +1,42 @@
+include(LLVMParseArguments)
+
+set(SANITIZER_GEN_DYNAMIC_LIST
+ ${COMPILER_RT_SOURCE_DIR}/lib/sanitizer_common/scripts/gen_dynamic_list.py)
+
+set(SANITIZER_LINT_SCRIPT
+ ${COMPILER_RT_SOURCE_DIR}/lib/sanitizer_common/scripts/check_lint.sh)
+
+# Create a target "<name>-symbols" that would generate the list of symbols
+# that need to be exported from sanitizer runtime "<name>". Function
+# interceptors are exported automatically, user can also provide files with
+# 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}
+ COMMAND ${PYTHON_EXECUTABLE}
+ ${SANITIZER_GEN_DYNAMIC_LIST} ${libfile} ${ARGN}
+ > ${symsfile}
+ 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}
+ SOURCES ${SANITIZER_GEN_DYNAMIC_LIST} ${ARGN})
+ install(FILES ${symsfile} DESTINATION ${COMPILER_RT_LIBRARY_INSTALL_DIR})
+ add_dependencies(compiler-rt ${name}-symbols)
+endmacro()
+
+# Add target to check code style for sanitizer runtimes.
+if(UNIX)
+ add_custom_target(SanitizerLintCheck
+ COMMAND LLVM_CHECKOUT=${LLVM_MAIN_SRC_DIR} SILENT=1 TMPDIR=
+ PYTHON_EXECUTABLE=${PYTHON_EXECUTABLE}
+ ${SANITIZER_LINT_SCRIPT}
+ DEPENDS ${SANITIZER_LINT_SCRIPT}
+ COMMENT "Running lint check for sanitizer sources..."
+ VERBATIM)
+endif()
+