[llvm] 11a75e6 - [gn build] Allow option to build with asan/tsan/ubsan
Arthur Eubanks via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 23 11:25:04 PDT 2020
Author: Arthur Eubanks
Date: 2020-09-23T11:24:38-07:00
New Revision: 11a75e6c92c9bde26f3c925b25135c2461afac1c
URL: https://github.com/llvm/llvm-project/commit/11a75e6c92c9bde26f3c925b25135c2461afac1c
DIFF: https://github.com/llvm/llvm-project/commit/11a75e6c92c9bde26f3c925b25135c2461afac1c.diff
LOG: [gn build] Allow option to build with asan/tsan/ubsan
Reviewed By: thakis
Differential Revision: https://reviews.llvm.org/D88056
Added:
Modified:
llvm/utils/gn/build/BUILD.gn
llvm/utils/gn/build/buildflags.gni
Removed:
################################################################################
diff --git a/llvm/utils/gn/build/BUILD.gn b/llvm/utils/gn/build/BUILD.gn
index 3c0b905991b5..373d371f017b 100644
--- a/llvm/utils/gn/build/BUILD.gn
+++ b/llvm/utils/gn/build/BUILD.gn
@@ -235,6 +235,27 @@ config("compiler_defaults") {
]
}
}
+
+ 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") {
diff --git a/llvm/utils/gn/build/buildflags.gni b/llvm/utils/gn/build/buildflags.gni
index eb8ac55e48e0..b04eae19a784 100644
--- a/llvm/utils/gn/build/buildflags.gni
+++ b/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.
More information about the llvm-commits
mailing list