forked from envoyproxy/envoy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprotobuf.patch
228 lines (217 loc) · 7.3 KB
/
protobuf.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
diff --git a/BUILD.bazel b/BUILD.bazel
index 32b26cbdc..e28b8e387 100644
--- a/BUILD.bazel
+++ b/BUILD.bazel
@@ -229,14 +229,79 @@ alias(
visibility = ["//visibility:public"],
)
+# Envoy: Patch
+
cc_binary(
- name = "protoc",
+ name = "compiled_protoc",
copts = COPTS,
linkopts = LINK_OPTS,
visibility = ["//visibility:public"],
deps = ["//src/google/protobuf/compiler:protoc_lib"],
)
+# Lifted from `rules_proto`
+config_setting(
+ name = "linux-aarch_64",
+ constraint_values = [
+ "@platforms//os:linux",
+ "@platforms//cpu:aarch64",
+ ],
+)
+
+config_setting(
+ name = "linux-x86_64",
+ constraint_values = [
+ "@platforms//os:linux",
+ "@platforms//cpu:x86_64",
+ ],
+)
+
+config_setting(
+ name = "osx-aarch_64",
+ constraint_values = [
+ "@platforms//os:osx",
+ "@platforms//cpu:aarch64",
+ ],
+)
+
+config_setting(
+ name = "osx-x86_64",
+ constraint_values = [
+ "@platforms//os:osx",
+ "@platforms//cpu:x86_64",
+ ],
+)
+
+config_setting(
+ name = "win64",
+ constraint_values = [
+ "@platforms//os:windows",
+ "@platforms//cpu:x86_64",
+ ],
+)
+
+# Use precompiled binaries where possible.
+alias(
+ name = "protoc",
+ actual = select({
+ ":linux-aarch_64": "@com_google_protobuf_protoc_linux_aarch_64//:protoc",
+ ":linux-x86_64": "@com_google_protobuf_protoc_linux_x86_64//:protoc",
+ ":osx-aarch_64": "@com_google_protobuf_protoc_osx_aarch_64//:protoc",
+ ":osx-x86_64": "@com_google_protobuf_protoc_osx_x86_64//:protoc",
+ ":win64": "@com_google_protobuf_protoc_win64//:protoc",
+ "//conditions:default": ":compiled_protoc",
+ }),
+ visibility = ["//visibility:public"],
+)
+
+alias(
+ name = "protobuf_python_genproto",
+ actual = "//python:well_known_types_py_pb2_genproto",
+ visibility = ["//visibility:public"],
+)
+
+# /Envoy: Patch
+
cc_binary(
name = "protoc_static",
copts = COPTS,
diff --git a/protobuf.bzl b/protobuf.bzl
index c8d32a604..5bd22e021 100644
--- a/protobuf.bzl
+++ b/protobuf.bzl
@@ -99,6 +99,10 @@ def _proto_gen_impl(ctx):
if ctx.attr.includes:
for include in ctx.attr.includes:
+ if include == ".":
+ # This is effectively source_dir, which has already been handled,
+ # and may be generated incorrectly here.
+ continue
import_flags += ["-I" + _GetPath(ctx, include)]
import_flags = depset(direct = import_flags)
diff --git a/python/google/protobuf/__init__.py b/python/google/protobuf/__init__.py
index fb6c5ae63..fc4b2523b 100755
--- a/python/google/protobuf/__init__.py
+++ b/python/google/protobuf/__init__.py
@@ -8,3 +8,10 @@
# Copyright 2007 Google Inc. All Rights Reserved.
__version__ = '5.29.1'
+
+
+if __name__ != '__main__':
+ try:
+ __import__('pkg_resources').declare_namespace(__name__)
+ except ImportError:
+ __path__ = __import__('pkgutil').extend_path(__path__, __name__)
diff --git a/src/google/protobuf/compiler/BUILD.bazel b/src/google/protobuf/compiler/BUILD.bazel
index 5012ee793..edf9adc5f 100644
--- a/src/google/protobuf/compiler/BUILD.bazel
+++ b/src/google/protobuf/compiler/BUILD.bazel
@@ -547,7 +547,7 @@ cc_library(
srcs = ["retention.cc"],
hdrs = ["retention.h"],
strip_include_prefix = "/src",
- visibility = ["//src/google/protobuf:__subpackages__"],
+ visibility = ["//visibility:public"],
deps = [
"//src/google/protobuf",
"//src/google/protobuf:port",
diff --git a/src/google/protobuf/io/BUILD.bazel b/src/google/protobuf/io/BUILD.bazel
index 192fec3ab..5d12630eb 100644
--- a/src/google/protobuf/io/BUILD.bazel
+++ b/src/google/protobuf/io/BUILD.bazel
@@ -159,7 +159,7 @@ cc_library(
"@com_google_absl//absl/log:absl_log",
] + select({
"//build_defs:config_msvc": [],
- "//conditions:default": ["@zlib"],
+ "//conditions:default": ["@envoy//bazel/foreign_cc:zlib"],
}),
)
diff --git a/src/google/protobuf/map.cc b/src/google/protobuf/map.cc
index 570b61bec..da6ceb99d 100644
--- a/src/google/protobuf/map.cc
+++ b/src/google/protobuf/map.cc
@@ -116,7 +116,7 @@ void UntypedMapBase::ClearTable(const ClearInput input) {
ABSL_DCHECK_NE(num_buckets_, kGlobalEmptyTableSize);
if (alloc_.arena() == nullptr) {
- const auto loop = [=](auto destroy_node) {
+ const auto loop = [&, this](auto destroy_node) {
const TableEntryPtr* table = table_;
for (map_index_t b = index_of_first_non_null_, end = num_buckets_;
b < end; ++b) {
diff --git a/src/google/protobuf/port_def.inc b/src/google/protobuf/port_def.inc
index 56f995e45..123f936ac 100644
--- a/src/google/protobuf/port_def.inc
+++ b/src/google/protobuf/port_def.inc
@@ -835,7 +835,7 @@ static_assert(PROTOBUF_ABSL_MIN(20230125, 3),
#pragma clang diagnostic ignored "-Wshorten-64-to-32"
// Turn on -Wdeprecated-enum-enum-conversion. This deprecation comes in C++20
// via http://wg21.link/p1120r0.
-#pragma clang diagnostic error "-Wdeprecated-enum-enum-conversion"
+// #pragma clang diagnostic error "-Wdeprecated-enum-enum-conversion"
// This error has been generally flaky, but we need to disable it specifically
// to fix https://github.com/protocolbuffers/protobuf/issues/12313
#pragma clang diagnostic ignored "-Wunused-parameter"
@@ -904,7 +904,8 @@ static_assert(PROTOBUF_ABSL_MIN(20230125, 3),
#pragma warning(disable: 4125)
#endif
-#if PROTOBUF_ENABLE_DEBUG_LOGGING_MAY_LEAK_PII
+#if defined(PROTOBUF_ENABLE_DEBUG_LOGGING_MAY_LEAK_PII) && \
+ PROTOBUF_ENABLE_DEBUG_LOGGING_MAY_LEAK_PII
#define PROTOBUF_DEBUG true
#else
#define PROTOBUF_DEBUG false
diff --git a/upb/message/internal/accessors.h b/upb/message/internal/accessors.h
index aae0fdc0a..01a874e4c 100644
--- a/upb/message/internal/accessors.h
+++ b/upb/message/internal/accessors.h
@@ -163,7 +163,7 @@ UPB_INLINE void UPB_PRIVATE(_upb_Message_SetPresence)(
}
}
-UPB_INLINE void UPB_PRIVATE(_upb_MiniTableField_DataCopy)(
+UPB_INLINE_IF_NOT_GCC void UPB_PRIVATE(_upb_MiniTableField_DataCopy)(
const upb_MiniTableField* f, void* to, const void* from) {
switch (UPB_PRIVATE(_upb_MiniTableField_GetRep)(f)) {
case kUpb_FieldRep_1Byte:
@@ -183,7 +183,7 @@ UPB_INLINE void UPB_PRIVATE(_upb_MiniTableField_DataCopy)(
UPB_UNREACHABLE();
}
-UPB_INLINE bool UPB_PRIVATE(_upb_MiniTableField_DataEquals)(
+UPB_INLINE_IF_NOT_GCC bool UPB_PRIVATE(_upb_MiniTableField_DataEquals)(
const upb_MiniTableField* f, const void* a, const void* b) {
switch (UPB_PRIVATE(_upb_MiniTableField_GetRep)(f)) {
case kUpb_FieldRep_1Byte:
diff --git a/upb/port/def.inc b/upb/port/def.inc
index 4c073b32f..cc63a28b5 100644
--- a/upb/port/def.inc
+++ b/upb/port/def.inc
@@ -82,6 +82,12 @@ Error, UINTPTR_MAX is undefined
#define UPB_INLINE static
#endif
+#if defined(__GNUC__) && !defined(__clang__)
+#define UPB_INLINE_IF_NOT_GCC static
+#else
+#define UPB_INLINE_IF_NOT_GCC UPB_INLINE
+#endif
+
#ifdef UPB_BUILD_API
#define UPB_API UPB_EXPORT
#define UPB_API_INLINE UPB_EXPORT
diff --git a/upb/port/undef.inc b/upb/port/undef.inc
index f94e2764e..5e02a3627 100644
--- a/upb/port/undef.inc
+++ b/upb/port/undef.inc
@@ -12,6 +12,7 @@
#undef UPB_MAPTYPE_STRING
#undef UPB_EXPORT
#undef UPB_INLINE
+#undef UPB_INLINE_IF_NOT_GCC
#undef UPB_API
#undef UPBC_API
#undef UPB_API_INLINE