summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib
diff options
context:
space:
mode:
authorAlexey Samsonov <samsonov@google.com>2012-11-16 12:57:07 +0000
committerAlexey Samsonov <samsonov@google.com>2012-11-16 12:57:07 +0000
commitbe9a293ddaa763b33340f3adb53da80cdb950d58 (patch)
tree28dde61765cb9bd74689c4fbe35ef42d5c5b1225 /compiler-rt/lib
parentcc42980335a44643ce8e79c7092446581ef457c8 (diff)
downloadbcm5719-llvm-be9a293ddaa763b33340f3adb53da80cdb950d58.tar.gz
bcm5719-llvm-be9a293ddaa763b33340f3adb53da80cdb950d58.zip
UBSan: enable CMake build on Darwin. Fix two failing tests and disable the test which produces linker errors on Darwin.
llvm-svn: 168169
Diffstat (limited to 'compiler-rt/lib')
-rw-r--r--compiler-rt/lib/CMakeLists.txt3
-rw-r--r--compiler-rt/lib/ubsan/CMakeLists.txt48
-rw-r--r--compiler-rt/lib/ubsan/lit_tests/Integer/add-overflow.cpp2
-rw-r--r--compiler-rt/lib/ubsan/lit_tests/Integer/sub-overflow.cpp2
-rw-r--r--compiler-rt/lib/ubsan/lit_tests/TypeCheck/vptr.cpp3
-rw-r--r--compiler-rt/lib/ubsan/lit_tests/lit.cfg5
6 files changed, 40 insertions, 23 deletions
diff --git a/compiler-rt/lib/CMakeLists.txt b/compiler-rt/lib/CMakeLists.txt
index 6febaf54c6d..b7cd07ee21b 100644
--- a/compiler-rt/lib/CMakeLists.txt
+++ b/compiler-rt/lib/CMakeLists.txt
@@ -6,12 +6,11 @@ if(CMAKE_SYSTEM_NAME MATCHES "Darwin|Linux")
add_subdirectory(asan)
add_subdirectory(interception)
add_subdirectory(sanitizer_common)
+ add_subdirectory(ubsan)
endif()
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
# ThreadSanitizer is supported on Linux only.
add_subdirectory(tsan)
- # UndefinedBehaviorSanitizer has been tested on Linux only.
- add_subdirectory(ubsan)
endif()
# FIXME: Add support for the profile library.
diff --git a/compiler-rt/lib/ubsan/CMakeLists.txt b/compiler-rt/lib/ubsan/CMakeLists.txt
index 3458875a6f2..b16983da43e 100644
--- a/compiler-rt/lib/ubsan/CMakeLists.txt
+++ b/compiler-rt/lib/ubsan/CMakeLists.txt
@@ -14,27 +14,41 @@ set(UBSAN_CFLAGS ${SANITIZER_COMMON_CFLAGS})
set(UBSAN_RUNTIME_LIBRARIES)
-if(CAN_TARGET_X86_64)
- add_library(clang_rt.ubsan-x86_64 STATIC
+if(APPLE)
+ # Build universal binary on APPLE.
+ add_library(clang_rt.ubsan_osx STATIC
${UBSAN_SOURCES}
- $<TARGET_OBJECTS:RTSanitizerCommon.x86_64>
+ $<TARGET_OBJECTS:RTSanitizerCommon.osx>
)
- set_target_compile_flags(clang_rt.ubsan-x86_64
- ${UBSAN_CFLAGS} ${TARGET_X86_64_CFLAGS}
- )
- list(APPEND UBSAN_RUNTIME_LIBRARIES clang_rt.ubsan-x86_64)
+ set_target_compile_flags(clang_rt.ubsan_osx ${UBSAN_CFLAGS})
+ filter_available_targets(UBSAN_TARGETS x86_64 i386)
+ set_target_properties(clang_rt.ubsan_osx PROPERTIES
+ OSX_ARCHITECTURES "${UBSAN_TARGETS}")
+ list(APPEND UBSAN_RUNTIME_LIBRARIES clang_rt.ubsan_osx)
+else()
+ # Build separate libraries for each target.
+ if(CAN_TARGET_X86_64)
+ add_library(clang_rt.ubsan-x86_64 STATIC
+ ${UBSAN_SOURCES}
+ $<TARGET_OBJECTS:RTSanitizerCommon.x86_64>
+ )
+ set_target_compile_flags(clang_rt.ubsan-x86_64
+ ${UBSAN_CFLAGS} ${TARGET_X86_64_CFLAGS}
+ )
+ list(APPEND UBSAN_RUNTIME_LIBRARIES clang_rt.ubsan-x86_64)
+ endif()
+ if(CAN_TARGET_I386)
+ add_library(clang_rt.ubsan-i386 STATIC
+ ${UBSAN_SOURCES}
+ $<TARGET_OBJECTS:RTSanitizerCommon.i386>
+ )
+ set_target_compile_flags(clang_rt.ubsan-i386
+ ${UBSAN_CFLAGS} ${TARGET_I386_CFLAGS}
+ )
+ list(APPEND UBSAN_RUNTIME_LIBRARIES clang_rt.ubsan-i386)
+ endif()
endif()
-if(CAN_TARGET_I386)
- add_library(clang_rt.ubsan-i386 STATIC
- ${UBSAN_SOURCES}
- $<TARGET_OBJECTS:RTSanitizerCommon.i386>
- )
- set_target_compile_flags(clang_rt.ubsan-i386
- ${UBSAN_CFLAGS} ${TARGET_I386_CFLAGS}
- )
- list(APPEND UBSAN_RUNTIME_LIBRARIES clang_rt.ubsan-i386)
-endif()
set_property(TARGET ${UBSAN_RUNTIME_LIBRARIES} APPEND PROPERTY
COMPILE_DEFINITIONS ${UBSAN_COMMON_DEFINITIONS})
diff --git a/compiler-rt/lib/ubsan/lit_tests/Integer/add-overflow.cpp b/compiler-rt/lib/ubsan/lit_tests/Integer/add-overflow.cpp
index 1b0a6d9c0b6..020ae767c60 100644
--- a/compiler-rt/lib/ubsan/lit_tests/Integer/add-overflow.cpp
+++ b/compiler-rt/lib/ubsan/lit_tests/Integer/add-overflow.cpp
@@ -17,7 +17,7 @@ int main() {
#ifdef ADD_I64
(void)(int64_t(8000000000000000000ll) + int64_t(2000000000000000000ll));
- // CHECK-ADD_I64: 8000000000000000000 + 2000000000000000000 cannot be represented in type 'long'
+ // CHECK-ADD_I64: 8000000000000000000 + 2000000000000000000 cannot be represented in type '{{long( long)?}}'
#endif
#ifdef ADD_I128
diff --git a/compiler-rt/lib/ubsan/lit_tests/Integer/sub-overflow.cpp b/compiler-rt/lib/ubsan/lit_tests/Integer/sub-overflow.cpp
index 38fc7b05575..ee431548f38 100644
--- a/compiler-rt/lib/ubsan/lit_tests/Integer/sub-overflow.cpp
+++ b/compiler-rt/lib/ubsan/lit_tests/Integer/sub-overflow.cpp
@@ -16,7 +16,7 @@ int main() {
#ifdef SUB_I64
(void)(int64_t(-8000000000000000000ll) - int64_t(2000000000000000000ll));
- // CHECK-SUB_I64: -8000000000000000000 - 2000000000000000000 cannot be represented in type 'long'
+ // CHECK-SUB_I64: -8000000000000000000 - 2000000000000000000 cannot be represented in type '{{long( long)?}}'
#endif
#ifdef SUB_I128
diff --git a/compiler-rt/lib/ubsan/lit_tests/TypeCheck/vptr.cpp b/compiler-rt/lib/ubsan/lit_tests/TypeCheck/vptr.cpp
index e9fffd5aefc..ee61e2c03bd 100644
--- a/compiler-rt/lib/ubsan/lit_tests/TypeCheck/vptr.cpp
+++ b/compiler-rt/lib/ubsan/lit_tests/TypeCheck/vptr.cpp
@@ -8,6 +8,9 @@
// RUN: %t mV 2>&1 | FileCheck %s --check-prefix=CHECK-MEMBER
// RUN: %t fV 2>&1 | FileCheck %s --check-prefix=CHECK-MEMFUN
+// FIXME: This test produces linker errors on Darwin.
+// XFAIL: darwin
+
struct S {
S() : a(0) {}
~S() {}
diff --git a/compiler-rt/lib/ubsan/lit_tests/lit.cfg b/compiler-rt/lib/ubsan/lit_tests/lit.cfg
index 50a8cbd601e..9fd3a1aeaa1 100644
--- a/compiler-rt/lib/ubsan/lit_tests/lit.cfg
+++ b/compiler-rt/lib/ubsan/lit_tests/lit.cfg
@@ -59,6 +59,7 @@ lit.load_config(config, compiler_rt_lit_cfg)
# Default test suffixes.
config.suffixes = ['.c', '.cc', '.cpp']
-# UndefinedBehaviorSanitizer tests are currently supported on Linux only.
-if config.host_os not in ['Linux']:
+# UndefinedBehaviorSanitizer tests are currently supported on
+# Linux and Darwin only.
+if config.host_os not in ['Linux', 'Darwin']:
config.unsupported = True
OpenPOWER on IntegriCloud