[libcxx-commits] [PATCH] D78390: [dfsan] Add dataflow option to LLVM_USE_SANITIZER
Zola Bridges via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Fri Apr 17 11:20:35 PDT 2020
zbrid created this revision.
zbrid added a reviewer: morehouse.
Herald added subscribers: libcxx-commits, cfe-commits, mgorny.
Herald added projects: clang, libc++.
Herald added a reviewer: libc++.
zbrid added a reviewer: EricWF.
zbrid edited the summary of this revision.
This patch add the dataflow option to LLVM_USE_SANITIZER and documents
it.
I tested this manually by trying it out on my set up. Let me know if that's not sufficient.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D78390
Files:
clang/docs/DataFlowSanitizer.rst
libcxx/CMakeLists.txt
llvm/cmake/modules/HandleLLVMOptions.cmake
llvm/docs/CMake.rst
Index: llvm/docs/CMake.rst
===================================================================
--- llvm/docs/CMake.rst
+++ llvm/docs/CMake.rst
@@ -422,7 +422,7 @@
**LLVM_USE_SANITIZER**:STRING
Define the sanitizer used to build LLVM binaries and tests. Possible values
are ``Address``, ``Memory``, ``MemoryWithOrigins``, ``Undefined``, ``Thread``,
- and ``Address;Undefined``. Defaults to empty string.
+ ``DataFlow``, and ``Address;Undefined``. Defaults to empty string.
**LLVM_ENABLE_LTO**:STRING
Add ``-flto`` or ``-flto=`` flags to the compile and link command
Index: llvm/cmake/modules/HandleLLVMOptions.cmake
===================================================================
--- llvm/cmake/modules/HandleLLVMOptions.cmake
+++ llvm/cmake/modules/HandleLLVMOptions.cmake
@@ -728,6 +728,8 @@
elseif (LLVM_USE_SANITIZER STREQUAL "Thread")
append_common_sanitizer_flags()
append("-fsanitize=thread" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
+ elseif (LLVM_USE_SANITIZER STREQUAL "DataFlow")
+ append("-fsanitize=dataflow" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
elseif (LLVM_USE_SANITIZER STREQUAL "Address;Undefined" OR
LLVM_USE_SANITIZER STREQUAL "Undefined;Address")
append_common_sanitizer_flags()
Index: libcxx/CMakeLists.txt
===================================================================
--- libcxx/CMakeLists.txt
+++ libcxx/CMakeLists.txt
@@ -682,6 +682,8 @@
append_flags(SANITIZER_FLAGS "-fsanitize=address,undefined -fno-sanitize=vptr,function -fno-sanitize-recover=all")
elseif (USE_SANITIZER STREQUAL "Thread")
append_flags(SANITIZER_FLAGS -fsanitize=thread)
+ elseif (USE_SANITIZER STREQUAL "DataFlow")
+ append_flags(SANITIZER_FLAGS -fsanitize=dataflow)
else()
message(WARNING "Unsupported value of LLVM_USE_SANITIZER: ${USE_SANITIZER}")
endif()
Index: clang/docs/DataFlowSanitizer.rst
===================================================================
--- clang/docs/DataFlowSanitizer.rst
+++ clang/docs/DataFlowSanitizer.rst
@@ -20,6 +20,26 @@
dynamic data flow analysis framework to be used by clients to help
detect application-specific issues within their own code.
+How to build
+============
+
+Build LLVM/Clang with `CMake <https://llvm.org/docs/CMake.html>`_.
+
+To build libc++ and the libc++ ABI with data flow sanitizer instrumentation:
+
+.. code-block:: console
+ cd libcxx-build
+
+ # An example using ninja
+ cmake -GNinja path/to/llvm-project/llvm \
+ -DCMAKE_C_COMPILER=clang \
+ -DCMAKE_CXX_COMPILER=clang++ \
+ -DLLVM_USE_SANITIZER="DataFlow" \
+ -DLLVM_ENABLE_LIBCXX=ON \
+ -DLLVM_ENABLE_PROJECTS="libcxx;libcxxabi"
+
+ ninja cxx cxxabi
+
Usage
=====
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D78390.258378.patch
Type: text/x-patch
Size: 2712 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20200417/b0992193/attachment-0001.bin>
More information about the libcxx-commits
mailing list