[CMake] Rename add_compiler_rt_static_runtime to add_compiler_rt_runtime.

Soon there will be an option to build compiler-rt parts as shared libraries
on Linux. Extracted from http://llvm-reviews.chandlerc.com/D3042
by Yuri Gribov.

llvm-svn: 205183
This commit is contained in:
Alexey Samsonov 2014-03-31 13:45:36 +00:00
parent 66f560903f
commit 78a8435fd6
11 changed files with 31 additions and 28 deletions

View File

@ -37,33 +37,37 @@ macro(add_compiler_rt_darwin_object_library name os)
COMPILE_DEFINITIONS ${LIB_DEFS})
endmacro()
# Adds static runtime for a given architecture and puts it in the proper
# directory in the build and install trees.
# add_compiler_rt_static_runtime(<name> <arch>
# SOURCES <source files>
# CFLAGS <compile flags>
# DEFS <compile definitions>)
macro(add_compiler_rt_static_runtime name arch)
# Adds static or shared runtime for a given architecture and puts it in the
# proper directory in the build and install trees.
# add_compiler_rt_runtime(<name> <arch> {STATIC,SHARED}
# SOURCES <source files>
# CFLAGS <compile flags>
# DEFS <compile definitions>)
macro(add_compiler_rt_runtime name arch type)
if(CAN_TARGET_${arch})
parse_arguments(LIB "SOURCES;CFLAGS;DEFS" "" ${ARGN})
add_library(${name} STATIC ${LIB_SOURCES})
add_library(${name} ${type} ${LIB_SOURCES})
# Setup compile flags and definitions.
set_target_compile_flags(${name}
${TARGET_${arch}_CFLAGS} ${LIB_CFLAGS})
set_target_link_flags(${name}
${TARGET_${arch}_CFLAGS} ${LIB_CFLAGS})
set_property(TARGET ${name} APPEND PROPERTY
COMPILE_DEFINITIONS ${LIB_DEFS})
# Setup correct output directory in the build tree.
set_target_properties(${name} PROPERTIES
ARCHIVE_OUTPUT_DIRECTORY ${COMPILER_RT_LIBRARY_OUTPUT_DIR})
ARCHIVE_OUTPUT_DIRECTORY ${COMPILER_RT_LIBRARY_OUTPUT_DIR}
LIBRARY_OUTPUT_DIRECTORY ${COMPILER_RT_LIBRARY_OUTPUT_DIR})
# Add installation command.
install(TARGETS ${name}
ARCHIVE DESTINATION ${COMPILER_RT_LIBRARY_INSTALL_DIR})
ARCHIVE DESTINATION ${COMPILER_RT_LIBRARY_INSTALL_DIR}
LIBRARY DESTINATION ${COMPILER_RT_LIBRARY_INSTALL_DIR})
else()
message(FATAL_ERROR "Archtecture ${arch} can't be targeted")
endif()
endmacro()
# Same as add_compiler_rt_static_runtime, but creates a universal library
# Same as add_compiler_rt_runtime(... STATIC), but creates a universal library
# for several architectures.
# add_compiler_rt_osx_static_runtime(<name> ARCH <architectures>
# SOURCES <source files>

View File

