[llvm-commits] [compiler-rt] r163613 - in /compiler-rt/trunk: CMakeLists.txt lib/asan/CMakeLists.txt lib/asan/tests/CMakeLists.txt lib/interception/CMakeLists.txt lib/sanitizer_common/CMakeLists.txt
Evgeniy Stepanov
eugeni.stepanov at gmail.com
Tue Sep 11 04:55:45 PDT 2012
Author: eugenis
Date: Tue Sep 11 06:55:45 2012
New Revision: 163613
URL: http://llvm.org/viewvc/llvm-project?rev=163613&view=rev
Log:
CMake build rules for ASan Android runtime and tests.
Modified:
compiler-rt/trunk/CMakeLists.txt
compiler-rt/trunk/lib/asan/CMakeLists.txt
compiler-rt/trunk/lib/asan/tests/CMakeLists.txt
compiler-rt/trunk/lib/interception/CMakeLists.txt
compiler-rt/trunk/lib/sanitizer_common/CMakeLists.txt
Modified: compiler-rt/trunk/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/CMakeLists.txt?rev=163613&r1=163612&r2=163613&view=diff
==============================================================================
--- compiler-rt/trunk/CMakeLists.txt (original)
+++ compiler-rt/trunk/CMakeLists.txt Tue Sep 11 06:55:45 2012
@@ -48,20 +48,6 @@
COMPILE_DEFINITIONS "${TARGET_I386_CFLAGS}"
CMAKE_FLAGS "-DCMAKE_EXE_LINKER_FLAGS:STRING=${TARGET_I386_CFLAGS}")
-if(LLVM_ANDROID_TOOLCHAIN_DIR)
- if(EXISTS ${LLVM_ANDROID_TOOLCHAIN_DIR}/arm-linux-androideabi)
- set(CAN_TARGET_ARM_ANDROID 1)
- set(TARGET_ARM_ANDROID_CFLAGS
- -target arm-linux-androideabi
- --sysroot=${LLVM_ANDROID_TOOLCHAIN_DIR}/sysroot
- -B${LLVM_ANDROID_TOOLCHAIN_DIR}
- )
- else()
- set(CAN_TARGET_ARM_ANDROID 0)
- endif()
- # TODO: support i686 and MIPS Android toolchains
-endif()
-
function(filter_available_targets out_var)
set(archs)
foreach(arch ${ARGN})
@@ -106,6 +92,13 @@
set_property(TARGET ${target} PROPERTY COMPILE_FLAGS "${argstring}")
endfunction()
+function(set_target_link_flags target)
+ foreach(arg ${ARGN})
+ set(argstring "${argstring} ${arg}")
+ endforeach()
+ set_property(TARGET ${target} PROPERTY LINK_FLAGS "${argstring}")
+endfunction()
+
# 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.
Modified: compiler-rt/trunk/lib/asan/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/CMakeLists.txt?rev=163613&r1=163612&r2=163613&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/CMakeLists.txt (original)
+++ compiler-rt/trunk/lib/asan/CMakeLists.txt Tue Sep 11 06:55:45 2012
@@ -30,11 +30,20 @@
set(ASAN_CFLAGS ${SANITIZER_COMMON_CFLAGS})
-set(ASAN_COMMON_DEFINITIONS
- ASAN_HAS_EXCEPTIONS=1
- ASAN_FLEXIBLE_MAPPING_AND_OFFSET=0
- ASAN_NEEDS_SEGV=1
- )
+if(ANDROID)
+ set(ASAN_COMMON_DEFINITIONS
+ ASAN_HAS_EXCEPTIONS=1
+ ASAN_FLEXIBLE_MAPPING_AND_OFFSET=0
+ ASAN_NEEDS_SEGV=0
+ ASAN_LOW_MEMORY=1
+ )
+else()
+ set(ASAN_COMMON_DEFINITIONS
+ ASAN_HAS_EXCEPTIONS=1
+ ASAN_FLEXIBLE_MAPPING_AND_OFFSET=0
+ ASAN_NEEDS_SEGV=1
+ )
+endif()
set(ASAN_DYLIB_DEFINITIONS
${ASAN_COMMON_DEFINITIONS}
@@ -54,6 +63,17 @@
set_target_properties(clang_rt.asan_osx PROPERTIES
OSX_ARCHITECTURES "${ASAN_TARGETS}")
list(APPEND ASAN_RUNTIME_LIBRARIES clang_rt.asan_osx)
+elseif(ANDROID)
+ add_library(clang_rt.asan-arm-android SHARED
+ ${ASAN_SOURCES}
+ $<TARGET_OBJECTS:RTInterception.arm.android>
+ $<TARGET_OBJECTS:RTSanitizerCommon.arm.android>
+ )
+ set_target_compile_flags(clang_rt.asan-arm-android
+ ${ASAN_CFLAGS}
+ )
+ target_link_libraries(clang_rt.asan-arm-android dl)
+ list(APPEND ASAN_RUNTIME_LIBRARIES clang_rt.asan-arm-android)
else()
# Otherwise, build separate libraries for each target.
if(CAN_TARGET_X86_64)
@@ -78,17 +98,6 @@
)
list(APPEND ASAN_RUNTIME_LIBRARIES clang_rt.asan-i386)
endif()
- if(CAN_TARGET_ARM_ANDROID)
- add_library(clang_rt.asan-arm-android STATIC
- ${ASAN_SOURCES}
- $<TARGET_OBJECTS:RTInterception.arm.android>
- $<TARGET_OBJECTS:RTSanitizerCommon.arm.android>
- )
- set_target_compile_flags(clang_rt.asan-arm-android
- ${ASAN_CFLAGS} ${TARGET_ARM_ANDROID_CFLAGS}
- )
- list(APPEND ASAN_RUNTIME_LIBRARIES clang_rt.asan-arm-android)
- endif()
endif()
set_property(TARGET ${ASAN_RUNTIME_LIBRARIES} APPEND PROPERTY
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=163613&r1=163612&r2=163613&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/tests/CMakeLists.txt (original)
+++ compiler-rt/trunk/lib/asan/tests/CMakeLists.txt Tue Sep 11 06:55:45 2012
@@ -15,17 +15,32 @@
include_directories(../..)
set(ASAN_UNITTEST_COMMON_CFLAGS
- # Use -D instead of definitions to please custom compile command.
- -DASAN_HAS_BLACKLIST=1
- -DASAN_HAS_EXCEPTIONS=1
- -DASAN_NEEDS_SEGV=1
- -DASAN_UAR=0
-Wall
-Wno-format
-fvisibility=hidden
-g
-O2
)
+
+# Use -D instead of definitions to please custom compile command.
+if(ANDROID)
+ list(APPEND ASAN_UNITTEST_COMMON_CFLAGS
+ -DASAN_LOW_MEMORY=1
+ -DASAN_HAS_BLACKLIST=1
+ -DASAN_HAS_EXCEPTIONS=1
+ -DASAN_NEEDS_SEGV=0
+ -DASAN_UAR=0
+ -fPIE
+ )
+else()
+ list(APPEND ASAN_UNITTEST_COMMON_CFLAGS
+ -DASAN_HAS_BLACKLIST=1
+ -DASAN_HAS_EXCEPTIONS=1
+ -DASAN_NEEDS_SEGV=1
+ -DASAN_UAR=0
+ )
+endif()
+
# Support 64-bit and 32-bit builds.
if(LLVM_BUILD_32_BITS)
list(APPEND ASAN_UNITTEST_COMMON_CFLAGS -m32)
@@ -60,6 +75,8 @@
set_property(TARGET ${testname} APPEND PROPERTY
LINK_FLAGS "-framework Foundation")
target_link_libraries(${testname} clang_rt.asan_osx)
+ elseif (ANDROID)
+ target_link_libraries(${testname} clang_rt.asan-arm-android)
elseif (UNIX)
# Linux-specific linker flags.
set_property(TARGET ${testname} APPEND PROPERTY
@@ -89,7 +106,8 @@
# We only support building instrumented tests when we're not cross compiling
# and targeting a unix-like system where we can predict viable compilation and
# linking strategies.
-if("${CMAKE_HOST_SYSTEM}" STREQUAL "${CMAKE_SYSTEM}" AND UNIX)
+# We use a different approach to build these tests for Android. See below.
+if("${CMAKE_HOST_SYSTEM}" STREQUAL "${CMAKE_SYSTEM}" AND UNIX AND NOT ANDROID)
# This function is a custom routine to manage manually compiling source files
# for unit tests with the just-built Clang binary, using the ASan
@@ -128,5 +146,26 @@
# Main AddressSanitizer unit tests.
add_custom_target(AsanUnitTests)
set_target_properties(AsanUnitTests PROPERTIES FOLDER "ASan unit tests")
-add_asan_test(AsanUnitTests AsanTest ${ASAN_NOINST_TEST_SOURCES}
- ${ASAN_INST_TEST_OBJECTS})
+
+if(ANDROID)
+ set(ASAN_INST_TEST_SOURCES asan_globals_test.cc asan_test.cc)
+ add_library(asan_noinst_test OBJECT
+ ${ASAN_NOINST_TEST_SOURCES}
+ )
+ set_target_compile_flags(asan_noinst_test
+ ${ASAN_UNITTEST_COMMON_CFLAGS} ${ASAN_GTEST_INCLUDE_CFLAGS}
+ )
+ add_asan_test(AsanUnitTests AsanTest
+ ${ASAN_INST_TEST_SOURCES}
+ $<TARGET_OBJECTS:asan_noinst_test>
+ )
+ set_target_compile_flags(AsanTest
+ ${ASAN_UNITTEST_INSTRUMENTED_CFLAGS} ${ASAN_GTEST_INCLUDE_CFLAGS}
+ )
+ set_target_link_flags(AsanTest
+ -pie
+ )
+else()
+ add_asan_test(AsanUnitTests AsanTest ${ASAN_NOINST_TEST_SOURCES}
+ ${ASAN_INST_TEST_OBJECTS})
+endif()
Modified: compiler-rt/trunk/lib/interception/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/interception/CMakeLists.txt?rev=163613&r1=163612&r2=163613&view=diff
==============================================================================
--- compiler-rt/trunk/lib/interception/CMakeLists.txt (original)
+++ compiler-rt/trunk/lib/interception/CMakeLists.txt Tue Sep 11 06:55:45 2012
@@ -34,9 +34,9 @@
set_target_compile_flags(RTInterception.i386
${INTERCEPTION_CFLAGS} ${TARGET_I386_CFLAGS})
endif()
- if(CAN_TARGET_ARM_ANDROID)
+ if(ANDROID)
add_library(RTInterception.arm.android OBJECT ${INTERCEPTION_SOURCES})
set_target_compile_flags(RTInterception.arm.android
- ${INTERCEPTION_CFLAGS} ${TARGET_ARM_ANDROID_CFLAGS})
+ ${INTERCEPTION_CFLAGS})
endif()
endif()
Modified: compiler-rt/trunk/lib/sanitizer_common/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/CMakeLists.txt?rev=163613&r1=163612&r2=163613&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/CMakeLists.txt (original)
+++ compiler-rt/trunk/lib/sanitizer_common/CMakeLists.txt Tue Sep 11 06:55:45 2012
@@ -44,10 +44,10 @@
${SANITIZER_CFLAGS} ${TARGET_I386_CFLAGS})
list(APPEND SANITIZER_RUNTIME_LIBRARIES RTSanitizerCommon.i386)
endif()
- if(CAN_TARGET_ARM_ANDROID)
+ if(ANDROID)
add_library(RTSanitizerCommon.arm.android OBJECT ${SANITIZER_SOURCES})
set_target_compile_flags(RTSanitizerCommon.arm.android
- ${SANITIZER_CFLAGS} ${TARGET_ARM_ANDROID_CFLAGS})
+ ${SANITIZER_CFLAGS})
list(APPEND SANITIZER_RUNTIME_LIBRARIES RTSanitizerCommon.arm.android)
endif()
endif()
More information about the llvm-commits
mailing list