summaryrefslogtreecommitdiffstats
path: root/compiler-rt
diff options
context:
space:
mode:
authorAlexey Samsonov <samsonov@google.com>2012-07-24 11:49:55 +0000
committerAlexey Samsonov <samsonov@google.com>2012-07-24 11:49:55 +0000
commit3397013606d10ddae5346970f93f705739826b9b (patch)
treeadbb0875480db1e134a341e52c343c2b3e9263ae /compiler-rt
parent465834c85f97666559d7acae8c028cb4ee3012f6 (diff)
downloadbcm5719-llvm-3397013606d10ddae5346970f93f705739826b9b.tar.gz
bcm5719-llvm-3397013606d10ddae5346970f93f705739826b9b.zip
[ASan] hacking cmake build: after generating asan runtime, copy it to the Clang lib directory where Clang driver expects to find it.
llvm-svn: 160669
Diffstat (limited to 'compiler-rt')
-rw-r--r--compiler-rt/lib/asan/CMakeLists.txt28
1 files changed, 27 insertions, 1 deletions
diff --git a/compiler-rt/lib/asan/CMakeLists.txt b/compiler-rt/lib/asan/CMakeLists.txt
index a8183c4f2dd..c14ef653e84 100644
--- a/compiler-rt/lib/asan/CMakeLists.txt
+++ b/compiler-rt/lib/asan/CMakeLists.txt
@@ -28,6 +28,9 @@ set(ASAN_CFLAGS
-fno-exceptions
-funwind-tables
-fvisibility=hidden
+ -fno-builtin
+ -fomit-frame-pointer
+ -O3
)
if (SUPPORTS_NO_VARIADIC_MACROS_FLAG)
list(APPEND ASAN_CFLAGS -Wno-variadic-macros)
@@ -38,6 +41,21 @@ set(ASAN_COMMON_DEFINITIONS
ASAN_NEEDS_SEGV=1
)
+# Compute the Clang version from the LLVM version.
+string(REGEX MATCH "[0-9]+\\.[0-9]+(\\.[0-9]+)?" CLANG_VERSION
+ ${PACKAGE_VERSION})
+
+# Set up paths to ASan runtime that Clang driver passes to linker.
+if (APPLE)
+ # FIXME: We need to build OS X universal binary libclang_rt.asan-osx.a
+ # instead of two arch-specific binaries.
+ set(clang_lib_dir ${LLVM_BINARY_DIR}/lib/clang/${CLANG_VERSION}/lib/darwin)
+ list(APPEND ASAN_CFLAGS -mmacosx-version-min=10.5)
+elseif (UNIX)
+ # Assume Linux.
+ set(clang_lib_dir ${LLVM_BINARY_DIR}/lib/clang/${CLANG_VERSION}/lib/linux)
+endif()
+
if(CAN_TARGET_X86_64)
add_library(clang_rt.asan-x86_64 STATIC
${ASAN_SOURCES}
@@ -50,6 +68,10 @@ if(CAN_TARGET_X86_64)
)
set_property(TARGET clang_rt.asan-x86_64 APPEND PROPERTY COMPILE_DEFINITIONS
${ASAN_COMMON_DEFINITIONS})
+ add_custom_command (TARGET clang_rt.asan-x86_64 POST_BUILD
+ COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:clang_rt.asan-x86_64>
+ ${clang_lib_dir}/libclang_rt.asan-x86_64.a
+ COMMENT "Copying libclang_rt.asan-x86_64.a to Clang lib dir...")
endif()
if(CAN_TARGET_I386)
add_library(clang_rt.asan-i386 STATIC
@@ -61,8 +83,12 @@ if(CAN_TARGET_I386)
${ASAN_CFLAGS}
${TARGET_I386_CFLAGS}
)
- set_property(TARGET clang_rt.asan-x86_64 APPEND PROPERTY COMPILE_DEFINITIONS
+ set_property(TARGET clang_rt.asan-i386 APPEND PROPERTY COMPILE_DEFINITIONS
${ASAN_COMMON_DEFINITIONS})
+ add_custom_command (TARGET clang_rt.asan-i386 POST_BUILD
+ COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:clang_rt.asan-i386>
+ ${clang_lib_dir}/libclang_rt.asan-i386.a
+ COMMENT "Copying libclang_rt.asan-i386.a to Clang lib dir...")
endif()
if(LLVM_INCLUDE_TESTS)
OpenPOWER on IntegriCloud