aboutsummaryrefslogtreecommitdiff
path: root/cmake/Modules/SanitizerUtils.cmake
diff options
context:
space:
mode:
Diffstat (limited to 'cmake/Modules/SanitizerUtils.cmake')
-rw-r--r--cmake/Modules/SanitizerUtils.cmake82
1 files changed, 48 insertions, 34 deletions
diff --git a/cmake/Modules/SanitizerUtils.cmake b/cmake/Modules/SanitizerUtils.cmake
index c040b42122ce..3eb49c83f51c 100644
--- a/cmake/Modules/SanitizerUtils.cmake
+++ b/cmake/Modules/SanitizerUtils.cmake
@@ -4,46 +4,60 @@ set(SANITIZER_GEN_DYNAMIC_LIST
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
+# Create a target "<name>-<arch>-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>)
+# add_sanitizer_rt_symbols(<name>
+# ARCHS <architectures>
+# PARENT_TARGET <convenience parent target>
+# EXTRA <files with extra symbols to export>)
macro(add_sanitizer_rt_symbols name)
- set(stamp ${CMAKE_CURRENT_BINARY_DIR}/${name}.syms-stamp)
- set(extra_args)
- foreach(arg ${ARGN})
- list(APPEND extra_args "--extra" ${arg})
- endforeach()
- add_custom_command(OUTPUT ${stamp}
- COMMAND ${PYTHON_EXECUTABLE}
- ${SANITIZER_GEN_DYNAMIC_LIST} ${extra_args} $<TARGET_FILE:${name}>
- > $<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 ${stamp}
- SOURCES ${SANITIZER_GEN_DYNAMIC_LIST} ${ARGN})
+ cmake_parse_arguments(ARG
+ ""
+ "PARENT_TARGET"
+ "ARCHS;EXTRA"
+ ${ARGN})
+ foreach(arch ${ARG_ARCHS})
+ set(target_name ${name}-${arch})
+ set(stamp ${CMAKE_CURRENT_BINARY_DIR}/${target_name}.syms-stamp)
+ set(extra_args)
+ foreach(arg ${ARG_EXTRA})
+ list(APPEND extra_args "--extra" ${arg})
+ endforeach()
+ add_custom_command(OUTPUT ${stamp}
+ COMMAND ${PYTHON_EXECUTABLE}
+ ${SANITIZER_GEN_DYNAMIC_LIST} ${extra_args} $<TARGET_FILE:${target_name}>
+ > $<TARGET_FILE:${target_name}>.syms
+ COMMAND ${CMAKE_COMMAND} -E touch ${stamp}
+ DEPENDS ${target_name} ${SANITIZER_GEN_DYNAMIC_LIST} ${ARG_EXTRA}
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+ COMMENT "Generating exported symbols for ${target_name}"
+ VERBATIM)
+ add_custom_target(${target_name}-symbols ALL
+ DEPENDS ${stamp}
+ SOURCES ${SANITIZER_GEN_DYNAMIC_LIST} ${ARG_EXTRA})
- 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()
+ if(NOT CMAKE_VERSION VERSION_LESS 3.0)
+ install(FILES $<TARGET_FILE:${target_name}>.syms
+ DESTINATION ${COMPILER_RT_LIBRARY_INSTALL_DIR})
else()
- get_target_property(libfile ${name} LOCATION_${CMAKE_BUILD_TYPE})
- install(FILES ${libfile}.syms DESTINATION ${COMPILER_RT_LIBRARY_INSTALL_DIR})
+ # Per-config install location.
+ if(CMAKE_CONFIGURATION_TYPES)
+ foreach(c ${CMAKE_CONFIGURATION_TYPES})
+ get_target_property(libfile ${target_name} LOCATION_${c})
+ install(FILES ${libfile}.syms CONFIGURATIONS ${c}
+ DESTINATION ${COMPILER_RT_LIBRARY_INSTALL_DIR})
+ endforeach()
+ else()
+ get_target_property(libfile ${target_name} LOCATION_${CMAKE_BUILD_TYPE})
+ install(FILES ${libfile}.syms DESTINATION ${COMPILER_RT_LIBRARY_INSTALL_DIR})
+ endif()
endif()
- endif()
+ if(ARG_PARENT_TARGET)
+ add_dependencies(${ARG_PARENT_TARGET} ${target_name}-symbols)
+ endif()
+ endforeach()
endmacro()
macro(add_sanitizer_rt_version_list name)