Enable _LIBCPP_DEBUG in Clang for non-Xcode-based debug builds.

Unlike _GLIBCXX_DEBUG, this is meant to not break the ABI.
The libc++ bundled with Xcode does not contain debug symbols so we need
to disable these checks on Mac/iOS.

Change-Id: Ie4f18e247db9c405b2ce45f388c41dcac8104815
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/297874
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
diff --git a/gn/BUILD.gn b/gn/BUILD.gn
index 894d312..2df0c26 100644
--- a/gn/BUILD.gn
+++ b/gn/BUILD.gn
@@ -60,6 +60,14 @@
     }
   }
 
+  if (is_debug) {
+    if (is_ios || is_mac) {
+      # The libc++ that ships with Xcode does not contain _LIBCPP_DEBUG symbols.
+    } else {
+      defines += [ "_LIBCPP_DEBUG=1" ]  # Asserts and iterator debugging.
+    }
+  }
+
   # Disable warnings about unknown attributes.
   # (These unknown attribute warnings are on by default, so we don't make
   # disabling them part of :warnings, as some targets remove :warnings.)