Skip to content

Commit 849eee8

Browse files
authored
Simplify onnx.patch (#25204)
Delete the legacy patches related to protobuf, which was added from #14279 and #15878 to simplify the ONNX patches.
1 parent 5ddd34e commit 849eee8

File tree

2 files changed

+6
-92
lines changed

2 files changed

+6
-92
lines changed

cmake/patches/onnx/onnx.patch

Lines changed: 3 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
diff --git a/CMakeLists.txt b/CMakeLists.txt
2-
index 8b5af303..7fe05a5a 100644
2+
index 8b5af303..8593fe4a 100644
33
--- a/CMakeLists.txt
44
+++ b/CMakeLists.txt
55
@@ -40,6 +40,7 @@ option(ONNX_USE_LITE_PROTO "Use lite protobuf instead of full." OFF)
@@ -47,15 +47,7 @@ index 8b5af303..7fe05a5a 100644
4747

4848
add_library(onnx_proto ${ONNX_PROTO_SRCS} ${ONNX_PROTO_HDRS})
4949
add_dependencies(onnx_proto gen_onnx_operators_proto gen_onnx_data_proto)
50-
@@ -492,6 +507,7 @@ if(MSVC)
51-
endif()
52-
else()
53-
# On non-Windows, hide all symbols we don't need
54-
+ set(EXTRA_FLAGS "-Wno-unused-parameter")
55-
set(ONNX_API_DEFINE "-DONNX_API=__attribute__\(\(__visibility__\(\"default\"\)\)\)")
56-
set_target_properties(onnx_proto PROPERTIES CXX_VISIBILITY_PRESET hidden)
57-
set_target_properties(onnx_proto PROPERTIES VISIBILITY_INLINES_HIDDEN 1)
58-
@@ -595,13 +611,6 @@ if(ONNX_BUILD_PYTHON)
50+
@@ -595,13 +610,6 @@ if(ONNX_BUILD_PYTHON)
5951
target_link_libraries(onnx_cpp2py_export PRIVATE ${Python3_LIBRARIES})
6052
target_compile_options(onnx_cpp2py_export
6153
PRIVATE /MP
@@ -69,7 +61,7 @@ index 8b5af303..7fe05a5a 100644
6961
${EXTRA_FLAGS})
7062
add_msvc_runtime_flag(onnx_cpp2py_export)
7163
add_onnx_global_defines(onnx_cpp2py_export)
72-
@@ -618,23 +627,9 @@ endif()
64+
@@ -618,23 +626,9 @@ endif()
7365
if(MSVC)
7466
target_compile_options(onnx_proto
7567
PRIVATE /MP
@@ -165,38 +157,3 @@ index acf3aac7..5bef6e72 100644
165157
OpSchemaRegisterNoExcept(std::move(op_schema), opset_version_to_load, fail_duplicate_schema);
166158
}
167159
static void
168-
diff --git a/onnx/onnx_pb.h b/onnx/onnx_pb.h
169-
index 0aab3e26..27f32195 100644
170-
--- a/onnx/onnx_pb.h
171-
+++ b/onnx/onnx_pb.h
172-
@@ -47,10 +47,30 @@
173-
#define ONNX_API ONNX_IMPORT
174-
#endif
175-
176-
+#if defined(__GNUC__)
177-
+#pragma GCC diagnostic push
178-
+
179-
+// In file included from onnx/onnx-ml.pb.h:30:
180-
+// In file included from google/protobuf/extension_set.h:53:
181-
+// google/protobuf/parse_context.h:328:47: error: implicit conversion loses integer precision: 'long' to 'int' [-Werror,-Wshorten-64-to-32]
182-
+#if defined(__has_warning)
183-
+#if __has_warning("-Wshorten-64-to-32")
184-
+#pragma GCC diagnostic ignored "-Wshorten-64-to-32"
185-
+#endif
186-
+#endif // defined(__has_warning)
187-
+
188-
+#endif // defined(__GNUC__)
189-
+
190-
+
191-
#ifdef ONNX_ML
192-
#include "onnx/onnx-ml.pb.h"
193-
#else
194-
#include "onnx/onnx.pb.h"
195-
#endif
196-
197-
+#if defined(__GNUC__)
198-
+#pragma GCC diagnostic pop
199-
+#endif
200-
+
201-
+
202-
#endif // ! ONNX_ONNX_PB_H

cmake/vcpkg-ports/onnx/binskim.patch

Lines changed: 3 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
diff --git a/CMakeLists.txt b/CMakeLists.txt
2-
index 8b5af303..7fe05a5a 100644
2+
index 8b5af303..8593fe4a 100644
33
--- a/CMakeLists.txt
44
+++ b/CMakeLists.txt
55
@@ -40,6 +40,7 @@ option(ONNX_USE_LITE_PROTO "Use lite protobuf instead of full." OFF)
@@ -47,15 +47,7 @@ index 8b5af303..7fe05a5a 100644
4747

4848
add_library(onnx_proto ${ONNX_PROTO_SRCS} ${ONNX_PROTO_HDRS})
4949
add_dependencies(onnx_proto gen_onnx_operators_proto gen_onnx_data_proto)
50-
@@ -492,6 +507,7 @@ if(MSVC)
51-
endif()
52-
else()
53-
# On non-Windows, hide all symbols we don't need
54-
+ set(EXTRA_FLAGS "-Wno-unused-parameter")
55-
set(ONNX_API_DEFINE "-DONNX_API=__attribute__\(\(__visibility__\(\"default\"\)\)\)")
56-
set_target_properties(onnx_proto PROPERTIES CXX_VISIBILITY_PRESET hidden)
57-
set_target_properties(onnx_proto PROPERTIES VISIBILITY_INLINES_HIDDEN 1)
58-
@@ -595,13 +611,6 @@ if(ONNX_BUILD_PYTHON)
50+
@@ -595,13 +610,6 @@ if(ONNX_BUILD_PYTHON)
5951
target_link_libraries(onnx_cpp2py_export PRIVATE ${Python3_LIBRARIES})
6052
target_compile_options(onnx_cpp2py_export
6153
PRIVATE /MP
@@ -69,7 +61,7 @@ index 8b5af303..7fe05a5a 100644
6961
${EXTRA_FLAGS})
7062
add_msvc_runtime_flag(onnx_cpp2py_export)
7163
add_onnx_global_defines(onnx_cpp2py_export)
72-
@@ -618,23 +627,9 @@ endif()
64+
@@ -618,23 +626,9 @@ endif()
7365
if(MSVC)
7466
target_compile_options(onnx_proto
7567
PRIVATE /MP
@@ -165,38 +157,3 @@ index acf3aac7..5bef6e72 100644
165157
OpSchemaRegisterNoExcept(std::move(op_schema), opset_version_to_load, fail_duplicate_schema);
166158
}
167159
static void
168-
diff --git a/onnx/onnx_pb.h b/onnx/onnx_pb.h
169-
index 0aab3e26..27f32195 100644
170-
--- a/onnx/onnx_pb.h
171-
+++ b/onnx/onnx_pb.h
172-
@@ -47,10 +47,30 @@
173-
#define ONNX_API ONNX_IMPORT
174-
#endif
175-
176-
+#if defined(__GNUC__)
177-
+#pragma GCC diagnostic push
178-
+
179-
+// In file included from onnx/onnx-ml.pb.h:30:
180-
+// In file included from google/protobuf/extension_set.h:53:
181-
+// google/protobuf/parse_context.h:328:47: error: implicit conversion loses integer precision: 'long' to 'int' [-Werror,-Wshorten-64-to-32]
182-
+#if defined(__has_warning)
183-
+#if __has_warning("-Wshorten-64-to-32")
184-
+#pragma GCC diagnostic ignored "-Wshorten-64-to-32"
185-
+#endif
186-
+#endif // defined(__has_warning)
187-
+
188-
+#endif // defined(__GNUC__)
189-
+
190-
+
191-
#ifdef ONNX_ML
192-
#include "onnx/onnx-ml.pb.h"
193-
#else
194-
#include "onnx/onnx.pb.h"
195-
#endif
196-
197-
+#if defined(__GNUC__)
198-
+#pragma GCC diagnostic pop
199-
+#endif
200-
+
201-
+
202-
#endif // ! ONNX_ONNX_PB_H

0 commit comments

Comments
 (0)