Skip to content

Commit 046d157

Browse files
committed
[Thirdparty] Upgrade protobuf to 3.9.2.
Signed-off-by: Tongxuan Liu <tongxuan.ltx@alibaba-inc.com>
1 parent 3bc930a commit 046d157

File tree

3 files changed

+34
-30
lines changed

3 files changed

+34
-30
lines changed

tensorflow/tools/pip_package/setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
'numpy >= 1.16.0, < 1.19.0',
6767
'opt_einsum >= 2.3.2',
6868
'six >= 1.10.0',
69-
'protobuf >= 3.6.1',
69+
'protobuf >= 3.9.2',
7070
'tensorboard >= 1.15.0, < 1.16.0',
7171
'tensorflow-estimator >= 1.15.1, < 1.15.5',
7272
'termcolor >= 1.1.0',

tensorflow/workspace.bzl

+7-16
Original file line numberDiff line numberDiff line change
@@ -511,28 +511,19 @@ def tf_repositories(path_prefix = "", tf_repo_name = ""):
511511
},
512512
)
513513

514-
# 310ba5ee72661c081129eb878c1bbcec936b20f0 is based on 3.8.0 with a fix for protobuf.bzl.
515-
PROTOBUF_URLS = [
516-
"https://storage.googleapis.com/mirror.tensorflow.org/github.com/protocolbuffers/protobuf/archive/310ba5ee72661c081129eb878c1bbcec936b20f0.tar.gz",
517-
"https://github.com/protocolbuffers/protobuf/archive/310ba5ee72661c081129eb878c1bbcec936b20f0.tar.gz",
518-
]
519-
PROTOBUF_SHA256 = "b9e92f9af8819bbbc514e2902aec860415b70209f31dfc8c4fa72515a5df9d59"
520-
PROTOBUF_STRIP_PREFIX = "protobuf-310ba5ee72661c081129eb878c1bbcec936b20f0"
521-
522-
# protobuf depends on @zlib, it has to be renamed to @zlib_archive because "zlib" is already
523-
# defined using bind for grpc.
524-
PROTOBUF_PATCH = "//third_party/protobuf:protobuf.patch"
525-
526514
tf_http_archive(
527515
name = "com_google_protobuf", # MIT license
528-
patch_file = [clean_dep(PROTOBUF_PATCH)],
529-
sha256 = PROTOBUF_SHA256,
530-
strip_prefix = PROTOBUF_STRIP_PREFIX,
516+
patch_file = clean_dep("//third_party/protobuf:protobuf.patch"),
517+
sha256 = "cfcba2df10feec52a84208693937c17a4b5df7775e1635c1e3baffc487b24c9b",
518+
strip_prefix = "protobuf-3.9.2",
531519
system_build_file = clean_dep("//third_party/systemlibs:protobuf.BUILD"),
532520
system_link_files = {
533521
"//third_party/systemlibs:protobuf.bzl": "protobuf.bzl",
534522
},
535-
urls = PROTOBUF_URLS,
523+
urls = [
524+
"https://storage.googleapis.com/mirror.tensorflow.org/github.com/protocolbuffers/protobuf/archive/v3.9.2.zip",
525+
"https://github.com/protocolbuffers/protobuf/archive/v3.9.2.zip",
526+
],
536527
)
537528

538529
tf_http_archive(

third_party/protobuf/protobuf.patch

+26-13
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,43 @@
11
diff --git a/BUILD b/BUILD
2-
index 2fb26050..c2744d5b 100644
2+
index dbae719ff..87dc38470 100644
33
--- a/BUILD
44
+++ b/BUILD
5-
@@ -19,7 +19,7 @@ config_setting(
5+
@@ -23,7 +23,7 @@ config_setting(
66
# ZLIB configuration
77
################################################################################
8-
8+
99
-ZLIB_DEPS = ["@zlib//:zlib"]
10-
+ZLIB_DEPS = ["@zlib_archive//:zlib"]
11-
10+
+ZLIB_DEPS = ["@zlib"]
11+
1212
################################################################################
1313
# Protobuf Runtime Library
14-
@@ -209,6 +209,7 @@ cc_library(
14+
@@ -143,6 +143,7 @@ cc_library(
1515
copts = COPTS,
1616
includes = ["src/"],
1717
linkopts = LINK_OPTS,
1818
+ alwayslink = 1,
1919
visibility = ["//visibility:public"],
20-
deps = [":protobuf_lite"] + PROTOBUF_DEPS,
2120
)
22-
@@ -219,7 +220,7 @@ cc_library(
23-
# TODO(keveman): Remove this target once the support gets added to Bazel.
24-
cc_library(
25-
name = "protobuf_headers",
26-
- hdrs = glob(["src/**/*.h"]),
27-
+ hdrs = glob(["src/**/*.h", "src/**/*.inc"]),
21+
22+
@@ -213,6 +214,7 @@ cc_library(
23+
copts = COPTS,
2824
includes = ["src/"],
25+
linkopts = LINK_OPTS,
26+
+ alwayslink = 1,
2927
visibility = ["//visibility:public"],
28+
deps = [":protobuf_lite"] + PROTOBUF_DEPS,
3029
)
30+
diff --git a/protobuf.bzl b/protobuf.bzl
31+
index e0653321f..253d9cbb5 100644
32+
--- a/protobuf.bzl
33+
+++ b/protobuf.bzl
34+
@@ -84,7 +84,9 @@ def _proto_gen_impl(ctx):
35+
36+
for dep in ctx.attr.deps:
37+
import_flags += dep.proto.import_flags
38+
deps += dep.proto.deps
39+
+ import_flags = depset(import_flags).to_list()
40+
+ deps = depset(deps).to_list()
41+
42+
if not ctx.attr.gen_cc and not ctx.attr.gen_py and not ctx.executable.plugin:
43+
return struct(

0 commit comments

Comments
 (0)