[compiler-rt] r279863 - [CMake] Connect Compiler-RT targets to LLVM Runtimes directory

Chris Bieneman via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 26 13:52:22 PDT 2016


Author: cbieneman
Date: Fri Aug 26 15:52:22 2016
New Revision: 279863

URL: http://llvm.org/viewvc/llvm-project?rev=279863&view=rev
Log:
[CMake] Connect Compiler-RT targets to LLVM Runtimes directory

This patch builds on LLVM r279776.

In this patch I've done some cleanup and abstracted three common steps runtime components have in their CMakeLists files, and added a fourth.

The three steps I abstract are:

(1) Add a top-level target (i.e asan, msan, ...)
(2) Set the target properties for sorting files in IDE generators
(3) Make the compiler-rt target depend on the top-level target

The new step is to check if a command named "runtime_register_component" is defined, and to call it with the component name.

The runtime_register_component command is defined in llvm/runtimes/CMakeLists.txt, and presently just adds the component to a list of sub-components, which later gets used to generate target mappings.

With this patch a new workflow for runtimes builds is supported. The new workflow when building runtimes from the LLVM runtimes directory is:

> cmake [...]
> ninja runtimes-configure
> ninja asan

The "runtimes-configure" target builds all the dependencies for configuring the runtimes projects, and runs CMake on the runtimes projects. Running the runtimes CMake generates a list of targets to bind into the top-level CMake so subsequent build invocations will have access to some of Compiler-RT's targets through the top-level build.

Note: This patch does exclude some top-level targets from compiler-rt libraries because they either don't install files (sanitizer_common), or don't have a cooresponding `check` target (stats).

Modified:
    compiler-rt/trunk/cmake/Modules/AddCompilerRT.cmake
    compiler-rt/trunk/lib/asan/CMakeLists.txt
    compiler-rt/trunk/lib/cfi/CMakeLists.txt
    compiler-rt/trunk/lib/dfsan/CMakeLists.txt
    compiler-rt/trunk/lib/esan/CMakeLists.txt
    compiler-rt/trunk/lib/lsan/CMakeLists.txt
    compiler-rt/trunk/lib/msan/CMakeLists.txt
    compiler-rt/trunk/lib/profile/CMakeLists.txt
    compiler-rt/trunk/lib/safestack/CMakeLists.txt
    compiler-rt/trunk/lib/scudo/CMakeLists.txt
    compiler-rt/trunk/lib/tsan/CMakeLists.txt
    compiler-rt/trunk/lib/ubsan/CMakeLists.txt
    compiler-rt/trunk/lib/xray/CMakeLists.txt

Modified: compiler-rt/trunk/cmake/Modules/AddCompilerRT.cmake
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/cmake/Modules/AddCompilerRT.cmake?rev=279863&r1=279862&r2=279863&view=diff
==============================================================================
--- compiler-rt/trunk/cmake/Modules/AddCompilerRT.cmake (original)
+++ compiler-rt/trunk/cmake/Modules/AddCompilerRT.cmake Fri Aug 26 15:52:22 2016
@@ -77,6 +77,15 @@ macro(format_object_libs output suffix)
   endforeach()
 endmacro()
 
+function(add_compiler_rt_component name)
+  add_custom_target(${name})
+  set_target_properties(${name} PROPERTIES FOLDER "Compiler-RT Misc")
+  if(COMMAND runtime_register_component)
+    runtime_register_component(${name})
+  endif()
+  add_dependencies(compiler-rt ${name})
+endfunction()
+
 # Adds static or shared runtime for a list of architectures and operating
 # systems and puts it in the proper directory in the build and install trees.
 # add_compiler_rt_runtime(<name>

Modified: compiler-rt/trunk/lib/asan/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/CMakeLists.txt?rev=279863&r1=279862&r2=279863&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/CMakeLists.txt (original)
+++ compiler-rt/trunk/lib/asan/CMakeLists.txt Fri Aug 26 15:52:22 2016
@@ -107,8 +107,7 @@ if(NOT APPLE)
 endif()
 
 # Build ASan runtimes shipped with Clang.
