[gn] Make ubsan errors fatal, as in cmake
authorReid Kleckner <rnk@google.com>
Fri, 28 May 2021 03:00:20 +0000 (20:00 -0700)
committerReid Kleckner <rnk@google.com>
Fri, 28 May 2021 15:05:37 +0000 (08:05 -0700)
Apparently ubsan errors are non-fatal by default. If you introduce UB
into LLVM and run the tests, if errors are not fatal, the test will
still produce the expected output and the tests will pass. In order to
make ubsan errors show up as test failures, they have to be made fatal.
Pass the -fno-sanitize-recover=all flag to make it so.

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

llvm/utils/gn/build/BUILD.gn

index 757d0b6..a7531fa 100644 (file)
@@ -298,7 +298,7 @@ config("compiler_defaults") {
   if (use_ubsan) {
     assert(is_clang && current_os == "linux",
            "ubsan only supported on Linux/Clang")
-    cflags += [ "-fsanitize=undefined" ]
+    cflags += [ "-fsanitize=undefined", "-fno-sanitize-recover=all" ]
     ldflags += [ "-fsanitize=undefined" ]
   }