Skip to content

Commit

Permalink
Update protobuf to v23.1
Browse files Browse the repository at this point in the history
Signed-off-by: Yan Avlasov <yavlasov@google.com>
  • Loading branch information
yanavlasov committed Jun 23, 2023
1 parent c63546c commit b11dd38
Show file tree
Hide file tree
Showing 33 changed files with 234 additions and 169 deletions.
2 changes: 2 additions & 0 deletions api/bazel/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ def api_dependencies():
)
external_http_archive(
name = "com_envoyproxy_protoc_gen_validate",
patch_args = ["-p1"],
patches = ["@envoy//bazel:pgv.patch"],
)
external_http_archive(
name = "com_google_googleapis",
Expand Down
6 changes: 3 additions & 3 deletions api/bazel/repository_locations.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ REPOSITORY_LOCATIONS_SPEC = dict(
project_desc = "xDS API Working Group (xDS-WG)",
project_url = "https://github.com/cncf/xds",
# During the UDPA -> xDS migration, we aren't working with releases.
version = "46e39c7b9b4321731ebe247f2e176fdf0518d76e",
sha256 = "a39bc06b1b420629643e3e49795004522c2b6439709fd98adccb4930e2b2c197",
release_date = "2023-01-12",
version = "e9ce68804cb4e64cab5a52e3c8baf840d4ff87b7",
sha256 = "0d33b83f8c6368954e72e7785539f0d272a8aba2f6e2e336ed15fd1514bc9899",
release_date = "2023-06-07",
strip_prefix = "xds-{version}",
urls = ["https://github.com/cncf/xds/archive/{version}.tar.gz"],
use_category = ["api"],
Expand Down
5 changes: 5 additions & 0 deletions bazel/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -873,3 +873,8 @@ platform(
"@build_bazel_apple_support//constraints:device",
],
)

cc_library(
name = "python_headers",
visibility = ["//visibility:public"],
)
3 changes: 2 additions & 1 deletion bazel/envoy_build_system.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,8 @@ def envoy_proto_descriptor(name, out, srcs = [], external_deps = []):
include_paths.append("external/com_google_googleapis")

if "well_known_protos" in external_deps:
srcs.append("@com_google_protobuf//:well_known_protos")
srcs.append("@com_google_protobuf//:well_known_type_protos")
srcs.append("@com_google_protobuf//:descriptor_proto_srcs")
include_paths.append("external/com_google_protobuf/src")

options = ["--include_imports"]
Expand Down
2 changes: 1 addition & 1 deletion bazel/envoy_internal.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def envoy_copts(repository, test = False):
"-Werror",
"-Wnon-virtual-dtor",
"-Woverloaded-virtual",
"-Wold-style-cast",
# "-Wold-style-cast", TODO(yanavlasov): re-enable after next protobuf upgrade
"-Wformat",
"-Wformat-security",
"-Wvla",
Expand Down
13 changes: 13 additions & 0 deletions bazel/pgv.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
--- a/templates/cc/register.go 2023-06-22 14:25:05.776175085 +0000
+++ b/templates/cc/register.go 2023-06-22 14:26:33.008090583 +0000
@@ -116,6 +116,10 @@
func (fns CCFuncs) methodName(name interface{}) string {
nameStr := fmt.Sprintf("%s", name)
switch nameStr {
+ case "concept":
+ return "concept_"
+ case "requires":
+ return "requires_"
case "const":
return "const_"
case "inline":
64 changes: 21 additions & 43 deletions bazel/protobuf.patch
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,19 @@ diff --git a/BUILD.bazel b/BUILD.bazel
index 0f6e41e3a..c0d2bbccf 100644
--- a/BUILD.bazel
+++ b/BUILD.bazel
@@ -138,7 +138,7 @@ cc_library(
visibility = ["//visibility:public"],
deps = [":protobuf_lite"] + select({
"//build_defs:config_msvc": [],
- "//conditions:default": ["@zlib//:zlib"],
+ "//conditions:default": ["//external:zlib"],
}),
)

@@ -454,14 +454,79 @@ cc_library(
deps = [":protobuf"],
visibility = ["//visibility:public"],
)

+# Envoy: Patch
+
cc_binary(
- name = "protoc",
+ name = "compiled_protoc",
srcs = ["src/google/protobuf/compiler/main.cc"],
linkopts = LINK_OPTS + PROTOC_LINK_OPTS,
copts = COPTS,
linkopts = LINK_OPTS,
visibility = ["//visibility:public"],
deps = [":protoc_lib"],
deps = ["//src/google/protobuf/compiler:protoc_lib"],
)

+# Lifted from `rules_proto`
Expand Down Expand Up @@ -83,52 +74,39 @@ index 0f6e41e3a..c0d2bbccf 100644
+
+alias(
+ name = "protobuf_python_genproto",
+ actual = "well_known_types_py_pb2_genproto",
+ actual = "//python:well_known_types_py_pb2_genproto",
+ visibility = ["//visibility:public"],
+)
+
+# /Envoy: Patch
+
################################################################################
# Tests
################################################################################
@@ -755,7 +820,7 @@ cc_test(
"@com_google_googletest//:gtest_main",
] + select({
"//build_defs:config_msvc": [],
- "//conditions:default": ["@zlib//:zlib"],
+ "//conditions:default": ["//external:zlib"],
}),
)

cc_binary(
name = "protoc_static",
copts = COPTS,
diff --git a/python/google/protobuf/__init__.py b/python/google/protobuf/__init__.py
index e7555ee10..a93beb1c5 100644
--- a/python/google/protobuf/__init__.py
+++ b/python/google/protobuf/__init__.py
@@ -31,3 +31,10 @@
# Copyright 2007 Google Inc. All Rights Reserved.

__version__ = '4.21.12'
__version__ = '4.23.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/generated_message_tctable_lite.cc b/src/google/protobuf/generated_message_tctable_lite.cc
index 9993811dc..d80006af7 100644
--- a/src/google/protobuf/generated_message_tctable_lite.cc
+++ b/src/google/protobuf/generated_message_tctable_lite.cc
@@ -343,11 +343,6 @@ const char* TcParser::MiniParse(PROTOBUF_TC_PARAM_DECL) {

namespace {

-// Offset returns the address `offset` bytes after `base`.
-inline void* Offset(void* base, uint32_t offset) {
- return static_cast<uint8_t*>(base) + offset;
-}
-
// InvertPacked changes tag bits from the given wire type to length
// delimited. This is the difference expected between packed and non-packed
// repeated fields.
diff --git a/src/google/protobuf/io/BUILD.bazel b/src/google/protobuf/io/BUILD.bazel
--- a/src/google/protobuf/io/BUILD.bazel
+++ b/src/google/protobuf/io/BUILD.bazel
@@ -138,7 +138,7 @@ cc_library(
"@com_google_absl//absl/log:absl_log",
] + select({
"//build_defs:config_msvc": [],
- "//conditions:default": ["@zlib//:zlib"],
+ "//conditions:default": ["//external:zlib"],
}),
)

16 changes: 15 additions & 1 deletion bazel/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ def envoy_repo():
# Bazel native C++ dependencies. For the dependencies that doesn't provide autoconf/automake builds.
def _cc_deps():
external_http_archive("grpc_httpjson_transcoding")
external_http_archive("com_google_protoconverter")
native.bind(
name = "path_matcher",
actual = "@grpc_httpjson_transcoding//src:path_matcher",
Expand Down Expand Up @@ -308,6 +309,8 @@ def envoy_dependencies(skip_targets = []):
external_http_archive("proxy_wasm_rust_sdk")
_com_google_cel_cpp()
_com_github_google_perfetto()
_utf8_range()
_rules_ruby()
external_http_archive("com_github_google_flatbuffers")
external_http_archive("bazel_toolchains")
external_http_archive("bazel_compdb")
Expand Down Expand Up @@ -894,7 +897,7 @@ def _com_google_protobuf():
# https://github.com/google/protobuf/blob/v3.6.1/util/python/BUILD#L6-L9
native.bind(
name = "python_headers",
actual = "@com_google_protobuf//util/python:python_headers",
actual = "//bazel:python_headers",
)

def _io_opencensus_cpp():
Expand Down Expand Up @@ -1083,6 +1086,11 @@ def _com_github_grpc_grpc():
actual = "@com_github_grpc_grpc//test/core/tsi/alts/fake_handshaker:transport_security_common_proto",
)

native.bind(
name = "upb_collections_lib",
actual = "@upb//:collections",
)

native.bind(
name = "upb_lib_descriptor",
actual = "@upb//:descriptor_upb_proto",
Expand Down Expand Up @@ -1339,6 +1347,12 @@ def _com_github_fdio_vpp_vcl():
patches = ["@envoy//bazel/foreign_cc:vpp_vcl.patch"],
)

def _utf8_range():
external_http_archive("utf8_range")

def _rules_ruby():
external_http_archive("rules_ruby")

def _foreign_cc_dependencies():
external_http_archive("rules_foreign_cc")

Expand Down
89 changes: 66 additions & 23 deletions bazel/repository_locations.bzl
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
# This should match the schema defined in external_deps.bzl.

PROTOBUF_VERSION = "21.12"
PROTOBUF_VERSION = "23.1"

# These names of these deps *must* match the names used in `/bazel/protobuf.patch`,
# and both must match the names from the protobuf releases (see
# https://github.com/protocolbuffers/protobuf/releases).
# The names change in upcoming versions.
# The shas are calculated from the downloads on the releases page.
PROTOC_VERSIONS = dict(
linux_aarch_64 = "2dd17f75d66a682640b136e31848da9fb2eefe68d55303baf8b32617374f6711",
linux_x86_64 = "3a4c1e5f2516c639d3079b1586e703fc7bcfa2136d58bda24d1d54f949c315e8",
osx_aarch_64 = "96839af0caed64352442fc8236f4bdf7c1cd6efcfaa98fa5db37307a73fc7c70",
osx_x86_64 = "9448ff40278504a7ae5139bb70c962acc78c32d8fc54b4890a55c14c68b9d10a",
win64 = "71852a30cf62975358edfcbbff93086e8857a079c8e4d6904881aa968d65c7f9",
linux_aarch_64 = "f174eb3a6bd812e9946be3a9ef3fb8f8ac4a6f8acd0a01c928fb2fecb22b6fb0",
linux_x86_64 = "031f8e7504eb359df58389b31752f8081c01b01132a2f3f768a3792ac4b06f3f",
osx_aarch_64 = "8d0af9adbbde1a9791d10125f4742a4c9fa84f85ee46fe69adde6bf5e8a4a428",
osx_x86_64 = "5d0367dfd58ea894f87d1d6efbd800bf52820842e9151d265db17471bc69fe94",
win64 = "420cd7a1548a9c3ef5b5a7e969b6fcf8ee6a5a09cec99d7a3209406f028e5dce",
)

REPOSITORY_LOCATIONS_SPEC = dict(
Expand Down Expand Up @@ -309,11 +309,11 @@ REPOSITORY_LOCATIONS_SPEC = dict(
project_name = "libprotobuf-mutator",
project_desc = "Library to randomly mutate protobuffers",
project_url = "https://github.com/google/libprotobuf-mutator",
version = "1.1",
sha256 = "fd299fd72c5cf664259d9bd43a72cb74dc6a8b9604d107fe2d2e90885aeb7c16",
version = "3b28530531b154a748fe9884bc9219b4966f0754",
sha256 = "21bfdfef25554fa2e30aec2a9f9b58f4a17c1d8c8593763fa94a6dd74b226594",
strip_prefix = "libprotobuf-mutator-{version}",
urls = ["https://github.com/google/libprotobuf-mutator/archive/v{version}.tar.gz"],
release_date = "2022-10-13",
urls = ["https://github.com/google/libprotobuf-mutator/archive/{version}.tar.gz"],
release_date = "2023-04-25",
use_category = ["test_only"],
license = "Apache-2.0",
license_url = "https://github.com/google/libprotobuf-mutator/blob/v{version}/LICENSE",
Expand Down Expand Up @@ -365,12 +365,12 @@ REPOSITORY_LOCATIONS_SPEC = dict(
project_name = "gRPC",
project_desc = "gRPC C core library",
project_url = "https://grpc.io",
version = "1.49.2",
sha256 = "cdeb805385fba23242bf87073e68d590c446751e09089f26e5e0b3f655b0f089",
version = "1.55.0",
sha256 = "9cf1a69a921534ac0b760dcbefb900f3c2f735f56070bf0536506913bb5bfd74",
strip_prefix = "grpc-{version}",
urls = ["https://github.com/grpc/grpc/archive/v{version}.tar.gz"],
use_category = ["dataplane_core", "controlplane"],
release_date = "2022-12-09",
release_date = "2023-05-19",
cpe = "cpe:2.3:a:grpc:grpc:*",
license = "Apache-2.0",
license_url = "https://github.com/grpc/grpc/blob/v{version}/LICENSE",
Expand Down Expand Up @@ -825,11 +825,11 @@ REPOSITORY_LOCATIONS_SPEC = dict(
# test/common/json:gen_excluded_unicodes to recompute the ranges
# excluded from differential fuzzing that are populated in
# test/common/json/json_sanitizer_test_util.cc.
sha256 = "2c6a36c7b5a55accae063667ef3c55f2642e67476d96d355ff0acb13dbb47f09",
sha256 = "72bae766561149f8507a81647f91fc519d2a60309613f004ed307cb5f9b1242b",
strip_prefix = "protobuf-{version}",
urls = ["https://github.com/protocolbuffers/protobuf/releases/download/v{version}/protobuf-all-{version}.tar.gz"],
urls = ["https://github.com/protocolbuffers/protobuf/releases/download/v{version}/protobuf-{version}.tar.gz"],
use_category = ["dataplane_core", "controlplane"],
release_date = "2022-12-14",
release_date = "2023-05-17",
cpe = "cpe:2.3:a:google:protobuf:*",
license = "Protocol Buffers",
license_url = "https://github.com/protocolbuffers/protobuf/blob/v{version}/LICENSE",
Expand All @@ -838,17 +838,32 @@ REPOSITORY_LOCATIONS_SPEC = dict(
project_name = "grpc-httpjson-transcoding",
project_desc = "Library that supports transcoding so that HTTP/JSON can be converted to gRPC",
project_url = "https://github.com/grpc-ecosystem/grpc-httpjson-transcoding",
version = "387cce028806226ef0976ad276a3842a9219df99",
sha256 = "4a456dc58a9ae287e5afebc9e7033ff7c04d55e8c5f230d0dc0cf79672e33ae7",
version = "ff41eb3fc9209e6197595b54f7addfa244c0bdb6",
sha256 = "dea66b3d2dfc150373697e25b1327877e0b7480dc2bacfff1e3fd7aa00b12790",
strip_prefix = "grpc-httpjson-transcoding-{version}",
urls = ["https://github.com/grpc-ecosystem/grpc-httpjson-transcoding/archive/{version}.tar.gz"],
use_category = ["dataplane_ext"],
extensions = ["envoy.filters.http.grpc_json_transcoder"],
release_date = "2022-10-07",
release_date = "2023-06-07",
cpe = "N/A",
license = "Apache-2.0",
license_url = "https://github.com/grpc-ecosystem/grpc-httpjson-transcoding/blob/{version}/LICENSE",
),
com_google_protoconverter = dict(
project_name = "proto-converter",
project_desc = "Library that supports the conversion between protobuf binary and json",
project_url = "https://github.com/grpc-ecosystem/proto-converter",
version = "d77ff301f48bf2e7a0f8935315e847c1a8e00017",
sha256 = "6081836fa3838ebb1aa15089a5c3e20f877a0244c7a39b92a2000efb40408dcb",
strip_prefix = "proto-converter-{version}",
urls = ["https://github.com/grpc-ecosystem/proto-converter/archive/{version}.zip"],
use_category = ["dataplane_ext"],
extensions = ["envoy.filters.http.grpc_json_transcoder"],
release_date = "2023-06-07",
cpe = "N/A",
license = "Apache-2.0",
license_url = "https://github.com/grpc-ecosystem/proto-converter/blob/{version}/LICENSE",
),
io_bazel_rules_go = dict(
project_name = "Go rules for Bazel",
project_desc = "Bazel rules for the Go language",
Expand Down Expand Up @@ -893,6 +908,20 @@ REPOSITORY_LOCATIONS_SPEC = dict(
license = "Apache-2.0",
license_url = "https://github.com/bazelbuild/rules_python/blob/{version}/LICENSE",
),
rules_ruby = dict(
# This is needed only to compile protobuf, not used in Envoy code
project_name = "Ruby rules for Bazel",
project_desc = "Bazel rules for the Ruby language",
project_url = "https://github.com/protocolbuffers/rules_ruby",
version = "37cf5900d0b0e44fa379c0ea3f5fcee0035d77ca",
sha256 = "24ed42b7e06907be993b21be603c130076c7d7e49d4f4d5bd228c5656a257f5e",
release_date = "2023-02-08",
strip_prefix = "rules_ruby-{version}",
urls = ["https://github.com/protocolbuffers/rules_ruby/archive/{version}.tar.gz"],
use_category = ["build"],
license = "Apache-2.0",
license_url = "https://github.com/protocolbuffers/rules_ruby/blob/{version}/LICENSE",
),
rules_pkg = dict(
project_name = "Packaging rules for Bazel",
project_desc = "Bazel rules for the packaging distributions",
Expand Down Expand Up @@ -1177,9 +1206,9 @@ REPOSITORY_LOCATIONS_SPEC = dict(
project_name = "upb",
project_desc = "A small protobuf implementation in C (gRPC dependency)",
project_url = "https://github.com/protocolbuffers/upb",
version = "e4635f223e7d36dfbea3b722a4ca4807a7e882e2",
sha256 = "017a7e8e4e842d01dba5dc8aa316323eee080cd1b75986a7d1f94d87220e6502",
release_date = "2022-06-21",
version = "61a97efa24a5ce01fb8cc73c9d1e6e7060f8ea98",
sha256 = "7d19f2ac9c1e508a86a272913d9aa67c8147827f949035828910bb05d9f2cf03",
release_date = "2023-05-16",
strip_prefix = "upb-{version}",
urls = ["https://github.com/protocolbuffers/upb/archive/{version}.tar.gz"],
use_category = ["controlplane"],
Expand Down Expand Up @@ -1375,6 +1404,20 @@ REPOSITORY_LOCATIONS_SPEC = dict(
license = "Apache-2.0",
license_url = "https://github.com/bazelbuild/rules_license/blob/{version}/LICENSE",
),
utf8_range = dict(
project_name = "utf8_range",
project_desc = "Fast UTF-8 validation with Range algorithm (NEON+SSE4+AVX2)",
project_url = "https://github.com/protocolbuffers/utf8_range",
version = "d863bc33e15cba6d873c878dcca9e6fe52b2f8cb",
sha256 = "c56f0a8c562050e6523a3095cf5610d19c190cd99bac622cc3e5754be51aaa7b",
strip_prefix = "utf8_range-{version}",
urls = ["https://github.com/protocolbuffers/utf8_range/archive/{version}.tar.gz"],
use_category = ["build", "dataplane_core", "controlplane"],
release_date = "2023-05-26",
cpe = "N/A",
license = "MIT",
license_url = "https://github.com/protocolbuffers/utf8_range/blob/{version}/LICENSE",
),
)

def _compiled_protoc_deps(locations, versions):
Expand All @@ -1387,7 +1430,7 @@ def _compiled_protoc_deps(locations, versions):
sha256 = sha,
urls = ["https://github.com/protocolbuffers/protobuf/releases/download/v{version}/protoc-{version}-%s.zip" % platform.replace("_", "-", 1)],
use_category = ["dataplane_core", "controlplane"],
release_date = "2022-12-14",
release_date = "2023-05-17",
cpe = "N/A",
license = "Protocol Buffers",
license_url = "https://github.com/protocolbuffers/protobuf/blob/v{version}/LICENSE",
Expand Down
Loading

0 comments on commit b11dd38

Please sign in to comment.