[clang] [Sanitizer][Docs] Improve docs on building Asan (PR #68636)

Aiden Grossman via cfe-commits cfe-commits at lists.llvm.org
Mon Oct 9 14:36:41 PDT 2023


https://github.com/boomanaiden154 created https://github.com/llvm/llvm-project/pull/68636

Currently the documentation for building Asan doesn't specify that compiler-rt needs to be built as well. In addition, there's no minimal example for the LLVM CMake configuration. This patch addresses both of these issues.

The lack of specification about building compiler-rt has shown up on Discourse (e.g., https://discourse.llvm.org/t/enabling-address-sanitizer/73940/2).

>From 49d010d28ba10ba86c58e8cd71e9c5af35a7c9e7 Mon Sep 17 00:00:00 2001
From: Aiden Grossman <agrossman154 at yahoo.com>
Date: Mon, 9 Oct 2023 11:11:18 -0700
Subject: [PATCH] [Sanitizer][Docs] Improve docs on building Asan

Currently the documentation for building Asan doesn't specify that
compiler-rt needs to be built as well. In addition, there's no minimal
example for the LLVM CMake configuration. This patch addresses both of
these issues.
---
 clang/docs/AddressSanitizer.rst | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/clang/docs/AddressSanitizer.rst b/clang/docs/AddressSanitizer.rst
index 37f34cb0cc9936d..94ff3404cba6024 100644
--- a/clang/docs/AddressSanitizer.rst
+++ b/clang/docs/AddressSanitizer.rst
@@ -26,7 +26,16 @@ Typical slowdown introduced by AddressSanitizer is **2x**.
 How to build
 ============
 
-Build LLVM/Clang with `CMake <https://llvm.org/docs/CMake.html>`_.
+Build LLVM/Clang with `CMake <https://llvm.org/docs/CMake.html>` and enable
+the ``compiler-rt`` runtime. An example CMake configuration that will allow
+for the use/testing of AddressSanitizer:
+
+.. code-block:: console
+
+   cmake -DCMAKE_BUILD_TYPE=Release \
+     -DLLVM_ENABLE_PROJECTS="clang" \
+     -DLLVM_ENABLE_RUNTIMES="compiler-rt" \
+     ../llvm
 
 Usage
 =====



More information about the cfe-commits mailing list