Get most of the code actually working with most sanitizers

Change-Id: Id55793ea135a317abe2e7207159b3e95e42dcf8a
diff --git a/tools/cpp/BUILD b/tools/cpp/BUILD
index 535ab0a..29ba1e1 100644
--- a/tools/cpp/BUILD
+++ b/tools/cpp/BUILD
@@ -40,13 +40,25 @@
     ':cc-compiler-roborio',
     '@arm-frc-linux-gnueabi-repo//:compiler_components',
     ':roborio-compiler-files',
+    ':flags_compiler_inputs',
+  ],
+)
+
+# Compiler inputs given by --copt etc in //tools:bazel.rc.
+filegroup(
+  name = 'flags_compiler_inputs',
+  # TODO(Brian): Change this to a select which only has the right files under
+  # the right configurations once that works.
+  srcs = [
+    'asan-blacklist',
+    'ubsan-blacklist',
   ],
 )
 
 cc_toolchain(
   name = 'cc-compiler-k8',
-  all_files = ':empty',
-  compiler_files = ':empty',
+  all_files = ':flags_compiler_inputs',
+  compiler_files = ':flags_compiler_inputs',
   cpu = 'local',
   dwp_files = ':empty',
   dynamic_runtime_libs = [':empty'],
@@ -63,6 +75,7 @@
     '//tools/cpp/arm-frc-linux-gnueabi:tool-wrappers',
     '//tools/cpp/arm-frc-linux-gnueabi:as',
     '@arm-frc-linux-gnueabi-repo//:compiler_pieces',
+    ':flags_compiler_inputs',
   ],
 )
 
diff --git a/tools/cpp/asan-blacklist b/tools/cpp/asan-blacklist
new file mode 100644
index 0000000..37191ea
--- /dev/null
+++ b/tools/cpp/asan-blacklist
@@ -0,0 +1,4 @@
+# Ignore issues with initialization order for gflags mutexes.
+# They (at least try to) work around any issues with complicated stuff explained
+# in a comment at the top of //third_party/gflags/src/mutex.h.
+type:gflags_mutex_namespace::Mutex=init
diff --git a/tools/cpp/ubsan-blacklist b/tools/cpp/ubsan-blacklist
new file mode 100644
index 0000000..ca3d7dd
--- /dev/null
+++ b/tools/cpp/ubsan-blacklist
@@ -0,0 +1,10 @@
+# Known bug in here (operators for std::_Ios_Fmtflags) with
+# invalid enum values in the libstdc++ implementation.
+# TODO(Brian): Remove this once the bug gets fixed.
+fun:_ZSt*St13_Ios_FmtflagsS_
+
+# Known bug in libstdc++'s ::std::map::end...
+# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60734
+# TODO(Brian): Remove this once the bug gets fixed.
+fun:_ZNSt8_Rb_tree*endEv
+fun:*Rb_tree_iterator*