[build] Fix host_asan-ubsan build of the library.

It looks like many executables in this project are buggy and will
either leak memory or perform undefined behavior, which makes
host_asan-ubsan builds fail miserably.

This CL adds `exclude_toolchain_variants` definitions to prevent
said executables to be compiled with asan or ubsan enabling variants,
which allows the build (and running of said executable) to work
properly.

Bug: 122698
Change-Id: Ib0a7c417a7199f4323ec37676d8022fc7897fb56
Reviewed-on: https://fuchsia-review.googlesource.com/c/third_party/yasm/+/811669
Reviewed-by: Tamir Duberstein <tamird@google.com>
diff --git a/BUILD.gn b/BUILD.gn
index ce75903..1ffbf34 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -43,6 +43,7 @@
     defines = [ "HAVE_CONFIG_H" ]
     cflags = [
       "-std=gnu99",
+
       # yasm does not comply with -Wimplicit-fallthrough, so disable it.
       "-Wno-implicit-fallthrough",
       "-Wno-unused-but-set-variable",
@@ -70,6 +71,12 @@
     configs += [ ":yasm_config" ]
 
     deps = [ ":yasm_utils" ]
+
+    # Required because this tool leaks memory.
+    exclude_toolchain_tags = [
+      "asan",
+      "lsan",
+    ]
   }
 
   # Used by both yasm and genperf binaries.
@@ -132,6 +139,10 @@
       ":yasm_config",
       ":re2c_warnings",
     ]
+
+    # Required because this triggers undefined behavior error:
+    # scanner.re:49:18: runtime error: null pointer passed as argument 2, which is declared to never be null
+    exclude_toolchain_tags = [ "ubsan" ]
   }
 
   config("yasm_warnings") {
@@ -140,6 +151,7 @@
         # reg3264type in x86expr.c is unused.
         "-Wno-unused-local-typedef",
         "-Wno-null-pointer-arithmetic",
+
         # yasm does not comply with -Wnull-pointer-subtraction, so disable it.
         "-Wno-null-pointer-subtraction",
       ]
@@ -262,6 +274,10 @@
       ":generate_version",
       ":yasm_utils",
     ]
+
+    # This tool generates ubsan errors:
+    # ../../third_party/yasm/libyasm/bitvect.c:404:37: runtime error: left shift of negative value -1
+    exclude_toolchain_tags = [ "ubsan" ]
   }
 
   compiled_action_foreach("compile_gperf") {