MacOS build fix

Fixed MacOS build after the recent Linux fix caused an issue on
MacOS. Removed a few flags and changed visibility to fix it.

Change-Id: Ic9d08d8ec0ccf8a2002f2787c3ec79861bb59139
Reviewed-on: https://swiftshader-review.googlesource.com/8589
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
diff --git a/BUILD.gn b/BUILD.gn
index 3665e71..b8f17d6 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -73,10 +73,12 @@
       ]
     }
 
-    ldflags = [
-      "-Wl,--hash-style=both",
-      "-Wl,--gc-sections",
-    ]
+    if (is_linux) {
+      ldflags = [
+        "-Wl,--hash-style=both",
+        "-Wl,--gc-sections",
+      ]
+    }
   }
 }
 
diff --git a/src/OpenGL/libEGL/BUILD.gn b/src/OpenGL/libEGL/BUILD.gn
index 7d11775..03af0f5 100644
--- a/src/OpenGL/libEGL/BUILD.gn
+++ b/src/OpenGL/libEGL/BUILD.gn
@@ -25,10 +25,15 @@
   } else {
     cflags = [
       "-DLOG_TAG=\"swiftshader_libEGL\"",
-      "-DEGLAPI=__attribute__((visibility(\"protected\")))",
       "-DEGL_EGLEXT_PROTOTYPES",
       "-Wno-sign-compare",
     ]
+
+    if (is_linux) {
+      cflags += [ "-DGL_APICALL=__attribute__((visibility(\"protected\")))" ]
+    } else {
+      cflags += [ "-DGL_APICALL=__attribute__((visibility(\"default\")))" ]
+    }
   }
 }
 
diff --git a/src/OpenGL/libGLESv2/BUILD.gn b/src/OpenGL/libGLESv2/BUILD.gn
index 80adf83..8b0024a 100644
--- a/src/OpenGL/libGLESv2/BUILD.gn
+++ b/src/OpenGL/libGLESv2/BUILD.gn
@@ -36,10 +36,15 @@
       "-D__STDC_CONSTANT_MACROS",
       "-D__STDC_LIMIT_MACROS",
       "-DGL_API=",
-      "-DGL_APICALL=__attribute__((visibility(\"protected\")))",
       "-DGL_GLEXT_PROTOTYPES",
       "-Wno-sign-compare",
     ]
+
+    if (is_linux) {
+      cflags += [ "-DGL_APICALL=__attribute__((visibility(\"protected\")))" ]
+    } else {
+      cflags += [ "-DGL_APICALL=__attribute__((visibility(\"default\")))" ]
+    }
   }
 }