@ -113,7 +113,7 @@ else()
list(APPEND ASAN_RUNTIME_OBJECTS $<TARGET_OBJECTS:RTLSanCommon.${arch}>)
endif()
add_compiler_rt_static_runtime(clang_rt.asan-${arch} ${arch}
add_compiler_rt_runtime(clang_rt.asan-${arch} ${arch} STATIC
SOURCES ${ASAN_RUNTIME_OBJECTS}
CFLAGS ${ASAN_CFLAGS}
DEFS ${ASAN_COMMON_DEFINITIONS})
@ -124,10 +124,10 @@ else()
endif()
if (WIN32)
add_compiler_rt_static_runtime(clang_rt.asan_dll_thunk-${arch} ${arch}
SOURCES asan_dll_thunk.cc
CFLAGS ${ASAN_CFLAGS} -DASAN_DLL_THUNK
DEFS ${ASAN_COMMON_DEFINITIONS})
add_compiler_rt_runtime(clang_rt.asan_dll_thunk-${arch} ${arch} STATIC
SOURCES asan_dll_thunk.cc
CFLAGS ${ASAN_CFLAGS} -DASAN_DLL_THUNK
DEFS ${ASAN_COMMON_DEFINITIONS})
add_dependencies(asan clang_rt.asan_dll_thunk-${arch})
endif()
endforeach()

View File

@ -247,7 +247,7 @@ add_custom_target(builtins)
if (NOT WIN32)
foreach(arch x86_64 i386 arm)
if(CAN_TARGET_${arch})
add_compiler_rt_static_runtime(clang_rt.${arch} ${arch}
add_compiler_rt_runtime(clang_rt.${arch} ${arch} STATIC
SOURCES ${${arch}_SOURCES}
CFLAGS "-std=c99")
add_dependencies(builtins clang_rt.${arch})

View File

@ -15,14 +15,14 @@ set(arch "x86_64")
if(CAN_TARGET_${arch})
set(DFSAN_CFLAGS ${DFSAN_COMMON_CFLAGS})
append_if(COMPILER_RT_HAS_FPIE_FLAG -fPIE DFSAN_CFLAGS)
add_compiler_rt_static_runtime(clang_rt.dfsan-${arch} ${arch}
add_compiler_rt_runtime(clang_rt.dfsan-${arch} ${arch} STATIC
SOURCES ${DFSAN_RTL_SOURCES}
$<TARGET_OBJECTS:RTInterception.${arch}>
$<TARGET_OBJECTS:RTSanitizerCommon.${arch}>
$<TARGET_OBJECTS:RTSanitizerCommonLibc.${arch}>
CFLAGS ${DFSAN_CFLAGS})
set(DFSAN_NOLIBC_CFLAGS ${DFSAN_COMMON_CFLAGS} -DDFSAN_NOLIBC)
add_compiler_rt_static_runtime(clang_rt.dfsan-libc-${arch} ${arch}
add_compiler_rt_runtime(clang_rt.dfsan-libc-${arch} ${arch} STATIC
SOURCES ${DFSAN_RTL_SOURCES}
$<TARGET_OBJECTS:RTSanitizerCommon.${arch}>
CFLAGS ${DFSAN_NOLIBC_CFLAGS})

View File

@ -38,7 +38,7 @@ elseif(NOT ANDROID)
endforeach()
foreach(arch ${LSAN_SUPPORTED_ARCH})
add_compiler_rt_static_runtime(clang_rt.lsan-${arch} ${arch}
add_compiler_rt_runtime(clang_rt.lsan-${arch} ${arch} STATIC
SOURCES ${LSAN_SOURCES}
$<TARGET_OBJECTS:RTInterception.${arch}>
$<TARGET_OBJECTS:RTSanitizerCommon.${arch}>

View File

@ -20,7 +20,7 @@ append_if(COMPILER_RT_HAS_FFREESTANDING_FLAG -ffreestanding MSAN_RTL_CFLAGS)
add_custom_target(msan)
set(arch "x86_64")
if(CAN_TARGET_${arch})
add_compiler_rt_static_runtime(clang_rt.msan-${arch} ${arch}
add_compiler_rt_runtime(clang_rt.msan-${arch} ${arch} STATIC
SOURCES ${MSAN_RTL_SOURCES}
$<TARGET_OBJECTS:RTInterception.${arch}>
$<TARGET_OBJECTS:RTSanitizerCommon.${arch}>

View File

@ -25,8 +25,7 @@ else()
InstrProfilingRuntime.cc)
foreach(arch ${PROFILE_SUPPORTED_ARCH})
add_compiler_rt_static_runtime(clang_rt.profile-${arch}
${arch}
add_compiler_rt_runtime(clang_rt.profile-${arch} ${arch} STATIC
SOURCES ${PROFILE_SOURCES})
add_dependencies(profile clang_rt.profile-${arch})
endforeach()

View File

@ -129,7 +129,7 @@ else()
DEFS ${SANITIZER_COMMON_DEFINITIONS})
list(APPEND SANITIZER_RUNTIME_LIBRARIES RTSanitizerCommon.${arch}
RTSanitizerCommonLibc.${arch})
add_compiler_rt_static_runtime(clang_rt.san-${arch} ${arch}
add_compiler_rt_runtime(clang_rt.san-${arch} ${arch} STATIC
SOURCES $<TARGET_OBJECTS:RTSanitizerCommon.${arch}>
$<TARGET_OBJECTS:RTSanitizerCommonLibc.${arch}>
CFLAGS ${SANITIZER_CFLAGS}

View File

@ -83,7 +83,7 @@ if(CAN_TARGET_x86_64 AND UNIX AND NOT APPLE)
set_source_files_properties(${TSAN_ASM_SOURCES} PROPERTIES
LANGUAGE C)
set(arch "x86_64")
add_compiler_rt_static_runtime(clang_rt.tsan-${arch} ${arch}
add_compiler_rt_runtime(clang_rt.tsan-${arch} ${arch} STATIC
SOURCES ${TSAN_SOURCES} ${TSAN_ASM_SOURCES}
$<TARGET_OBJECTS:RTInterception.${arch}>
$<TARGET_OBJECTS:RTSanitizerCommon.${arch}>

View File

@ -26,7 +26,7 @@ add_custom_target(dd)
# Deadlock detector is currently supported on 64-bit Linux only.
if(CAN_TARGET_x86_64 AND UNIX AND NOT APPLE AND NOT ANDROID)
set(arch "x86_64")
add_compiler_rt_static_runtime(clang_rt.dd-${arch} ${arch}
add_compiler_rt_runtime(clang_rt.dd-${arch} ${arch} STATIC
SOURCES ${DD_SOURCES}
$<TARGET_OBJECTS:RTInterception.${arch}>
$<TARGET_OBJECTS:RTSanitizerCommon.${arch}>

View File

@ -29,11 +29,11 @@ else()
# Build separate libraries for each target.
foreach(arch ${UBSAN_SUPPORTED_ARCH})
# Main UBSan runtime.
add_compiler_rt_static_runtime(clang_rt.ubsan-${arch} ${arch}
add_compiler_rt_runtime(clang_rt.ubsan-${arch} ${arch} STATIC
SOURCES ${UBSAN_SOURCES}
CFLAGS ${UBSAN_CFLAGS})
# C++-specific parts of UBSan runtime. Requires a C++ ABI library.
add_compiler_rt_static_runtime(clang_rt.ubsan_cxx-${arch} ${arch}
add_compiler_rt_runtime(clang_rt.ubsan_cxx-${arch} ${arch} STATIC
SOURCES ${UBSAN_CXX_SOURCES}
CFLAGS ${UBSAN_CFLAGS})
add_dependencies(ubsan