From: Arthur Eubanks Date: Mon, 21 Sep 2020 23:28:21 +0000 (-0700) Subject: [gn build] Allow option to build with asan/tsan/ubsan X-Git-Tag: llvmorg-13-init~11134 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=11a75e6c92c9bde26f3c925b25135c2461afac1c;p=platform%2Fupstream%2Fllvm.git [gn build] Allow option to build with asan/tsan/ubsan Reviewed By: thakis Differential Revision: https://reviews.llvm.org/D88056 --- diff --git a/llvm/utils/gn/build/BUILD.gn b/llvm/utils/gn/build/BUILD.gn index 3c0b905..373d371 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 eb8ac55..b04eae1 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.