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