Don't define _HAS_EXCEPTIONS to 0 with libc++.

libc++ uses a predefined macro to control whether to use exceptions, so
defining this macro is unnecessary. Defining _HAS_EXCEPTIONS to 0 also
breaks libc++ because it depends on MSVC headers that only provide
certain declarations if _HAS_EXCEPTIONS is 1.

Bug: chromium:801780
Change-Id: I0d0c04e55e1e91c3ce7fe90d15b55de0cd7a21ac
Reviewed-on: https://swiftshader-review.googlesource.com/16688
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Peter Collingbourne <pcc@google.com>
diff --git a/BUILD.gn b/BUILD.gn
index 9404d0b..7af9f6a 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -12,6 +12,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+import("//build/config/c++/c++.gni")
 import("//build/config/compiler/compiler.gni")
 
 config("swiftshader_config") {
@@ -26,8 +27,18 @@
       "/Gd",  # Default calling convention
     ]
 
+    if (!use_custom_libcxx) {
+      # Disable EH usage in STL headers.
+      # libc++ uses a predefined macro to control whether to use exceptions, so
+      # defining this macro is unnecessary. Defining _HAS_EXCEPTIONS to 0 also
+      # breaks libc++ because it depends on MSVC headers that only provide
+      # certain declarations if _HAS_EXCEPTIONS is 1.
+      defines += [
+        "_HAS_EXCEPTIONS=0",
+      ]
+    }
+
     defines += [
-      "_HAS_EXCEPTIONS=0",  # Disable EH usage in STL headers
       "_CRT_SECURE_NO_DEPRECATE",
       "NOMINMAX",
       "_WINDLL",