Update to Linux build files for Chromium

Although SwiftShader was building properly on the build bots, it
wasn't exporting its symbols properly. I compared the flags used in
the BUILD.gn files and in the CMakeLists.txt file and attempted to
get both build systems to use the same flags and options.

Change-Id: Idc73d4ad5b45311881e88720bf611e25110dcc70
Reviewed-on: https://swiftshader-review.googlesource.com/8576
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
diff --git a/BUILD.gn b/BUILD.gn
index ae6087e..3665e71 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -31,10 +31,21 @@
       cflags += [ "/DANGLE_DISABLE_TRACE" ]
     }
   } else {
-    cflags = [ "-std=c++11" ]
+    cflags = [
+      "-std=c++11",
+      "-Wall",
+      "-fexceptions",
+      "-fvisibility=protected",
+      "-fno-operator-names",
+      "-D__STDC_CONSTANT_MACROS",
+      "-D__STDC_LIMIT_MACROS",
+    ]
 
     if (is_debug) {
-      cflags += [ "-g" ]
+      cflags += [
+        "-g",
+        "-g3",
+      ]
     } else {  # Release
       # All Release builds use function/data sections to make the shared libraries smaller
       cflags += [
@@ -42,24 +53,30 @@
         "-fdata-sections",
         "-fomit-frame-pointer",
         "-DANGLE_DISABLE_TRACE",
+        "-DNDEBUG",
+        "-O2",
+        "-Os",
       ]
-
-      # Choose the right Release architecture
-      if (target_cpu == "x64") {
-        cflags += [ "-march=core2" ]
-      } else {  # 32
-        cflags += [ "-march=i686" ]
-      }
     }
 
     if (target_cpu == "x64") {  # 64 bit version
       cflags += [
         "-m64",
         "-fPIC",
+        "-march=core2",
       ]
     } else {  # 32 bit version
-      cflags += [ "-m32" ]
+      cflags += [
+        "-m32",
+        "-msse2",
+        "-march=i686",
+      ]
     }
+
+    ldflags = [
+      "-Wl,--hash-style=both",
+      "-Wl,--gc-sections",
+    ]
   }
 }