summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexey Samsonov <vonosmas@gmail.com>2014-08-29 00:50:36 +0000
committerAlexey Samsonov <vonosmas@gmail.com>2014-08-29 00:50:36 +0000
commit4ee2675dfea34926a75dfb61f9ced6a79c7d7eb5 (patch)
tree52350b92194ac384b10d078006fd0e6eb923fdf8
parent77bc09f5ab4433cbb0ab9a6c2a75ece1ff241537 (diff)
downloadbcm5719-llvm-4ee2675dfea34926a75dfb61f9ced6a79c7d7eb5.tar.gz
bcm5719-llvm-4ee2675dfea34926a75dfb61f9ced6a79c7d7eb5.zip
Introduce -DLLVM_USE_SANITIZER=Undefined CMake option to build UBSan-ified version of LLVM/Clang.
I've fixed most of the simple bugs and currently "check-llvm" test suite has 26 failures, and "check-clang" suite has 5 failures. llvm-svn: 216701
-rw-r--r--clang/test/lit.cfg2
-rw-r--r--llvm/cmake/modules/HandleLLVMOptions.cmake4
-rw-r--r--llvm/docs/CMake.rst4
-rw-r--r--llvm/test/lit.cfg2
4 files changed, 8 insertions, 4 deletions
diff --git a/clang/test/lit.cfg b/clang/test/lit.cfg
index b5c5628a580..2d946c5a65d 100644
--- a/clang/test/lit.cfg
+++ b/clang/test/lit.cfg
@@ -116,7 +116,7 @@ for symbolizer in ['ASAN_SYMBOLIZER_PATH', 'MSAN_SYMBOLIZER_PATH']:
config.environment[symbolizer] = os.environ[symbolizer]
# Propagate options for sanitizers.
-for options in ['ASAN_OPTIONS']:
+for options in ['ASAN_OPTIONS', 'UBSAN_OPTIONS']:
if options in os.environ:
config.environment[options] = os.environ[options]
diff --git a/llvm/cmake/modules/HandleLLVMOptions.cmake b/llvm/cmake/modules/HandleLLVMOptions.cmake
index d17ce11fe9f..2fcdfbefd15 100644
--- a/llvm/cmake/modules/HandleLLVMOptions.cmake
+++ b/llvm/cmake/modules/HandleLLVMOptions.cmake
@@ -363,6 +363,10 @@ if(LLVM_USE_SANITIZER)
if(LLVM_USE_SANITIZER STREQUAL "MemoryWithOrigins")
append("-fsanitize-memory-track-origins" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
endif()
+ elseif (LLVM_USE_SANITIZER STREQUAL "Undefined")
+ append_common_sanitizer_flags()
+ append("-fsanitize=undefined -fno-sanitize=vptr -fno-sanitize-recover"
+ CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
else()
message(WARNING "Unsupported value of LLVM_USE_SANITIZER: ${LLVM_USE_SANITIZER}")
endif()
diff --git a/llvm/docs/CMake.rst b/llvm/docs/CMake.rst
index 1da123419dc..4a5165b7a13 100644
--- a/llvm/docs/CMake.rst
+++ b/llvm/docs/CMake.rst
@@ -288,8 +288,8 @@ LLVM-specific variables
**LLVM_USE_SANITIZER**:STRING
Define the sanitizer used to build LLVM binaries and tests. Possible values
- are ``Address``, ``Memory`` and ``MemoryWithOrigins``. Defaults to empty
- string.
+ are ``Address``, ``Memory``, ``MemoryWithOrigins`` and ``Undefined``.
+ Defaults to empty string.
**LLVM_BUILD_DOCS**:BOOL
Enables all enabled documentation targets (i.e. Doxgyen and Sphinx targets) to
diff --git a/llvm/test/lit.cfg b/llvm/test/lit.cfg
index b5a982c02d5..fefba5257cb 100644
--- a/llvm/test/lit.cfg
+++ b/llvm/test/lit.cfg
@@ -96,7 +96,7 @@ for symbolizer in ['ASAN_SYMBOLIZER_PATH', 'MSAN_SYMBOLIZER_PATH']:
config.environment[symbolizer] = os.environ[symbolizer]
# Propagate options for sanitizers.
-for options in ['ASAN_OPTIONS']:
+for options in ['ASAN_OPTIONS', 'UBSAN_OPTIONS']:
if options in os.environ:
config.environment[options] = os.environ[options]
OpenPOWER on IntegriCloud