From 78a8435fd6b85abc3348d3ec80d4ef53dd281067 Mon Sep 17 00:00:00 2001 From: Alexey Samsonov Date: Mon, 31 Mar 2014 13:45:36 +0000 Subject: [PATCH] [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 --- compiler-rt/cmake/Modules/AddCompilerRT.cmake | 26 +++++++++++-------- compiler-rt/lib/asan/CMakeLists.txt | 10 +++---- compiler-rt/lib/builtins/CMakeLists.txt | 2 +- compiler-rt/lib/dfsan/CMakeLists.txt | 4 +-- compiler-rt/lib/lsan/CMakeLists.txt | 2 +- compiler-rt/lib/msan/CMakeLists.txt | 2 +- compiler-rt/lib/profile/CMakeLists.txt | 3 +-- .../lib/sanitizer_common/CMakeLists.txt | 2 +- compiler-rt/lib/tsan/CMakeLists.txt | 2 +- compiler-rt/lib/tsan/dd/CMakeLists.txt | 2 +- compiler-rt/lib/ubsan/CMakeLists.txt | 4 +-- 11 files changed, 31 insertions(+), 28 deletions(-) diff --git a/compiler-rt/cmake/Modules/AddCompilerRT.cmake b/compiler-rt/cmake/Modules/AddCompilerRT.cmake index 480677960991..556ada48ae79 100644 --- a/compiler-rt/cmake/Modules/AddCompilerRT.cmake +++ b/compiler-rt/cmake/Modules/AddCompilerRT.cmake @@ -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( -# SOURCES -# CFLAGS -# DEFS ) -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( {STATIC,SHARED} +# SOURCES +# CFLAGS +# DEFS ) +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( ARCH # SOURCES diff --git a/compiler-rt/lib/asan/CMakeLists.txt b/compiler-rt/lib/asan/CMakeLists.txt index 5bfb7c1791a0..d1c0d801c6d1 100644 --- a/compiler-rt/lib/asan/CMakeLists.txt +++ b/compiler-rt/lib/asan/CMakeLists.txt @@ -113,7 +113,7 @@ else() list(APPEND ASAN_RUNTIME_OBJECTS $) 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() diff --git a/compiler-rt/lib/builtins/CMakeLists.txt b/compiler-rt/lib/builtins/CMakeLists.txt index 4887c5d07587..0c88893e1a96 100644 --- a/compiler-rt/lib/builtins/CMakeLists.txt +++ b/compiler-rt/lib/builtins/CMakeLists.txt @@ -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}) diff --git a/compiler-rt/lib/dfsan/CMakeLists.txt b/compiler-rt/lib/dfsan/CMakeLists.txt index bcf335df95d2..18fe34576109 100644 --- a/compiler-rt/lib/dfsan/CMakeLists.txt +++ b/compiler-rt/lib/dfsan/CMakeLists.txt @@ -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} $ $ $ 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} $ CFLAGS ${DFSAN_NOLIBC_CFLAGS}) diff --git a/compiler-rt/lib/lsan/CMakeLists.txt b/compiler-rt/lib/lsan/CMakeLists.txt index 8b026be6be8d..0924282a6ea7 100644 --- a/compiler-rt/lib/lsan/CMakeLists.txt +++ b/compiler-rt/lib/lsan/CMakeLists.txt @@ -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} $ $ diff --git a/compiler-rt/lib/msan/CMakeLists.txt b/compiler-rt/lib/msan/CMakeLists.txt index 47795e3c8b05..7a53026065db 100644 --- a/compiler-rt/lib/msan/CMakeLists.txt +++ b/compiler-rt/lib/msan/CMakeLists.txt @@ -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} $ $ diff --git a/compiler-rt/lib/profile/CMakeLists.txt b/compiler-rt/lib/profile/CMakeLists.txt index 526017f2e931..8d0a5d0d0fc3 100644 --- a/compiler-rt/lib/profile/CMakeLists.txt +++ b/compiler-rt/lib/profile/CMakeLists.txt @@ -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() diff --git a/compiler-rt/lib/sanitizer_common/CMakeLists.txt b/compiler-rt/lib/sanitizer_common/CMakeLists.txt index 854aa4024437..d28e5e6e3db6 100644 --- a/compiler-rt/lib/sanitizer_common/CMakeLists.txt +++ b/compiler-rt/lib/sanitizer_common/CMakeLists.txt @@ -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 $ $ CFLAGS ${SANITIZER_CFLAGS} diff --git a/compiler-rt/lib/tsan/CMakeLists.txt b/compiler-rt/lib/tsan/CMakeLists.txt index 4de713843e3c..792d259f43a2 100644 --- a/compiler-rt/lib/tsan/CMakeLists.txt +++ b/compiler-rt/lib/tsan/CMakeLists.txt @@ -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} $ $ diff --git a/compiler-rt/lib/tsan/dd/CMakeLists.txt b/compiler-rt/lib/tsan/dd/CMakeLists.txt index 305e26c078af..a21e2dd57f6c 100644 --- a/compiler-rt/lib/tsan/dd/CMakeLists.txt +++ b/compiler-rt/lib/tsan/dd/CMakeLists.txt @@ -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} $ $ diff --git a/compiler-rt/lib/ubsan/CMakeLists.txt b/compiler-rt/lib/ubsan/CMakeLists.txt index 33cedeee9344..78c0d703d959 100644 --- a/compiler-rt/lib/ubsan/CMakeLists.txt +++ b/compiler-rt/lib/ubsan/CMakeLists.txt @@ -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