diff options
author | Alexey Samsonov <samsonov@google.com> | 2012-07-25 11:15:00 +0000 |
---|---|---|
committer | Alexey Samsonov <samsonov@google.com> | 2012-07-25 11:15:00 +0000 |
commit | 5062359502a5d0e43e314aed9c8c5baa082e8de3 (patch) | |
tree | a34436d7f9021b8868a25baa91d63ad872998de2 /compiler-rt | |
parent | 2538bf111eeda6e43ba4ea79449be68b5a1648f6 (diff) | |
download | bcm5719-llvm-5062359502a5d0e43e314aed9c8c5baa082e8de3.tar.gz bcm5719-llvm-5062359502a5d0e43e314aed9c8c5baa082e8de3.zip |
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.
llvm-svn: 160721
Diffstat (limited to 'compiler-rt')
-rw-r--r-- | compiler-rt/lib/CMakeLists.txt | 22 | ||||
-rw-r--r-- | compiler-rt/lib/asan/CMakeLists.txt | 5 | ||||
-rw-r--r-- | compiler-rt/lib/asan/tests/CMakeLists.txt | 2 |
3 files changed, 28 insertions, 1 deletions
diff --git a/compiler-rt/lib/CMakeLists.txt b/compiler-rt/lib/CMakeLists.txt index 21fdd77a8b9..67019655332 100644 --- a/compiler-rt/lib/CMakeLists.txt +++ b/compiler-rt/lib/CMakeLists.txt @@ -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) diff --git a/compiler-rt/lib/asan/CMakeLists.txt b/compiler-rt/lib/asan/CMakeLists.txt index 5bd9e7eea8c..ce985f52817 100644 --- a/compiler-rt/lib/asan/CMakeLists.txt +++ b/compiler-rt/lib/asan/CMakeLists.txt @@ -45,6 +45,9 @@ set(ASAN_COMMON_DEFINITIONS 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 @@ if(CAN_TARGET_X86_64) ) 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 @@ if(CAN_TARGET_I386) ) 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) diff --git a/compiler-rt/lib/asan/tests/CMakeLists.txt b/compiler-rt/lib/asan/tests/CMakeLists.txt index 8a9da45b2da..d409d50b995 100644 --- a/compiler-rt/lib/asan/tests/CMakeLists.txt +++ b/compiler-rt/lib/asan/tests/CMakeLists.txt @@ -99,7 +99,7 @@ if("${CMAKE_HOST_SYSTEM}" STREQUAL "${CMAKE_SYSTEM}" AND UNIX) -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() |