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", + ] } }
diff --git a/src/OpenGL/libEGL/BUILD.gn b/src/OpenGL/libEGL/BUILD.gn index 42c77f8..7d11775 100644 --- a/src/OpenGL/libEGL/BUILD.gn +++ b/src/OpenGL/libEGL/BUILD.gn
@@ -25,7 +25,7 @@ } else { cflags = [ "-DLOG_TAG=\"swiftshader_libEGL\"", - "-DEGLAPI=", + "-DEGLAPI=__attribute__((visibility(\"protected\")))", "-DEGL_EGLEXT_PROTOTYPES", "-Wno-sign-compare", ] @@ -70,6 +70,8 @@ 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" ]
diff --git a/src/OpenGL/libGLESv2/BUILD.gn b/src/OpenGL/libGLESv2/BUILD.gn index 1b798a3..80adf83 100644 --- a/src/OpenGL/libGLESv2/BUILD.gn +++ b/src/OpenGL/libGLESv2/BUILD.gn
@@ -36,7 +36,7 @@ "-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 @@ 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" ]