[PATCH] D12106: [CMake] Refactoring add_compiler_rt functions for darwin runtimes.
Justin Bogner via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 18 10:29:17 PDT 2015
Chris Bieneman <beanz at apple.com> writes:
> beanz created this revision.
> beanz added reviewers: filcab, samsonov, bogner.
> beanz added a subscriber: llvm-commits.
>
> This patch consolidates add_compiler_rt_osx_static_runtime and
> add_compiler_rt_darwin_dynamic_runtime into a single new function
> add_compiler_rt_darwin_runtime.
LGTM. This sort of obvious refactoring is probably fine for post-commit
review.
> http://reviews.llvm.org/D12106
>
> Files:
> cmake/Modules/AddCompilerRT.cmake
> lib/asan/CMakeLists.txt
> lib/profile/CMakeLists.txt
> lib/safestack/CMakeLists.txt
> lib/ubsan/CMakeLists.txt
>
> Index: lib/ubsan/CMakeLists.txt
> ===================================================================
> --- lib/ubsan/CMakeLists.txt
> +++ lib/ubsan/CMakeLists.txt
> @@ -50,7 +50,8 @@
> SOURCES ${UBSAN_STANDALONE_SOURCES}
> CFLAGS ${UBSAN_STANDALONE_CFLAGS})
> foreach(os ${SANITIZER_COMMON_SUPPORTED_OS})
> - add_compiler_rt_darwin_dynamic_runtime(clang_rt.ubsan_${os}_dynamic ${os}
> + add_compiler_rt_darwin_runtime(clang_rt.ubsan_${os}_dynamic ${os}
> + SHARED
> ARCHS ${UBSAN_SUPPORTED_ARCH}
> SOURCES $<TARGET_OBJECTS:RTUbsan.${os}>
> $<TARGET_OBJECTS:RTUbsan_standalone.${os}>
> Index: lib/safestack/CMakeLists.txt
> ===================================================================
> --- lib/safestack/CMakeLists.txt
> +++ lib/safestack/CMakeLists.txt
> @@ -8,13 +8,16 @@
>
> if(APPLE)
> # Build universal binary on APPLE.
> - add_compiler_rt_osx_static_runtime(clang_rt.safestack_osx
> - ARCH ${SAFESTACK_SUPPORTED_ARCH}
> - SOURCES ${SAFESTACK_SOURCES}
> - $<TARGET_OBJECTS:RTInterception.osx>
> - $<TARGET_OBJECTS:RTSanitizerCommon.osx>
> - CFLAGS ${SAFESTACK_CFLAGS})
> - add_dependencies(safestack clang_rt.safestack_osx)
> + foreach (os ${SANITIZER_COMMON_SUPPORTED_OS})
> + add_compiler_rt_darwin_runtime(clang_rt.safestack_${os} ${os}
> + STATIC
> + ARCH ${SAFESTACK_SUPPORTED_ARCH}
> + SOURCES ${SAFESTACK_SOURCES}
> + $<TARGET_OBJECTS:RTInterception.${os}>
> + $<TARGET_OBJECTS:RTSanitizerCommon.${os}>
> + CFLAGS ${SAFESTACK_CFLAGS})
> + add_dependencies(safestack clang_rt.safestack_${os})
> + endforeach()
> else()
> # Otherwise, build separate libraries for each target.
> foreach(arch ${SAFESTACK_SUPPORTED_ARCH})
> Index: lib/profile/CMakeLists.txt
> ===================================================================
> --- lib/profile/CMakeLists.txt
> +++ lib/profile/CMakeLists.txt
> @@ -11,10 +11,13 @@
> InstrProfilingUtil.c)
>
> if(APPLE)
> - add_compiler_rt_osx_static_runtime(clang_rt.profile_osx
> - ARCHS ${PROFILE_SUPPORTED_ARCH}
> - SOURCES ${PROFILE_SOURCES})
> - add_dependencies(profile clang_rt.profile_osx)
> + foreach (os ${SANITIZER_COMMON_SUPPORTED_OS})
> + add_compiler_rt_darwin_runtime(clang_rt.profile_${os} ${os}
> + STATIC
> + ARCHS ${PROFILE_SUPPORTED_ARCH}
> + SOURCES ${PROFILE_SOURCES})
> + add_dependencies(profile clang_rt.profile_${os})
> + endforeach()
> else()
> foreach(arch ${PROFILE_SUPPORTED_ARCH})
> add_compiler_rt_runtime(clang_rt.profile-${arch} ${arch} STATIC
> Index: lib/asan/CMakeLists.txt
> ===================================================================
> --- lib/asan/CMakeLists.txt
> +++ lib/asan/CMakeLists.txt
> @@ -111,7 +111,8 @@
> add_custom_target(asan)
> if(APPLE)
> foreach (os ${SANITIZER_COMMON_SUPPORTED_OS})
> - add_compiler_rt_darwin_dynamic_runtime(clang_rt.asan_${os}_dynamic ${os}
> + add_compiler_rt_darwin_runtime(clang_rt.asan_${os}_dynamic ${os}
> + SHARED
> ARCHS ${ASAN_SUPPORTED_ARCH}
> SOURCES $<TARGET_OBJECTS:RTAsan.${os}>
> $<TARGET_OBJECTS:RTInterception.${os}>
> Index: cmake/Modules/AddCompilerRT.cmake
> ===================================================================
> --- cmake/Modules/AddCompilerRT.cmake
> +++ cmake/Modules/AddCompilerRT.cmake
> @@ -86,47 +86,45 @@
> endif()
> endmacro()
>
> -# Same as add_compiler_rt_runtime(... STATIC), but creates a universal library
> -# for several architectures.
> -# add_compiler_rt_osx_static_runtime(<name> ARCHS <architectures>
> -# SOURCES <source files>
> -# CFLAGS <compile flags>
> -# DEFS <compile definitions>)
> -macro(add_compiler_rt_osx_static_runtime name)
> - cmake_parse_arguments(LIB "" "" "ARCHS;SOURCES;CFLAGS;DEFS" ${ARGN})
> - add_library(${name} STATIC ${LIB_SOURCES})
> - set_target_compile_flags(${name} ${LIB_CFLAGS})
> - set_property(TARGET ${name} APPEND PROPERTY
> - COMPILE_DEFINITIONS ${LIB_DEFS})
> - set_target_properties(${name} PROPERTIES
> - OSX_ARCHITECTURES "${LIB_ARCHS}"
> - ARCHIVE_OUTPUT_DIRECTORY ${COMPILER_RT_LIBRARY_OUTPUT_DIR})
> - install(TARGETS ${name}
> - ARCHIVE DESTINATION ${COMPILER_RT_LIBRARY_INSTALL_DIR})
> -endmacro()
> -
> -# Adds dynamic runtime library on osx/iossim, which supports multiple
> +# Adds runtime library for darwin platforms, which supports multiple
> # architectures.
> -# add_compiler_rt_darwin_dynamic_runtime(<name> <os>
> -# ARCHS <architectures>
> -# SOURCES <source files>
> -# CFLAGS <compile flags>
> -# DEFS <compile definitions>
> -# LINKFLAGS <link flags>)
> -macro(add_compiler_rt_darwin_dynamic_runtime name os)
> - cmake_parse_arguments(LIB "" "" "ARCHS;SOURCES;CFLAGS;DEFS;LINKFLAGS" ${ARGN})
> - add_library(${name} SHARED ${LIB_SOURCES})
> - 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})
> +# add_compiler_rt_darwin_runtime(<name> <os>
> +# STATIC|SHARED
> +# ARCHS <architectures>
> +# SOURCES <source files>
> +# CFLAGS <compile flags>
> +# DEFS <compile definitions>
> +# LINKFLAGS <link flags>)
> +function(add_compiler_rt_darwin_runtime name os)
> + cmake_parse_arguments(LIB "SHARED;STATIC" "" "ARCHS;SOURCES;CFLAGS;DEFS;LINKFLAGS" ${ARGN})
> list_union(filtered_arches DARWIN_${os}_ARCHS LIB_ARCHS)
> - set_target_properties(${name} PROPERTIES
> - OSX_ARCHITECTURES "${filtered_arches}"
> - LIBRARY_OUTPUT_DIRECTORY ${COMPILER_RT_LIBRARY_OUTPUT_DIR})
> - install(TARGETS ${name}
> - LIBRARY DESTINATION ${COMPILER_RT_LIBRARY_INSTALL_DIR})
> -endmacro()
> + # if there are no supported architectures, don't create the library
> + if(filtered_arches)
> + if(LIB_SHARED)
> + add_library(${name} SHARED ${LIB_SOURCES})
> + set_target_properties(${name} PROPERTIES
> + LIBRARY_OUTPUT_DIRECTORY ${COMPILER_RT_LIBRARY_OUTPUT_DIR})
> + install(TARGETS ${name}
> + LIBRARY DESTINATION ${COMPILER_RT_LIBRARY_INSTALL_DIR})
> + elseif(LIB_STATIC)
> + add_library(${name} STATIC ${LIB_SOURCES})
> + set_target_properties(${name} PROPERTIES
> + ARCHIVE_OUTPUT_DIRECTORY ${COMPILER_RT_LIBRARY_OUTPUT_DIR})
> + install(TARGETS ${name}
> + ARCHIVE DESTINATION ${COMPILER_RT_LIBRARY_INSTALL_DIR})
> + else()
> + message(FATAL_ERROR "Must specified SHARED|STATIC to add_compiler_rt_darwin_runtime")
> + endif()
> +
> + 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
> + OSX_ARCHITECTURES "${filtered_arches}")
> + endif()
> +endfunction()
>
> set(COMPILER_RT_TEST_CFLAGS)
>
More information about the llvm-commits
mailing list