[llvm] 52554f7 - [gn build] Allow use_ubsan=true on mac and unbreak use_asan, use_tsan, use_ubsan

Nico Weber via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 15 16:41:21 PDT 2022


Author: Nico Weber
Date: 2022-06-15T19:34:35-04:00
New Revision: 52554f731514526ffa33eeda149f9b7ed55ba81f

URL: https://github.com/llvm/llvm-project/commit/52554f731514526ffa33eeda149f9b7ed55ba81f
DIFF: https://github.com/llvm/llvm-project/commit/52554f731514526ffa33eeda149f9b7ed55ba81f.diff

LOG: [gn build] Allow use_ubsan=true on mac and unbreak use_asan, use_tsan, use_ubsan

`use_ubsan=true` seems to Just Work on macOS, so allow it.

https://reviews.llvm.org/D122862 broke use_asan=true, use_tsan=true, and
use_ubsan=true builds on Linux too. This makes this go again by explicitly
disabling asan, tsan, and ubsan for the baremetal part of the build. See
discussion on https://reviews.llvm.org/D122862 for other possible approaches.

Differential Revision: https://reviews.llvm.org/D127906

Added: 
    

Modified: 
    llvm/utils/gn/build/BUILD.gn
    llvm/utils/gn/build/toolchain/BUILD.gn

Removed: 
    


################################################################################
diff  --git a/llvm/utils/gn/build/BUILD.gn b/llvm/utils/gn/build/BUILD.gn
index 252ceff287d3b..3c462d4351887 100644
--- a/llvm/utils/gn/build/BUILD.gn
+++ b/llvm/utils/gn/build/BUILD.gn
@@ -334,8 +334,9 @@ config("compiler_defaults") {
       "goma needs a sysroot: run `llvm/utils/sysroot.py make-fake --out-dir=sysroot` and add `sysroot = \"//sysroot\"` to your args.gn")
 
   if (use_ubsan) {
-    assert(is_clang && current_os == "linux",
-           "ubsan only supported on Linux/Clang")
+    assert(is_clang && (current_os == "ios" || current_os == "linux" ||
+                            current_os == "mac"),
+           "ubsan only supported on iOS/Clang, Linux/Clang, or macOS/Clang")
     cflags += [
       "-fsanitize=undefined",
       "-fno-sanitize-recover=all",
@@ -346,7 +347,7 @@ config("compiler_defaults") {
   if (use_asan) {
     assert(is_clang && (current_os == "ios" || current_os == "linux" ||
                             current_os == "mac"),
-           "asan only supported on iOS/Clang, Linux/Clang, and macOS/Clang")
+           "asan only supported on iOS/Clang, Linux/Clang, or macOS/Clang")
     cflags += [ "-fsanitize=address" ]
     ldflags += [ "-fsanitize=address" ]
   }

diff  --git a/llvm/utils/gn/build/toolchain/BUILD.gn b/llvm/utils/gn/build/toolchain/BUILD.gn
index 29da00c29fcad..81408115b225c 100644
--- a/llvm/utils/gn/build/toolchain/BUILD.gn
+++ b/llvm/utils/gn/build/toolchain/BUILD.gn
@@ -253,6 +253,12 @@ stage2_unix_toolchain("stage2_baremetal_aarch64") {
   toolchain_args = {
     current_os = "baremetal"
     current_cpu = "arm64"
+
+    # FIXME: These should be set in all toolchains building sanitizers,
+    # see discussion at https://reviews.llvm.org/D127906#3587329
+    use_asan = false
+    use_tsan = false
+    use_ubsan = false
   }
 }
 


        


More information about the llvm-commits mailing list