[PATCH] D88056: [gn build] Allow option to build with asan/tsan/ubsan

Arthur Eubanks via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 23 11:25:14 PDT 2020


This revision was automatically updated to reflect the committed changes.
Closed by commit rG11a75e6c92c9: [gn build] Allow option to build with asan/tsan/ubsan (authored by aeubanks).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D88056/new/

https://reviews.llvm.org/D88056

Files:
  llvm/utils/gn/build/BUILD.gn
  llvm/utils/gn/build/buildflags.gni


Index: llvm/utils/gn/build/buildflags.gni
===================================================================
--- llvm/utils/gn/build/buildflags.gni
+++ llvm/utils/gn/build/buildflags.gni
@@ -1,6 +1,15 @@
 declare_args() {
   # Whether to build with debug information.
   is_debug = false
+
+  # Whether to build with tsan.
+  use_tsan = false
+
+  # Whether to build with ubsan.
+  use_ubsan = false
+
+  # Whether to build with asan.
+  use_asan = false
 }
 
 # args that depend on other args must live in a later declare_args() block.
Index: llvm/utils/gn/build/BUILD.gn
===================================================================
--- llvm/utils/gn/build/BUILD.gn
+++ llvm/utils/gn/build/BUILD.gn
@@ -235,6 +235,27 @@
       ]
     }
   }
+
+  if (use_ubsan) {
+    assert(is_clang && current_os == "linux",
+           "ubsan only supported on Linux/Clang")
+    cflags += [ "-fsanitize=undefined" ]
+    ldflags += [ "-fsanitize=undefined" ]
+  }
+
+  if (use_asan) {
+    assert(is_clang && current_os == "linux",
+           "asan only supported on Linux/Clang")
+    cflags += [ "-fsanitize=address" ]
+    ldflags += [ "-fsanitize=address" ]
+  }
+
+  if (use_tsan) {
+    assert(is_clang && current_os == "linux",
+           "tsan only supported on Linux/Clang")
+    cflags += [ "-fsanitize=thread" ]
+    ldflags += [ "-fsanitize=thread" ]
+  }
 }
 
 config("no_exceptions") {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D88056.293810.patch
Type: text/x-patch
Size: 1398 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200923/5ad25988/attachment.bin>


More information about the llvm-commits mailing list