[llvm-commits] [compiler-rt] r160721 - in /compiler-rt/trunk/lib: CMakeLists.txt asan/CMakeLists.txt asan/tests/CMakeLists.txt

Alexey Samsonov samsonov at google.com
Wed Jul 25 04:15:00 PDT 2012


Author: samsonov
Date: Wed Jul 25 06:15:00 2012
New Revision: 160721

URL: http://llvm.org/viewvc/llvm-project?rev=160721&view=rev
Log:
cmake for compiler-rt: add a function to set output dirs for compiler runtimes equal to directory used by Clang driver. Use it for ASan runtime. Also, make sure that ASan unit tests depend on the ASan runtime.

Modified:
    compiler-rt/trunk/lib/CMakeLists.txt
    compiler-rt/trunk/lib/asan/CMakeLists.txt
    compiler-rt/trunk/lib/asan/tests/CMakeLists.txt

Modified: compiler-rt/trunk/lib/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/CMakeLists.txt?rev=160721&r1=160720&r2=160721&view=diff
==============================================================================
--- compiler-rt/trunk/lib/CMakeLists.txt (original)
+++ compiler-rt/trunk/lib/CMakeLists.txt Wed Jul 25 06:15:00 2012
@@ -1,3 +1,25 @@
+# Compute the Clang version from the LLVM version.
+# FIXME: We should be able to reuse CLANG_VERSION variable calculated
+#        in Clang cmake files, instead of copying the rules here.
+string(REGEX MATCH "[0-9]+\\.[0-9]+(\\.[0-9]+)?" CLANG_VERSION
+       ${PACKAGE_VERSION})
+
+# Call add_clang_runtime_static_library(<target_library>) to make
+# sure that static <target_library> is built in the directory
+# where Clang driver expects to find it.
+if (APPLE)
+  set(CLANG_RUNTIME_LIB_DIR
+      ${LLVM_BINARY_DIR}/lib/clang/${CLANG_VERSION}/lib/darwin)
+elseif (UNIX)
+  # Assume Linux.
+  set(CLANG_RUNTIME_LIB_DIR
+      ${LLVM_BINARY_DIR}/lib/clang/${CLANG_VERSION}/lib/linux)
+endif()
+function(add_clang_runtime_static_library target_name)
+  set_target_properties(${target_name} PROPERTIES
+                        ARCHIVE_OUTPUT_DIRECTORY ${CLANG_RUNTIME_LIB_DIR})
+endfunction()
+
 # First, add the subdirectories which contain feature-based runtime libraries
 # and several convenience helper libraries.
 add_subdirectory(asan)

Modified: compiler-rt/trunk/lib/asan/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/CMakeLists.txt?rev=160721&r1=160720&r2=160721&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/CMakeLists.txt (original)
+++ compiler-rt/trunk/lib/asan/CMakeLists.txt Wed Jul 25 06:15:00 2012
@@ -45,6 +45,9 @@
   ASAN_NEEDS_SEGV=1
   )
 
+# FIXME: We need to build universal binaries on OS X instead of
+# two arch-specific binaries.
+
 if(CAN_TARGET_X86_64)
   add_library(clang_rt.asan-x86_64 STATIC
     ${ASAN_SOURCES}
@@ -57,6 +60,7 @@
     )
   set_property(TARGET clang_rt.asan-x86_64 APPEND PROPERTY COMPILE_DEFINITIONS
     ${ASAN_COMMON_DEFINITIONS})
+  add_clang_runtime_static_library(clang_rt.asan-x86_64)
 endif()
 if(CAN_TARGET_I386)
   add_library(clang_rt.asan-i386 STATIC
@@ -70,6 +74,7 @@
     )
   set_property(TARGET clang_rt.asan-i386 APPEND PROPERTY COMPILE_DEFINITIONS
     ${ASAN_COMMON_DEFINITIONS})
+  add_clang_runtime_static_library(clang_rt.asan-i386)
 endif()
 
 if(LLVM_INCLUDE_TESTS)

Modified: compiler-rt/trunk/lib/asan/tests/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/tests/CMakeLists.txt?rev=160721&r1=160720&r2=160721&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/tests/CMakeLists.txt (original)
+++ compiler-rt/trunk/lib/asan/tests/CMakeLists.txt Wed Jul 25 06:15:00 2012
@@ -99,7 +99,7 @@
               -c -o "${output_obj}"
               ${CMAKE_CURRENT_SOURCE_DIR}/${source}
       MAIN_DEPENDENCY ${source}
-      DEPENDS clang ${ARGN}
+      DEPENDS clang clang_rt.asan-i386 clang_rt.asan-x86_64 ${ARGN}
       )
   endfunction()
 





More information about the llvm-commits mailing list