Skip to content

Commit

Permalink
[Thirdparty] Upgrade protobuf to 3.9.2.
Browse files Browse the repository at this point in the history
Signed-off-by: Tongxuan Liu <tongxuan.ltx@alibaba-inc.com>
  • Loading branch information
liutongxuan committed Apr 19, 2023
1 parent 3bc930a commit 9e65506
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 30 deletions.
2 changes: 1 addition & 1 deletion tensorflow/tools/pip_package/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
'numpy >= 1.16.0, < 1.19.0',
'opt_einsum >= 2.3.2',
'six >= 1.10.0',
'protobuf >= 3.6.1',
'protobuf >= 3.9.2',
'tensorboard >= 1.15.0, < 1.16.0',
'tensorflow-estimator >= 1.15.1, < 1.15.5',
'termcolor >= 1.1.0',
Expand Down
23 changes: 7 additions & 16 deletions tensorflow/workspace.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -511,28 +511,19 @@ def tf_repositories(path_prefix = "", tf_repo_name = ""):
},
)

# 310ba5ee72661c081129eb878c1bbcec936b20f0 is based on 3.8.0 with a fix for protobuf.bzl.
PROTOBUF_URLS = [
"https://storage.googleapis.com/mirror.tensorflow.org/github.com/protocolbuffers/protobuf/archive/310ba5ee72661c081129eb878c1bbcec936b20f0.tar.gz",
"https://github.com/protocolbuffers/protobuf/archive/310ba5ee72661c081129eb878c1bbcec936b20f0.tar.gz",
]
PROTOBUF_SHA256 = "b9e92f9af8819bbbc514e2902aec860415b70209f31dfc8c4fa72515a5df9d59"
PROTOBUF_STRIP_PREFIX = "protobuf-310ba5ee72661c081129eb878c1bbcec936b20f0"

# protobuf depends on @zlib, it has to be renamed to @zlib_archive because "zlib" is already
# defined using bind for grpc.
PROTOBUF_PATCH = "//third_party/protobuf:protobuf.patch"

tf_http_archive(
name = "com_google_protobuf", # MIT license
patch_file = [clean_dep(PROTOBUF_PATCH)],
sha256 = PROTOBUF_SHA256,
strip_prefix = PROTOBUF_STRIP_PREFIX,
patch_file = [clean_dep("//third_party/protobuf:protobuf.patch")],
sha256 = "cfcba2df10feec52a84208693937c17a4b5df7775e1635c1e3baffc487b24c9b",
strip_prefix = "protobuf-3.9.2",
system_build_file = clean_dep("//third_party/systemlibs:protobuf.BUILD"),
system_link_files = {
"//third_party/systemlibs:protobuf.bzl": "protobuf.bzl",
},
urls = PROTOBUF_URLS,
urls = [
"https://storage.googleapis.com/mirror.tensorflow.org/github.com/protocolbuffers/protobuf/archive/v3.9.2.zip",
"https://github.com/protocolbuffers/protobuf/archive/v3.9.2.zip",
],
)

tf_http_archive(
Expand Down
39 changes: 26 additions & 13 deletions third_party/protobuf/protobuf.patch
Original file line number Diff line number Diff line change
@@ -1,30 +1,43 @@
diff --git a/BUILD b/BUILD
index 2fb26050..c2744d5b 100644
index dbae719ff..87dc38470 100644
--- a/BUILD
+++ b/BUILD
@@ -19,7 +19,7 @@ config_setting(
@@ -23,7 +23,7 @@ config_setting(
# ZLIB configuration
################################################################################

-ZLIB_DEPS = ["@zlib//:zlib"]
+ZLIB_DEPS = ["@zlib_archive//:zlib"]
+ZLIB_DEPS = ["@zlib"]

################################################################################
# Protobuf Runtime Library
@@ -209,6 +209,7 @@ cc_library(
@@ -143,6 +143,7 @@ cc_library(
copts = COPTS,
includes = ["src/"],
linkopts = LINK_OPTS,
+ alwayslink = 1,
visibility = ["//visibility:public"],
deps = [":protobuf_lite"] + PROTOBUF_DEPS,
)
@@ -219,7 +220,7 @@ cc_library(
# TODO(keveman): Remove this target once the support gets added to Bazel.
cc_library(
name = "protobuf_headers",
- hdrs = glob(["src/**/*.h"]),
+ hdrs = glob(["src/**/*.h", "src/**/*.inc"]),

@@ -213,6 +214,7 @@ cc_library(
copts = COPTS,
includes = ["src/"],
linkopts = LINK_OPTS,
+ alwayslink = 1,
visibility = ["//visibility:public"],
deps = [":protobuf_lite"] + PROTOBUF_DEPS,
)
diff --git a/protobuf.bzl b/protobuf.bzl
index e0653321f..253d9cbb5 100644
--- a/protobuf.bzl
+++ b/protobuf.bzl
@@ -84,7 +84,9 @@ def _proto_gen_impl(ctx):

for dep in ctx.attr.deps:
import_flags += dep.proto.import_flags
deps += dep.proto.deps
+ import_flags = depset(import_flags).to_list()
+ deps = depset(deps).to_list()

if not ctx.attr.gen_cc and not ctx.attr.gen_py and not ctx.executable.plugin:
return struct(

0 comments on commit 9e65506

Please sign in to comment.