[UBSan] Embed UBSan into ASan runtime (Clang part).

Summary:
Change the way we use ASan and UBSan together. Instead of keeping two
separate runtimes (libclang_rt.asan and libclang_rt.ubsan), embed UBSan
into ASan and get rid of libclang_rt.ubsan. If UBSan is not supported on
a platform, all UBSan sources are just compiled into dummy empty object
files. UBSan initialization code (e.g. flag parsing) is directly called
from ASan initialization, so we are able to enforce correct
initialization order.

This mirrors the approach we already use for ASan+LSan. This change doesn't
modify the way we use standalone UBSan.

Test Plan: regression test suite

Reviewers: kubabrecka, zaks.anna, kcc, rsmith

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D8645

llvm-svn: 233860
diff --git a/clang/lib/Driver/ToolChains.cpp b/clang/lib/Driver/ToolChains.cpp
index 61a2ac6..658ffb6 100644
--- a/clang/lib/Driver/ToolChains.cpp
+++ b/clang/lib/Driver/ToolChains.cpp
@@ -338,6 +338,9 @@
                                     OS + "_dynamic.dylib").str(),
                     /*AlwaysLink*/ true, /*IsEmbedded*/ false,
                     /*AddRPath*/ true);
+  // Add explicit dependcy on -lc++abi, as -lc++ doesn't re-export
+  // all RTTI-related symbols that UBSan uses.
+  CmdArgs.push_back("-lc++abi");
 }
 
 void DarwinClang::AddLinkRuntimeLibArgs(const ArgList &Args,
@@ -401,9 +404,6 @@
           << "-fsanitize=undefined";
     } else {
       AddLinkSanitizerLibArgs(Args, CmdArgs, "ubsan");
-      // Add explicit dependcy on -lc++abi, as -lc++ doesn't re-export
-      // all RTTI-related symbols that UBSan uses.
-      CmdArgs.push_back("-lc++abi");
     }
   }