Enable in-tree libc++ builds on iOS

Binary size regression of about 109kB is expected -- please add
thomasanderson@ and thakis@ to the bug.

BUG=945054
R=thakis

Change-Id: Iaca4178e3b23b55a36af55d119d2eda2b76ef71d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1534897
Commit-Queue: Thomas Anderson <thomasanderson@chromium.org>
Auto-Submit: Thomas Anderson <thomasanderson@chromium.org>
Reviewed-by: Justin Cohen <justincohen@chromium.org>
Reviewed-by: Rohit Rao <rohitrao@chromium.org>
Reviewed-by: Nico Weber <thakis@chromium.org>
Cr-Original-Commit-Position: refs/heads/master@{#645001}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: dd9e27c0290618d32f50486ddb271704eab69999
diff --git a/third_party/libc++/BUILD.gn b/third_party/libc++/BUILD.gn
index 02a501a..a021562 100644
--- a/third_party/libc++/BUILD.gn
+++ b/third_party/libc++/BUILD.gn
@@ -122,7 +122,9 @@
     defines += [ "_LIBCPP_EXTERN_TEMPLATE_TYPE_VIS=__attribute__((__visibility__(\"default\")))" ]
   }
   if (!libcxx_is_shared) {
-    if (is_mac && is_clang) {
+    # TODO(https://crbug.com/946629): Remove use_xcode_clang condition once
+    # XCode clang is updated to support -fvisibility-global-new-delete-hidden.
+    if ((is_mac || (is_ios && !use_xcode_clang)) && is_clang) {
       # We want operator new/delete to be private on Mac, but these functions
       # are implicitly created by the compiler for each translation unit, as
       # specified in the C++ spec 3.7.4p2, which makes them always have default
@@ -149,7 +151,7 @@
       ]
     }
   }
-  if (!is_mac && (is_asan || is_tsan || is_msan)) {
+  if (!is_mac && !is_ios && (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
diff --git a/third_party/libc++abi/BUILD.gn b/third_party/libc++abi/BUILD.gn
index 8949236..e571b86 100644
--- a/third_party/libc++abi/BUILD.gn
+++ b/third_party/libc++abi/BUILD.gn
@@ -56,7 +56,7 @@
 
   # This file should really be included on linux as well, but that
   # would introduce an unwanted glibc 2.18 dependency.
-  if (is_fuchsia || (is_posix && !is_mac && !is_linux)) {
+  if (is_fuchsia || (is_posix && !is_mac && !is_ios && !is_linux)) {
     sources += [ "trunk/src/cxa_thread_atexit.cpp" ]
   }