OSDN Git Service

Update to Linux build files for Chromium
authorAlexis Hetu <sugoi@google.com>
Fri, 27 Jan 2017 16:38:59 +0000 (11:38 -0500)
committerNicolas Capens <capn@google.com>
Fri, 27 Jan 2017 21:19:50 +0000 (21:19 +0000)
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>
BUILD.gn
src/OpenGL/libEGL/BUILD.gn
src/OpenGL/libGLESv2/BUILD.gn

index ae6087e..3665e71 100644 (file)
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -31,10 +31,21 @@ config("swiftshader_config") {
       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 @@ config("swiftshader_config") {
         "-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",
+    ]
   }
 }
 
index 42c77f8..7d11775 100644 (file)
@@ -25,7 +25,7 @@ config("swiftshader_libEGL_private_config") {
   } else {
     cflags = [
       "-DLOG_TAG=\"swiftshader_libEGL\"",
-      "-DEGLAPI=",
+      "-DEGLAPI=__attribute__((visibility(\"protected\")))",
       "-DEGL_EGLEXT_PROTOTYPES",
       "-Wno-sign-compare",
     ]
@@ -70,6 +70,8 @@ shared_library("swiftshader_libEGL") {
     ldflags = [ "/DEF:" + rebase_path("libGLESv2.def", root_build_dir) ]
   } else if (is_linux) {
     sources += [ "../../Main/libX11.cpp" ]
+    ldflags =
+        [ "-Wl,--version-script=" + rebase_path("exports.map", root_build_dir) ]
   }
 
   configs -= [ "//build/config/compiler:chromium_code" ]
index 1b798a3..80adf83 100644 (file)
@@ -36,7 +36,7 @@ config("swiftshader_libGLESv2_private_config") {
       "-D__STDC_CONSTANT_MACROS",
       "-D__STDC_LIMIT_MACROS",
       "-DGL_API=",
-      "-DGL_APICALL=",
+      "-DGL_APICALL=__attribute__((visibility(\"protected\")))",
       "-DGL_GLEXT_PROTOTYPES",
       "-Wno-sign-compare",
     ]
@@ -83,6 +83,9 @@ shared_library("swiftshader_libGLESv2") {
   if (is_win) {
     configs -= [ "//build/config/win:unicode" ]
     ldflags = [ "/DEF:" + rebase_path("libGLESv2.def", root_build_dir) ]
+  } else if (is_linux) {
+    ldflags =
+        [ "-Wl,--version-script=" + rebase_path("exports.map", root_build_dir) ]
   }
 
   configs -= [ "//build/config/compiler:chromium_code" ]