Merge "Revert "Remove libcpp_is_static""
diff --git a/third_party/libc++/BUILD.gn b/third_party/libc++/BUILD.gn
index fc2dac0..6cd5a55 100644
--- a/third_party/libc++/BUILD.gn
+++ b/third_party/libc++/BUILD.gn
@@ -18,8 +18,13 @@
   }
 }
 
-component("libc++") {
-  if (is_component_build) {
+if (libcpp_is_static) {
+  link_target_type = "source_set"
+} else {
+  link_target_type = "shared_library"
+}
+target(link_target_type, "libc++") {
+  if (!libcpp_is_static) {
     no_default_deps = true
   }
   sources = [
@@ -67,7 +72,7 @@
     "//build/config/compiler:no_rtti",
     "//build/config/coverage:default_coverage",
   ]
-  if (is_android && is_component_build) {
+  if (is_android && !libcpp_is_static) {
     configs -= [ "//build/config/android:hide_all_but_jni_onload" ]
   }
   configs += [
@@ -79,14 +84,14 @@
   ]
 
   defines = [ "_LIBCPP_BUILDING_LIBRARY" ]
-  if (!is_clang && is_component_build) {
+  if (!is_clang && !libcpp_is_static) {
     # This is a temporary workaround to get libc++ builds working with
     # gcc.  It can be removed with either
     # https://reviews.llvm.org/D35326 or
     # https://reviews.llvm.org/D35388 lands.
     defines += [ "_LIBCPP_EXTERN_TEMPLATE_TYPE_VIS=__attribute__((__visibility__(\"default\")))" ]
   }
-  if (!is_component_build) {
+  if (libcpp_is_static) {
     defines += [
       # This resets the visibility to default only for the various
       # flavors of operator new and operator delete.  These symbols
@@ -105,13 +110,6 @@
       "_LIBCPP_OVERRIDABLE_FUNC_VIS=__attribute__((__visibility__(\"default\")))",
     ]
   }
-  if (is_asan || is_tsan || is_msan) {
-    # In {a,t,m}san configurations, operator new and operator delete will be
-    # provided by the sanitizer runtime library.  Since libc++ defines these
-    # symbols with weak linkage, and the *san runtime uses strong linkage, it
-    # should technically be OK to omit this, but it's added to be explicit.
-    defines += [ "_LIBCPP_DISABLE_NEW_DELETE_DEFINITIONS" ]
-  }
 
   if (!is_win) {
     defines += [ "LIBCXX_BUILDING_LIBCXXABI" ]
diff --git a/third_party/libc++abi/BUILD.gn b/third_party/libc++abi/BUILD.gn
index ca12381..50dc8ae 100644
--- a/third_party/libc++abi/BUILD.gn
+++ b/third_party/libc++abi/BUILD.gn
@@ -14,7 +14,6 @@
     # Fuchsia builds don't link against any libraries that provide stack
     # unwinding symbols, unlike Linux does with glibc.  Build and link against
     # libunwind manually to get this functionality.
-    # TODO(thomasanderson): Move this to exe_and_shlib_deps.
     if (is_fuchsia) {
       deps += [ "//buildtools/third_party/libunwind" ]
     }
@@ -25,6 +24,7 @@
       "trunk/src/cxa_default_handlers.cpp",
       "trunk/src/cxa_exception.cpp",
       "trunk/src/cxa_exception_storage.cpp",
+      "trunk/src/cxa_guard.cpp",
       "trunk/src/cxa_handlers.cpp",
 
       # This file is supposed to be used in fno-exception builds of
@@ -41,10 +41,6 @@
       "trunk/src/stdlib_typeinfo.cpp",
     ]
 
-    if (!is_tsan) {
-      sources += [ "trunk/src/cxa_guard.cpp" ]
-    }
-
     # See the comment in cxa_demangle_stub.cc for why we don't use LLVM's
     # demangler on android.
     if (is_android) {
@@ -85,7 +81,7 @@
   # use_custom_libcxx=true.  When this happens, this target can be removed,
   # cxa_demangle_stub.cc can be added to the libc++abi target above, and
   # __cxa_demangle can simply be annoted with _LIBCXXABI_FUNC_VIS.
-  if (use_custom_libcxx && is_component_build) {
+  if (use_custom_libcxx && !libcpp_is_static) {
     defines = [ "EXPORT_CXA_DEMANGLE" ]
   }
   sources = [ "cxa_demangle_stub.cc" ]