OSDN Git Service

Memory leak fix
[android-x86/external-swiftshader.git] / BUILD.gn
index db96bae..7af9f6a 100644 (file)
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -12,6 +12,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+import("//build/config/c++/c++.gni")
 import("//build/config/compiler/compiler.gni")
 
 config("swiftshader_config") {
@@ -21,11 +22,22 @@ config("swiftshader_config") {
     cflags = [
       "/GS",  # Detects some buffer overruns
       "/Zc:wchar_t",
-      "/EHsc",
+      "/EHs-c-",  # Disable C++ exceptions
       "/nologo",
       "/Gd",  # Default calling convention
     ]
 
+    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",
@@ -73,13 +85,16 @@ config("swiftshader_config") {
       cflags += [
         "-m64",
         "-fPIC",
-        "-march=core2",
+        "-march=x86-64",
+        "-mtune=generic",
       ]
     } else {  # 32 bit version
       cflags += [
         "-m32",
         "-msse2",
-        "-march=i686",
+        "-mfpmath=sse",
+        "-march=pentium4",
+        "-mtune=generic",
       ]
     }
 
@@ -101,6 +116,13 @@ source_set("vertex_routine_fuzzer") {
   sources = [
     "tests/fuzzers/VertexRoutineFuzzer.cpp"
   ]
+  if (is_win) {
+    cflags = [
+      "/wd4201",  # nameless struct/union
+      "/wd4065",  # switch statement contains 'default' but no 'case' labels
+      "/wd5030",  # attribute is not recognized
+    ]
+  }
   include_dirs = [
     "src/",
   ]