[PATCH] D89439: [cmake] Add LLVM_UBSAN_FLAGS, to allow overriding UBSan flags
Vedant Kumar via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 26 15:48:37 PDT 2020
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG905f874c449c: [cmake] Add LLVM_UBSAN_FLAGS, to allow overriding UBSan flags (authored by vsk).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D89439/new/
https://reviews.llvm.org/D89439
Files:
llvm/CMakeLists.txt
llvm/cmake/modules/HandleLLVMOptions.cmake
llvm/docs/CMake.rst
Index: llvm/docs/CMake.rst
===================================================================
--- llvm/docs/CMake.rst
+++ llvm/docs/CMake.rst
@@ -428,6 +428,11 @@
are ``Address``, ``Memory``, ``MemoryWithOrigins``, ``Undefined``, ``Thread``,
``DataFlow``, and ``Address;Undefined``. Defaults to empty string.
+**LLVM_UBSAN_FLAGS**:STRING
+ Defines the set of compile flags used to enable UBSan. Only used if
+ ``LLVM_USE_SANITIZER`` contains ``Undefined``. This can be used to override
+ the default set of UBSan flags.
+
**LLVM_ENABLE_LTO**:STRING
Add ``-flto`` or ``-flto=`` flags to the compile and link command
lines, enabling link-time optimization. Possible values are ``Off``,
Index: llvm/cmake/modules/HandleLLVMOptions.cmake
===================================================================
--- llvm/cmake/modules/HandleLLVMOptions.cmake
+++ llvm/cmake/modules/HandleLLVMOptions.cmake
@@ -776,8 +776,7 @@
endif()
elseif (LLVM_USE_SANITIZER STREQUAL "Undefined")
append_common_sanitizer_flags()
- append("-fsanitize=undefined -fno-sanitize=vptr,function -fno-sanitize-recover=all"
- CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
+ append("${LLVM_UBSAN_FLAGS}" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
elseif (LLVM_USE_SANITIZER STREQUAL "Thread")
append_common_sanitizer_flags()
append("-fsanitize=thread" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
@@ -786,8 +785,8 @@
elseif (LLVM_USE_SANITIZER STREQUAL "Address;Undefined" OR
LLVM_USE_SANITIZER STREQUAL "Undefined;Address")
append_common_sanitizer_flags()
- append("-fsanitize=address,undefined -fno-sanitize=vptr,function -fno-sanitize-recover=all"
- CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
+ append("-fsanitize=address" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
+ append("${LLVM_UBSAN_FLAGS}" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
elseif (LLVM_USE_SANITIZER STREQUAL "Leaks")
append_common_sanitizer_flags()
append("-fsanitize=leak" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
Index: llvm/CMakeLists.txt
===================================================================
--- llvm/CMakeLists.txt
+++ llvm/CMakeLists.txt
@@ -487,6 +487,10 @@
set(LLVM_USE_SANITIZER "" CACHE STRING
"Define the sanitizer used to build binaries and tests.")
option(LLVM_OPTIMIZE_SANITIZED_BUILDS "Pass -O1 on debug sanitizer builds" ON)
+set(LLVM_UBSAN_FLAGS
+ "-fsanitize=undefined -fno-sanitize=vptr,function -fno-sanitize-recover=all"
+ CACHE STRING
+ "Compile flags set to enable UBSan. Only used if LLVM_USE_SANITIZER contains 'Undefined'.")
set(LLVM_LIB_FUZZING_ENGINE "" CACHE PATH
"Path to fuzzing library for linking with fuzz targets")
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D89439.300814.patch
Type: text/x-patch
Size: 2686 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201026/e5053236/attachment.bin>
More information about the llvm-commits
mailing list