-add_custom_target(asan)
-set_target_properties(asan PROPERTIES FOLDER "Compiler-RT Misc")
+add_compiler_rt_component(asan)
 
 if(APPLE)
   add_compiler_rt_runtime(clang_rt.asan
@@ -225,7 +224,6 @@ else()
 endif()
 
 add_compiler_rt_resource_file(asan_blacklist asan_blacklist.txt asan)
-add_dependencies(compiler-rt asan)
 
 add_subdirectory(scripts)
 

Modified: compiler-rt/trunk/lib/cfi/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/cfi/CMakeLists.txt?rev=279863&r1=279862&r2=279863&view=diff
==============================================================================
--- compiler-rt/trunk/lib/cfi/CMakeLists.txt (original)
+++ compiler-rt/trunk/lib/cfi/CMakeLists.txt Fri Aug 26 15:52:22 2016
@@ -1,5 +1,4 @@
-add_custom_target(cfi)
-set_target_properties(cfi PROPERTIES FOLDER "Compiler-RT Misc")
+add_compiler_rt_component(cfi)
 
 set(CFI_SOURCES cfi.cc)
 
@@ -36,4 +35,3 @@ foreach(arch ${CFI_SUPPORTED_ARCH})
 endforeach()
 
 add_compiler_rt_resource_file(cfi_blacklist cfi_blacklist.txt cfi)
-add_dependencies(compiler-rt cfi)

Modified: compiler-rt/trunk/lib/dfsan/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/dfsan/CMakeLists.txt?rev=279863&r1=279862&r2=279863&view=diff
==============================================================================
--- compiler-rt/trunk/lib/dfsan/CMakeLists.txt (original)
+++ compiler-rt/trunk/lib/dfsan/CMakeLists.txt Fri Aug 26 15:52:22 2016
@@ -11,8 +11,7 @@ append_rtti_flag(OFF DFSAN_COMMON_CFLAGS
 append_list_if(COMPILER_RT_HAS_FFREESTANDING_FLAG -ffreestanding DFSAN_COMMON_CFLAGS)
 
 # Static runtime library.
-add_custom_target(dfsan)
-set_target_properties(dfsan PROPERTIES FOLDER "Compiler-RT Misc")
+add_compiler_rt_component(dfsan)
 
 foreach(arch ${DFSAN_SUPPORTED_ARCH})
   set(DFSAN_CFLAGS ${DFSAN_COMMON_CFLAGS})
@@ -46,5 +45,3 @@ add_custom_command(OUTPUT ${dfsan_abilis
 add_dependencies(dfsan dfsan_abilist)
 install(FILES ${dfsan_abilist_filename}
         DESTINATION ${COMPILER_RT_INSTALL_PATH})
-
-add_dependencies(compiler-rt dfsan)

Modified: compiler-rt/trunk/lib/esan/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/esan/CMakeLists.txt?rev=279863&r1=279862&r2=279863&view=diff
==============================================================================
--- compiler-rt/trunk/lib/esan/CMakeLists.txt (original)
+++ compiler-rt/trunk/lib/esan/CMakeLists.txt Fri Aug 26 15:52:22 2016
@@ -1,7 +1,6 @@
 # Build for the EfficiencySanitizer runtime support library.
 
-add_custom_target(esan)
-set_target_properties(esan PROPERTIES FOLDER "Compiler-RT Misc")
+add_compiler_rt_component(esan)
 
 set(ESAN_RTL_CFLAGS ${SANITIZER_COMMON_CFLAGS})
 append_rtti_flag(OFF ESAN_RTL_CFLAGS)
@@ -36,8 +35,6 @@ foreach (arch ${ESAN_SUPPORTED_ARCH})
     clang_rt.esan-${arch}-symbols)
 endforeach()
 
-add_dependencies(compiler-rt esan)
-
 if (COMPILER_RT_INCLUDE_TESTS)
   # TODO(bruening): add tests via add_subdirectory(tests)
 endif()

Modified: compiler-rt/trunk/lib/lsan/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/lsan/CMakeLists.txt?rev=279863&r1=279862&r2=279863&view=diff
==============================================================================
--- compiler-rt/trunk/lib/lsan/CMakeLists.txt (original)
+++ compiler-rt/trunk/lib/lsan/CMakeLists.txt Fri Aug 26 15:52:22 2016
@@ -16,9 +16,6 @@ set(LSAN_SOURCES
 
 set(LSAN_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR})
 
-add_custom_target(lsan)
-set_target_properties(lsan PROPERTIES FOLDER "Compiler-RT Misc")
-
 add_compiler_rt_object_libraries(RTLSanCommon
     OS ${SANITIZER_COMMON_SUPPORTED_OS}
     ARCHS ${LSAN_COMMON_SUPPORTED_ARCH}
@@ -27,6 +24,8 @@ add_compiler_rt_object_libraries(RTLSanC
 
 if(COMPILER_RT_HAS_LSAN)
   foreach(arch ${LSAN_SUPPORTED_ARCH})
+    add_compiler_rt_component(lsan)
+    
     add_compiler_rt_runtime(clang_rt.lsan
       STATIC
       ARCHS ${arch}
@@ -39,5 +38,3 @@ if(COMPILER_RT_HAS_LSAN)
       PARENT_TARGET lsan)
   endforeach()
 endif()
-
-add_dependencies(compiler-rt lsan)

Modified: compiler-rt/trunk/lib/msan/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/msan/CMakeLists.txt?rev=279863&r1=279862&r2=279863&view=diff
==============================================================================
--- compiler-rt/trunk/lib/msan/CMakeLists.txt (original)
+++ compiler-rt/trunk/lib/msan/CMakeLists.txt Fri Aug 26 15:52:22 2016
@@ -25,8 +25,7 @@ append_list_if(COMPILER_RT_HAS_FFREESTAN
 set(MSAN_RUNTIME_LIBRARIES)
 
 # Static runtime library.
-add_custom_target(msan)
-set_target_properties(msan PROPERTIES FOLDER "Compiler-RT Misc")
+add_compiler_rt_component(msan)
 
 foreach(arch ${MSAN_SUPPORTED_ARCH})
   add_compiler_rt_runtime(clang_rt.msan
@@ -61,7 +60,6 @@ foreach(arch ${MSAN_SUPPORTED_ARCH})
 endforeach()
 
 add_compiler_rt_resource_file(msan_blacklist msan_blacklist.txt msan)
-add_dependencies(compiler-rt msan)
 
 if(COMPILER_RT_INCLUDE_TESTS)
   add_subdirectory(tests)

Modified: compiler-rt/trunk/lib/profile/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/profile/CMakeLists.txt?rev=279863&r1=279862&r2=279863&view=diff
==============================================================================
--- compiler-rt/trunk/lib/profile/CMakeLists.txt (original)
+++ compiler-rt/trunk/lib/profile/CMakeLists.txt Fri Aug 26 15:52:22 2016
@@ -38,8 +38,7 @@ int main() {
 
 " COMPILER_RT_TARGET_HAS_FCNTL_LCK)
 
-add_custom_target(profile)
-set_target_properties(profile PROPERTIES FOLDER "Compiler-RT Misc")
+add_compiler_rt_component(profile)
 
 set(PROFILE_SOURCES
   GCDAProfiling.c
@@ -99,5 +98,3 @@ else()
     SOURCES ${PROFILE_SOURCES}
     PARENT_TARGET profile)
 endif()
-
-add_dependencies(compiler-rt profile)

Modified: compiler-rt/trunk/lib/safestack/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/safestack/CMakeLists.txt?rev=279863&r1=279862&r2=279863&view=diff
==============================================================================
--- compiler-rt/trunk/lib/safestack/CMakeLists.txt (original)
+++ compiler-rt/trunk/lib/safestack/CMakeLists.txt Fri Aug 26 15:52:22 2016
@@ -1,6 +1,4 @@
-add_custom_target(safestack)
-set_target_properties(safestack PROPERTIES
-  FOLDER "Compiler-RT Misc")
+add_compiler_rt_component(safestack)
 
 set(SAFESTACK_SOURCES safestack.cc)
 

Modified: compiler-rt/trunk/lib/scudo/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/scudo/CMakeLists.txt?rev=279863&r1=279862&r2=279863&view=diff
==============================================================================
--- compiler-rt/trunk/lib/scudo/CMakeLists.txt (original)
+++ compiler-rt/trunk/lib/scudo/CMakeLists.txt Fri Aug 26 15:52:22 2016
@@ -1,5 +1,4 @@
-add_custom_target(scudo)
-set_target_properties(scudo PROPERTIES FOLDER "Compiler-RT Misc")
+add_compiler_rt_component(scudo)
 
 include_directories(..)
 
@@ -28,6 +27,3 @@ if(COMPILER_RT_HAS_SCUDO)
       PARENT_TARGET scudo)
   endforeach()
 endif()
-
-add_dependencies(compiler-rt scudo)
-

Modified: compiler-rt/trunk/lib/tsan/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/CMakeLists.txt?rev=279863&r1=279862&r2=279863&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/CMakeLists.txt (original)
+++ compiler-rt/trunk/lib/tsan/CMakeLists.txt Fri Aug 26 15:52:22 2016
@@ -96,8 +96,7 @@ set(TSAN_HEADERS
   rtl/tsan_vector.h)
 
 set(TSAN_RUNTIME_LIBRARIES)
-add_custom_target(tsan)
-set_target_properties(tsan PROPERTIES FOLDER "Compiler-RT Misc")
+add_compiler_rt_component(tsan)
 
 if(APPLE)
   set(TSAN_ASM_SOURCES rtl/tsan_rtl_amd64.S)
@@ -198,8 +197,6 @@ else()
   endforeach()
 endif()
 
-add_dependencies(compiler-rt tsan)
-
 # Make sure that non-platform-specific files don't include any system headers.
 # FreeBSD does not install a number of Clang-provided headers for the compiler
 # in the base system due to incompatibilities between FreeBSD's and Clang's

Modified: compiler-rt/trunk/lib/ubsan/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/ubsan/CMakeLists.txt?rev=279863&r1=279862&r2=279863&view=diff
==============================================================================
--- compiler-rt/trunk/lib/ubsan/CMakeLists.txt (original)
+++ compiler-rt/trunk/lib/ubsan/CMakeLists.txt Fri Aug 26 15:52:22 2016
@@ -33,8 +33,7 @@ set(UBSAN_CXXFLAGS ${SANITIZER_COMMON_CF
 append_rtti_flag(ON UBSAN_CXXFLAGS)
 append_list_if(SANITIZER_CAN_USE_CXXABI -DUBSAN_CAN_USE_CXXABI UBSAN_CXXFLAGS)
 
-add_custom_target(ubsan)
-set_target_properties(ubsan PROPERTIES FOLDER "Compiler-RT Misc")
+add_compiler_rt_component(ubsan)
 
 if(APPLE)
   set(UBSAN_COMMON_SOURCES ${UBSAN_SOURCES})
@@ -125,5 +124,3 @@ else()
     endif()
   endif()
 endif()
-
-add_dependencies(compiler-rt ubsan)

Modified: compiler-rt/trunk/lib/xray/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/xray/CMakeLists.txt?rev=279863&r1=279862&r2=279863&view=diff
==============================================================================
--- compiler-rt/trunk/lib/xray/CMakeLists.txt (original)
+++ compiler-rt/trunk/lib/xray/CMakeLists.txt Fri Aug 26 15:52:22 2016
@@ -23,7 +23,8 @@ add_compiler_rt_object_libraries(RTXray
     SOURCES ${XRAY_SOURCES} CFLAGS ${XRAY_CFLAGS}
     DEFS ${XRAY_COMMON_DEFINITIONS})
 
-add_custom_target(xray)
+add_compiler_rt_component(xray)
+
 set(XRAY_COMMON_RUNTIME_OBJECT_LIBS
 		RTSanitizerCommon
 		RTSanitizerCommonLibc)
@@ -40,5 +41,3 @@ foreach (arch ${XRAY_SUPPORTED_ARCH})
 						PARENT_TARGET xray)
 		endif ()
 endforeach()
-
-add_dependencies(compiler-rt xray)




More information about the llvm-commits mailing list