mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-07-27 20:02:15 +00:00
### Description This PR fixes build break for WebAssembly introduced in6986981482(435ad2b1d8). This change updates onnx.patch in onnxruntime repo. the corresponding PR in onnx repo is: https://github.com/onnx/onnx/pull/5495. It may takes a while for the next onnx version bump.
79 lines
3 KiB
Diff
79 lines
3 KiB
Diff
diff --git a/CMakeLists.txt b/CMakeLists.txt
|
|
index 4dd56b6e..018da488 100644
|
|
--- a/CMakeLists.txt
|
|
+++ b/CMakeLists.txt
|
|
@@ -397,6 +397,7 @@ if (MSVC)
|
|
endif()
|
|
else()
|
|
# On non-Windows, hide all symbols we don't need
|
|
+ set(EXTRA_FLAGS "-Wno-unused-parameter")
|
|
set(ONNX_API_DEFINE "-DONNX_API=__attribute__\(\(__visibility__\(\"default\"\)\)\)")
|
|
set_target_properties(onnx_proto PROPERTIES CXX_VISIBILITY_PRESET hidden)
|
|
set_target_properties(onnx_proto PROPERTIES VISIBILITY_INLINES_HIDDEN 1)
|
|
@@ -548,20 +549,9 @@ endif()
|
|
if(MSVC)
|
|
target_compile_options(onnx_proto
|
|
PRIVATE /MP
|
|
- /wd4244 #'argument': conversion from 'google::
|
|
- #protobuf::uint64' to 'int', possible
|
|
- # loss of data
|
|
- /wd4267 # Conversion from 'size_t' to 'int',
|
|
- # possible loss of data
|
|
${EXTRA_FLAGS})
|
|
target_compile_options(onnx
|
|
PRIVATE /MP
|
|
- /wd4244 # 'argument': conversion from 'google::
|
|
- # protobuf::uint64' to 'int', possible
|
|
- # loss of data
|
|
- /wd4267 # Conversion from 'size_t' to 'int',
|
|
- # possible loss of data
|
|
- /wd4996 # The second parameter is ignored.
|
|
${EXTRA_FLAGS})
|
|
if(ONNX_USE_PROTOBUF_SHARED_LIBS)
|
|
target_compile_options(onnx_proto
|
|
diff --git a/onnx/onnx_pb.h b/onnx/onnx_pb.h
|
|
index 0aab3e26..0f859267 100644
|
|
--- a/onnx/onnx_pb.h
|
|
+++ b/onnx/onnx_pb.h
|
|
@@ -47,10 +47,28 @@
|
|
#define ONNX_API ONNX_IMPORT
|
|
#endif
|
|
|
|
+#if defined(__GNUC__)
|
|
+#pragma GCC diagnostic push
|
|
+
|
|
+// In file included from onnx/onnx-ml.pb.h:30:
|
|
+// In file included from google/protobuf/extension_set.h:53:
|
|
+// google/protobuf/parse_context.h:328:47: error: implicit conversion loses integer precision: 'long' to 'int' [-Werror,-Wshorten-64-to-32]
|
|
+#if defined(__has_warning)
|
|
+#if __has_warning("-Wshorten-64-to-32")
|
|
+#pragma GCC diagnostic ignored "-Wshorten-64-to-32"
|
|
+#endif
|
|
+#endif // defined(__has_warning)
|
|
+
|
|
+#endif // defined(__GNUC__)
|
|
+
|
|
#ifdef ONNX_ML
|
|
#include "onnx/onnx-ml.pb.h"
|
|
#else
|
|
#include "onnx/onnx.pb.h"
|
|
#endif
|
|
|
|
+#if defined(__GNUC__)
|
|
+#pragma GCC diagnostic pop
|
|
+#endif
|
|
+
|
|
#endif // ! ONNX_ONNX_PB_H
|
|
diff --git a/onnx/checker.cc b/onnx/checker.cc
|
|
index 8fdaf037..1beb1b88 100644
|
|
--- a/onnx/checker.cc
|
|
+++ b/onnx/checker.cc
|
|
@@ -190,7 +190,7 @@ void check_tensor(const TensorProto& tensor, const CheckerContext& ctx) {
|
|
}
|
|
std::string data_path = path_join(ctx.get_model_dir(), relative_path);
|
|
// use stat64 to check whether the file exists
|
|
-#ifdef __APPLE__
|
|
+#if defined(__APPLE__) || defined(__wasm__)
|
|
struct stat buffer; // APPLE does not have stat64
|
|
if (stat((data_path).c_str(), &buffer) != 0) {
|
|
#else
|