1set(SANITIZER_GEN_DYNAMIC_LIST 2 ${COMPILER_RT_SOURCE_DIR}/lib/sanitizer_common/scripts/gen_dynamic_list.py) 3 4set(SANITIZER_LINT_SCRIPT 5 ${COMPILER_RT_SOURCE_DIR}/lib/sanitizer_common/scripts/check_lint.sh) 6 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 9# interceptors are exported automatically, user can also provide files with 10# symbol names that should be exported as well. 11# add_sanitizer_rt_symbols(<name> 12# ARCHS <architectures> 13# PARENT_TARGET <convenience parent target> 14# EXTRA <files with extra symbols to export>) 15macro(add_sanitizer_rt_symbols name) 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}) 40 41 install(FILES $<TARGET_FILE:${target_name}>.syms 42 DESTINATION ${COMPILER_RT_LIBRARY_INSTALL_DIR}) 43 if(ARG_PARENT_TARGET) 44 add_dependencies(${ARG_PARENT_TARGET} ${target_name}-symbols) 45 endif() 46 endforeach() 47endmacro() 48 49macro(add_sanitizer_rt_version_list name) 50 set(vers ${CMAKE_CURRENT_BINARY_DIR}/${name}.vers) 51 cmake_parse_arguments(ARG "" "" "LIBS;EXTRA" ${ARGN}) 52 set(args) 53 foreach(arg ${ARG_EXTRA}) 54 list(APPEND args "--extra" ${arg}) 55 endforeach() 56 foreach(arg ${ARG_LIBS}) 57 list(APPEND args "$<TARGET_FILE:${arg}>") 58 endforeach() 59 add_custom_command(OUTPUT ${vers} 60 COMMAND ${PYTHON_EXECUTABLE} 61 ${SANITIZER_GEN_DYNAMIC_LIST} --version-list ${args} 62 > ${vers} 63 DEPENDS ${SANITIZER_GEN_DYNAMIC_LIST} ${ARG_EXTRA} ${ARG_LIBS} 64 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} 65 COMMENT "Generating version list for ${name}" 66 VERBATIM) 67 68 add_custom_target(${name}-version-list ALL 69 DEPENDS ${vers}) 70endmacro() 71 72# Add target to check code style for sanitizer runtimes. 73if(CMAKE_HOST_UNIX) 74 add_custom_target(SanitizerLintCheck 75 COMMAND env LLVM_CHECKOUT=${LLVM_MAIN_SRC_DIR} SILENT=1 TMPDIR= 76 PYTHON_EXECUTABLE=${PYTHON_EXECUTABLE} 77 COMPILER_RT=${COMPILER_RT_SOURCE_DIR} 78 ${SANITIZER_LINT_SCRIPT} 79 DEPENDS ${SANITIZER_LINT_SCRIPT} 80 COMMENT "Running lint check for sanitizer sources..." 81 VERBATIM) 82endif() 83 84