From 25fec34a8a7d66c768fafdc68bdb6bb73076877e Mon Sep 17 00:00:00 2001
From: Yasuhiro Matsumoto <mattn.jp@gmail.com>
Date: Mon, 7 Sep 2020 17:41:52 +0900
Subject: [PATCH] Fix cmake build on mingw compiler

---
 tensorflow/lite/CMakeLists.txt   | 6 +++++-
 tensorflow/lite/shared_library.h | 4 ++--
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/tensorflow/lite/CMakeLists.txt b/tensorflow/lite/CMakeLists.txt
index 917c885d1f7..dd75334cb06 100644
--- a/tensorflow/lite/CMakeLists.txt
+++ b/tensorflow/lite/CMakeLists.txt
@@ -177,7 +177,11 @@ if(CMAKE_SYSTEM_NAME MATCHES "Windows")
   list(APPEND TFLITE_TARGET_PRIVATE_OPTIONS "-DNOMINMAX" "-DNOGDI")
   # lite/kernels/conv.cc has more than 64k sections so enable /bigobj to
   # support compilation with MSVC2015.
-  list(APPEND TFLITE_TARGET_PRIVATE_OPTIONS "/bigobj")
+  if(MSVC)
+    list(APPEND TFLITE_TARGET_PRIVATE_OPTIONS "/bigobj")
+  elseif(CMAKE_COMPILER_IS_GNUCXX)
+    list(APPEND TFLITE_TARGET_PRIVATE_OPTIONS "-Wa,-mbig-obj")
+  endif()
 endif()
 # Build a list of source files to compile into the TF Lite library.
 populate_tflite_source_vars("." TFLITE_SRCS)
diff --git a/tensorflow/lite/shared_library.h b/tensorflow/lite/shared_library.h
index 7cf34a03125..a7bd91b3a0a 100644
--- a/tensorflow/lite/shared_library.h
+++ b/tensorflow/lite/shared_library.h
@@ -33,11 +33,11 @@ class SharedLibrary {
     return ::LoadLibrary(lib);
   }
   static inline void* GetLibrarySymbol(void* handle, const char* symbol) {
-    return static_cast<void*>(
+    return reinterpret_cast<void*>(
         GetProcAddress(static_cast<HMODULE>(handle), symbol));
   }
   static inline void* GetSymbol(const char* symbol) {
-    return static_cast<void*>(GetProcAddress(nullptr, symbol));
+    return reinterpret_cast<void*>(GetProcAddress(nullptr, symbol));
   }
   static inline int UnLoadLibrary(void* handle) {
     return FreeLibrary(static_cast<HMODULE>(handle));