Alexey Samsonov | e5fa243 | 2013-08-27 15:08:02 +0000 | [diff] [blame] | 1 | include(LLVMParseArguments) |
| 2 | |
| 3 | set(SANITIZER_GEN_DYNAMIC_LIST |
| 4 | ${COMPILER_RT_SOURCE_DIR}/lib/sanitizer_common/scripts/gen_dynamic_list.py) |
| 5 | |
Alexey Samsonov | 38a61aa | 2013-08-29 10:49:04 +0000 | [diff] [blame] | 6 | set(SANITIZER_LINT_SCRIPT |
| 7 | ${COMPILER_RT_SOURCE_DIR}/lib/sanitizer_common/scripts/check_lint.sh) |
| 8 | |
Alexey Samsonov | e5fa243 | 2013-08-27 15:08:02 +0000 | [diff] [blame] | 9 | # Create a target "<name>-symbols" that would generate the list of symbols |
| 10 | # that need to be exported from sanitizer runtime "<name>". Function |
| 11 | # interceptors are exported automatically, user can also provide files with |
| 12 | # symbol names that should be exported as well. |
| 13 | # add_sanitizer_rt_symbols(<name> <files with extra symbols to export>) |
| 14 | macro(add_sanitizer_rt_symbols name) |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 15 | set(stamp ${CMAKE_CURRENT_BINARY_DIR}/${name}.syms-stamp) |
Pirama Arumuga Nainar | cdce50b | 2015-07-01 12:26:56 -0700 | [diff] [blame] | 16 | set(extra_args) |
| 17 | foreach(arg ${ARGN}) |
| 18 | list(APPEND extra_args "--extra" ${arg}) |
| 19 | endforeach() |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 20 | add_custom_command(OUTPUT ${stamp} |
Will Dietz | 1de4060 | 2013-08-28 15:53:17 +0000 | [diff] [blame] | 21 | COMMAND ${PYTHON_EXECUTABLE} |
Pirama Arumuga Nainar | cdce50b | 2015-07-01 12:26:56 -0700 | [diff] [blame] | 22 | ${SANITIZER_GEN_DYNAMIC_LIST} ${extra_args} $<TARGET_FILE:${name}> |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 23 | > $<TARGET_FILE:${name}>.syms |
| 24 | COMMAND ${CMAKE_COMMAND} -E touch ${stamp} |
Alexey Samsonov | e5fa243 | 2013-08-27 15:08:02 +0000 | [diff] [blame] | 25 | DEPENDS ${name} ${SANITIZER_GEN_DYNAMIC_LIST} ${ARGN} |
| 26 | WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} |
Alexey Samsonov | 38a61aa | 2013-08-29 10:49:04 +0000 | [diff] [blame] | 27 | COMMENT "Generating exported symbols for ${name}" |
| 28 | VERBATIM) |
| 29 | add_custom_target(${name}-symbols ALL |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 30 | DEPENDS ${stamp} |
Alexey Samsonov | e5fa243 | 2013-08-27 15:08:02 +0000 | [diff] [blame] | 31 | SOURCES ${SANITIZER_GEN_DYNAMIC_LIST} ${ARGN}) |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 32 | |
| 33 | if(NOT CMAKE_VERSION VERSION_LESS 3.0) |
| 34 | install(FILES $<TARGET_FILE:${name}>.syms |
| 35 | DESTINATION ${COMPILER_RT_LIBRARY_INSTALL_DIR}) |
| 36 | else() |
| 37 | # Per-config install location. |
| 38 | if(CMAKE_CONFIGURATION_TYPES) |
| 39 | foreach(c ${CMAKE_CONFIGURATION_TYPES}) |
| 40 | get_target_property(libfile ${name} LOCATION_${c}) |
| 41 | install(FILES ${libfile}.syms CONFIGURATIONS ${c} |
| 42 | DESTINATION ${COMPILER_RT_LIBRARY_INSTALL_DIR}) |
| 43 | endforeach() |
| 44 | else() |
| 45 | get_target_property(libfile ${name} LOCATION_${CMAKE_BUILD_TYPE}) |
| 46 | install(FILES ${libfile}.syms DESTINATION ${COMPILER_RT_LIBRARY_INSTALL_DIR}) |
| 47 | endif() |
| 48 | endif() |
Alexey Samsonov | e5fa243 | 2013-08-27 15:08:02 +0000 | [diff] [blame] | 49 | endmacro() |
Alexey Samsonov | 38a61aa | 2013-08-29 10:49:04 +0000 | [diff] [blame] | 50 | |
Pirama Arumuga Nainar | cdce50b | 2015-07-01 12:26:56 -0700 | [diff] [blame] | 51 | macro(add_sanitizer_rt_version_list name) |
| 52 | set(vers ${CMAKE_CURRENT_BINARY_DIR}/${name}.vers) |
| 53 | parse_arguments(ARG "LIB;EXTRA" "" ${ARGN}) |
| 54 | set(args) |
| 55 | foreach(arg ${ARG_EXTRA}) |
| 56 | list(APPEND args "--extra" ${arg}) |
| 57 | endforeach() |
| 58 | foreach(arg ${ARG_LIB}) |
| 59 | list(APPEND args "$<TARGET_FILE:${arg}>") |
| 60 | endforeach() |
| 61 | add_custom_command(OUTPUT ${vers} |
| 62 | COMMAND ${PYTHON_EXECUTABLE} |
| 63 | ${SANITIZER_GEN_DYNAMIC_LIST} --version-list ${args} |
| 64 | > ${vers} |
| 65 | DEPENDS ${SANITIZER_GEN_DYNAMIC_LIST} ${ARG_EXTRA} ${ARG_LIB} |
| 66 | WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} |
| 67 | COMMENT "Generating version list for ${name}" |
| 68 | VERBATIM) |
| 69 | |
| 70 | add_custom_target(${name}-version-list ALL |
| 71 | DEPENDS ${vers}) |
| 72 | endmacro() |
| 73 | |
Alexey Samsonov | 38a61aa | 2013-08-29 10:49:04 +0000 | [diff] [blame] | 74 | # Add target to check code style for sanitizer runtimes. |
| 75 | if(UNIX) |
| 76 | add_custom_target(SanitizerLintCheck |
| 77 | COMMAND LLVM_CHECKOUT=${LLVM_MAIN_SRC_DIR} SILENT=1 TMPDIR= |
| 78 | PYTHON_EXECUTABLE=${PYTHON_EXECUTABLE} |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 79 | COMPILER_RT=${COMPILER_RT_SOURCE_DIR} |
Alexey Samsonov | 38a61aa | 2013-08-29 10:49:04 +0000 | [diff] [blame] | 80 | ${SANITIZER_LINT_SCRIPT} |
| 81 | DEPENDS ${SANITIZER_LINT_SCRIPT} |
| 82 | COMMENT "Running lint check for sanitizer sources..." |
| 83 | VERBATIM) |
| 84 | endif() |
| 85 | |