Remove unnecessary flags from BUILD.gn

The GN build gets many default flags from //build/config. Remove
flags that are redundant with the default flags.

No intended behavior change (except for the hash style).

Bug: chromium:1220175
Change-Id: Idcebc8f55165ae300632005f5cf527ec689a365f
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/55608
Reviewed-by: Alexis Hétu <sugoi@google.com>
Kokoro-Result: kokoro <noreply+kokoro@google.com>
Tested-by: Nico Weber <thakis@chromium.org>
Commit-Queue: Nico Weber <thakis@chromium.org>
diff --git a/BUILD.gn b/BUILD.gn
index 0e12281..ed48ff6 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -22,32 +22,13 @@
   defines = []
 
   if (is_win) {
-    cflags = [
-      "/GS",  # Detects some buffer overruns
-      "/Zc:wchar_t",
-      "/EHs-c-",  # Disable C++ exceptions
-      "/nologo",
-      "/Gd",  # Default calling convention
-      # Disable MSVC warnings about std::aligned_storage being broken before VS 2017 15.8
-      "/D_ENABLE_EXTENDED_ALIGNED_STORAGE",
-    ]
-
-    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 += [
-      "_CRT_SECURE_NO_DEPRECATE",
-      "NOMINMAX",
       "_WINDLL",
       "NO_SANITIZE_FUNCTION=",
+
+      # Disable MSVC warnings about std::aligned_storage being broken before
+      # VS 2017 15.8
+      "_ENABLE_EXTENDED_ALIGNED_STORAGE",
     ]
 
     if (!is_debug) {
@@ -57,21 +38,20 @@
     # Diable some MSVC warnings.
     if (!is_clang) {
       cflags += [
-        "/wd4065", # switch statement contains 'default' but no 'case' labels
-        "/wd4309", # Truncation of constant value. See PixelRoutine.cpp casts of signed shorts.
+        "/wd4065",  # switch statement contains 'default' but no 'case' labels
+        "/wd4309",  # Truncation of constant value. See PixelRoutine.cpp casts
+                    # of signed shorts.
       ]
     }
 
     cflags_cc = [ "/std:c++17" ]
   } else {
-    cflags = [
-      "-fno-exceptions",
-      "-fno-operator-names",
-    ]
+    cflags = [ "-fno-operator-names" ]
     cflags_cc = [ "-std=c++17" ]
-    # On macOS for the ARM architecture, some C++17 features require version 10.14,
-    # while Chrome must support 10.11 (El Capitan). However, the first 'Apple Silicon'
-    # devices launched with macOS 11.0 (Big Sur).
+
+    # On macOS for the ARM architecture, some C++17 features require version
+    # 10.14, while Chrome must support 10.11 (El Capitan). However, the first
+    # 'Apple Silicon' devices launched with macOS 11.0 (Big Sur).
     # TODO(b/174843857): Remove once Chrome demands macOS 10.14.
     if (is_mac && current_cpu == "arm64") {
       cflags += [
@@ -81,30 +61,16 @@
       ]
     }
 
-    defines += [
-      "__STDC_CONSTANT_MACROS",
-      "__STDC_LIMIT_MACROS",
-      "NO_SANITIZE_FUNCTION=__attribute__((no_sanitize(\"function\")))",
-    ]
+    defines +=
+        [ "NO_SANITIZE_FUNCTION=__attribute__((no_sanitize(\"function\")))" ]
 
-    if (is_debug) {
+    if (!is_debug) {
       cflags += [
-        "-g",
-        "-g3",
-      ]
-    } else {  # Release
-      # All Release builds use function/data sections to make the shared libraries smaller
-      cflags += [
-        "-ffunction-sections",
-        "-fdata-sections",
         "-fomit-frame-pointer",
         "-Os",
       ]
 
-      defines += [
-        "ANGLE_DISABLE_TRACE",
-        "NDEBUG",
-      ]
+      defines += [ "ANGLE_DISABLE_TRACE" ]
     }
 
     if (current_cpu == "x64") {  # 64 bit version
@@ -131,13 +97,9 @@
         "-mxgot",
       ]
       if (mips_arch_variant == "r1") {
-        cflags += [
-          "-march=mips32",
-        ]
+        cflags += [ "-march=mips32" ]
       } else {
-        cflags += [
-          "-march=mips32r2",
-        ]
+        cflags += [ "-march=mips32r2" ]
       }
     } else if (target_cpu == "mips64el" && current_cpu == target_cpu) {
       cflags += [
@@ -150,28 +112,14 @@
     }
 
     if (is_linux || is_chromeos) {
-      ldflags = [ "-Wl,--gc-sections" ]
-
       if (current_cpu == "mipsel") {
-        ldflags += [
-          "-Wl,--hash-style=sysv",
-        ]
         if (mips_arch_variant == "r1") {
-          ldflags += [
-            "-mips32",
-          ]
+          ldflags += [ "-mips32" ]
         } else {
-          ldflags += [
-            "-mips32r2",
-          ]
+          ldflags += [ "-mips32r2" ]
         }
       } else if (current_cpu == "mips64el") {
-        ldflags += [
-          "-Wl,--hash-style=sysv",
-          "-mips64r2",
-        ]
-      } else {
-        ldflags += [ "-Wl,--hash-style=both" ]
+        ldflags += [ "-mips64r2" ]
       }
 
       # A bug in the gold linker prevents using ICF on 32-bit (crbug.com/729532)
@@ -183,9 +131,7 @@
 }
 
 source_set("vertex_routine_fuzzer") {
-  sources = [
-    "tests/fuzzers/VertexRoutineFuzzer.cpp"
-  ]
+  sources = [ "tests/fuzzers/VertexRoutineFuzzer.cpp" ]
   if (is_win) {
     cflags = [
       "/wd4201",  # nameless struct/union
@@ -193,36 +139,34 @@
       "/wd5030",  # attribute is not recognized
     ]
   }
-  include_dirs = [
-    "src/",
-  ]
-  deps = [
-    "src/OpenGL/libGLESv2:swiftshader_libGLESv2_static",
-  ]
+  include_dirs = [ "src/" ]
+  deps = [ "src/OpenGL/libGLESv2:swiftshader_libGLESv2_static" ]
 }
 
 group("swiftshader") {
   data_deps = [
-    "src/OpenGL/libGLESv2:swiftshader_libGLESv2",
     "src/OpenGL/libEGL:swiftshader_libEGL",
+    "src/OpenGL/libGLESv2:swiftshader_libGLESv2",
   ]
 }
 
 if (build_with_chromium) {
-    group("swiftshader_tests") {
-      testonly = true
+  group("swiftshader_tests") {
+    testonly = true
 
-      data_deps = [
-        "tests/GLESUnitTests:swiftshader_unittests",
-        "tests/SystemUnitTests:swiftshader_system_unittests",
-      ]
+    data_deps = [
+      "tests/GLESUnitTests:swiftshader_unittests",
+      "tests/SystemUnitTests:swiftshader_system_unittests",
+    ]
 
-      if (supports_llvm) {
-        data_deps += [ "tests/ReactorUnitTests:swiftshader_reactor_llvm_unittests" ]
-      }
-
-      if (supports_subzero) {
-        data_deps += [ "tests/ReactorUnitTests:swiftshader_reactor_subzero_unittests" ]
-      }
+    if (supports_llvm) {
+      data_deps +=
+          [ "tests/ReactorUnitTests:swiftshader_reactor_llvm_unittests" ]
     }
+
+    if (supports_subzero) {
+      data_deps +=
+          [ "tests/ReactorUnitTests:swiftshader_reactor_subzero_unittests" ]
+    }
+  }
 }