[PATCH] D95750: [CMake] [MinGW] Enable use of LLVM_USE_SANITIZER in a MinGW environment
Markus Böck via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sat Jan 30 15:45:01 PST 2021
zero9178 created this revision.
zero9178 added reviewers: mstorsjo, thieta, mati865.
Herald added a subscriber: mgorny.
zero9178 requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Currently using LLVM_USE_SANITIZER with a MinGW target leads to a fatal configuration error due to an unsupported platform. MinGW targets on clang however implement a few sanitizers, currently ASAN and UBSAN.
This patch enables LLVM_USE_SANITIZER in a MinGW environment as well.
If accepted I'd need this patch to be committed for me with the email: markus.boeck02 at gmail.com
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D95750
Files:
llvm/cmake/modules/HandleLLVMOptions.cmake
Index: llvm/cmake/modules/HandleLLVMOptions.cmake
===================================================================
--- llvm/cmake/modules/HandleLLVMOptions.cmake
+++ llvm/cmake/modules/HandleLLVMOptions.cmake
@@ -793,6 +793,21 @@
else()
message(FATAL_ERROR "Unsupported value of LLVM_USE_SANITIZER: ${LLVM_USE_SANITIZER}")
endif()
+ elseif(MINGW)
+ if (LLVM_USE_SANITIZER STREQUAL "Address")
+ append_common_sanitizer_flags()
+ append("-fsanitize=address" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
+ elseif (LLVM_USE_SANITIZER STREQUAL "Undefined")
+ append_common_sanitizer_flags()
+ append("${LLVM_UBSAN_FLAGS}" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
+ elseif (LLVM_USE_SANITIZER STREQUAL "Address;Undefined" OR
+ LLVM_USE_SANITIZER STREQUAL "Undefined;Address")
+ append_common_sanitizer_flags()
+ append("-fsanitize=address" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
+ append("${LLVM_UBSAN_FLAGS}" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
+ else()
+ message(FATAL_ERROR "This sanitizer not yet supported in a MinGW environment: ${LLVM_USE_SANITIZER}")
+ endif()
elseif(MSVC)
if (LLVM_USE_SANITIZER STREQUAL "Address")
append_common_sanitizer_flags()
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D95750.320327.patch
Type: text/x-patch
Size: 1216 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210130/5051c689/attachment.bin>
More information about the llvm-commits
mailing list