From f396035891b0938364ea247a7dd243a147930c6e Mon Sep 17 00:00:00 2001 From: "A. Unique TensorFlower" Date: Tue, 18 Feb 2020 14:36:47 -0800 Subject: [PATCH] Upgrade and rename external dependency grpc in workspace for bazel. Fixes #33758 Downstream projects depending on TensorFlow: If bazel complains, please substitute `@zlib_archive` with `@zlib`, and `@grpc` with `@com_github_grpc_grpc` in WORKPLACE. PiperOrigin-RevId: 295824868 Change-Id: If2259d59e9d82543369e5670916b1398374c9889 --- WORKSPACE | 25 ++++++++++++++++++ tensorflow/BUILD | 8 +++--- tensorflow/core/BUILD | 4 +-- tensorflow/core/debug/BUILD | 2 +- tensorflow/core/lib/io/BUILD | 6 ++--- tensorflow/core/lib/png/BUILD | 2 +- tensorflow/core/platform/BUILD | 2 +- .../core/platform/default/build_config/BUILD | 4 +-- tensorflow/tensorflow.bzl | 2 +- tensorflow/tools/ci_build/ci_sanity.sh | 24 +++++++++++++++-- tensorflow/tools/lib_package/BUILD | 14 +++++----- tensorflow/tools/pip_package/BUILD | 8 +++--- tensorflow/workspace.bzl | 26 +++++++++---------- third_party/curl.BUILD | 2 +- third_party/llvm/llvm.autogenerated.BUILD | 2 +- third_party/png.BUILD | 2 +- third_party/protobuf/protobuf.patch | 2 +- third_party/systemlibs/syslibs_configure.bzl | 4 +-- 18 files changed, 91 insertions(+), 48 deletions(-) diff --git a/WORKSPACE b/WORKSPACE index 0139c4aa643..ad645add449 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -113,3 +113,28 @@ http_archive( "https://storage.googleapis.com/download.tensorflow.org/models/speech_commands_v0.01.zip", ], ) + +# Required for dependency @com_github_grpc_grpc + +load("@com_github_grpc_grpc//bazel:grpc_deps.bzl", "grpc_deps") + +grpc_deps() + +load( + "@build_bazel_rules_apple//apple:repositories.bzl", + "apple_rules_dependencies", +) + +apple_rules_dependencies() + +load( + "@build_bazel_apple_support//lib:repositories.bzl", + "apple_support_dependencies", +) + +apple_support_dependencies() + +load("@upb//bazel:repository_defs.bzl", "bazel_version_repository") + +bazel_version_repository(name = "bazel_version") + diff --git a/tensorflow/BUILD b/tensorflow/BUILD index 31efafb7801..55406a5686a 100644 --- a/tensorflow/BUILD +++ b/tensorflow/BUILD @@ -547,8 +547,8 @@ cc_library( name = "grpc", visibility = ["//visibility:public"], deps = select({ - ":linux_s390x": ["@grpc//:grpc_unsecure"], - "//conditions:default": ["@grpc"], + ":linux_s390x": ["@com_github_grpc_grpc//:grpc_unsecure"], + "//conditions:default": ["@com_github_grpc_grpc//:grpc"], }), ) @@ -556,8 +556,8 @@ cc_library( name = "grpc++", visibility = ["//visibility:public"], deps = select({ - ":linux_s390x": ["@grpc//:grpc++_unsecure"], - "//conditions:default": ["@grpc//:grpc++"], + ":linux_s390x": ["@com_github_grpc_grpc//:grpc++_unsecure"], + "//conditions:default": ["@com_github_grpc_grpc//:grpc++"], }), ) diff --git a/tensorflow/core/BUILD b/tensorflow/core/BUILD index 4f0df417037..5002f80c059 100644 --- a/tensorflow/core/BUILD +++ b/tensorflow/core/BUILD @@ -1997,7 +1997,7 @@ cc_library( "//tensorflow/core/util:env_var", "//tensorflow/core/util:reporter", # TODO(gunan): REMOVE as soon as cc_shared_library is supported. "@snappy", - "@zlib_archive//:zlib", + "@zlib", "@double_conversion//:double-conversion", "@com_google_protobuf//:protobuf", ] + tf_protos_all_impl() + tf_protos_grappler_impl() + tf_protos_profiler_impl(), @@ -3077,7 +3077,7 @@ tf_cc_tests( "@com_google_absl//absl/strings", "@com_google_absl//absl/synchronization", "@com_google_absl//absl/types:optional", - "@zlib_archive//:zlib", + "@zlib", ], ) diff --git a/tensorflow/core/debug/BUILD b/tensorflow/core/debug/BUILD index 4cf8bc3588e..d9dfbc16677 100644 --- a/tensorflow/core/debug/BUILD +++ b/tensorflow/core/debug/BUILD @@ -38,7 +38,7 @@ package( # Check that tensorflow/core:tensorflow does not depend on grpc. check_deps( name = "core_tensorflow_check_deps", - disallowed_deps = ["@grpc//:grpc++"], + disallowed_deps = ["@com_github_grpc_grpc//:grpc++"], deps = ["//tensorflow/core:tensorflow"], ) diff --git a/tensorflow/core/lib/io/BUILD b/tensorflow/core/lib/io/BUILD index 68dff3009fa..87b5090a59f 100644 --- a/tensorflow/core/lib/io/BUILD +++ b/tensorflow/core/lib/io/BUILD @@ -240,7 +240,7 @@ cc_library( hdrs = ["zlib_compression_options.h"], deps = [ "//tensorflow/core/platform:types", - "@zlib_archive//:zlib", + "@zlib", ], alwayslink = True, ) @@ -258,7 +258,7 @@ cc_library( "//tensorflow/core/platform:macros", "//tensorflow/core/platform:strcat", "//tensorflow/core/platform:types", - "@zlib_archive//:zlib", + "@zlib", ], alwayslink = True, ) @@ -275,7 +275,7 @@ cc_library( "//tensorflow/core/platform:env", "//tensorflow/core/platform:macros", "//tensorflow/core/platform:types", - "@zlib_archive//:zlib", + "@zlib", ], alwayslink = True, ) diff --git a/tensorflow/core/lib/png/BUILD b/tensorflow/core/lib/png/BUILD index db2ab4801ee..7abc82e6a0f 100644 --- a/tensorflow/core/lib/png/BUILD +++ b/tensorflow/core/lib/png/BUILD @@ -22,7 +22,7 @@ cc_library( "//tensorflow/core/platform:stringpiece", "//tensorflow/core/platform:types", "@com_google_absl//absl/base", - "@zlib_archive//:zlib", + "@zlib", ], ) diff --git a/tensorflow/core/platform/BUILD b/tensorflow/core/platform/BUILD index b992f1abdfb..1b03357f48e 100644 --- a/tensorflow/core/platform/BUILD +++ b/tensorflow/core/platform/BUILD @@ -899,7 +899,7 @@ tf_cc_tests( "@com_google_absl//absl/strings", "@com_google_absl//absl/synchronization", "@com_google_absl//absl/types:optional", - "@zlib_archive//:zlib", + "@zlib", ], ) diff --git a/tensorflow/core/platform/default/build_config/BUILD b/tensorflow/core/platform/default/build_config/BUILD index 7545bc5b2c0..20f0e9e42d9 100644 --- a/tensorflow/core/platform/default/build_config/BUILD +++ b/tensorflow/core/platform/default/build_config/BUILD @@ -153,7 +153,7 @@ cc_library( "@farmhash_archive//:farmhash", "@fft2d", "@highwayhash//:sip_hash", - "@zlib_archive//:zlib", + "@zlib", ], ) @@ -178,7 +178,7 @@ cc_library( copts = tf_copts(), deps = [ "@png", - "@zlib_archive//:zlib", + "@zlib", ], ) diff --git a/tensorflow/tensorflow.bzl b/tensorflow/tensorflow.bzl index 2beac63feb4..f86010cef2a 100644 --- a/tensorflow/tensorflow.bzl +++ b/tensorflow/tensorflow.bzl @@ -1758,7 +1758,7 @@ def transitive_hdrs(name, deps = [], **kwargs): # # For: # * Eigen: it's a header-only library. Add it directly to your deps. -# * GRPC: add a direct dep on @grpc//:grpc++_public_hdrs. +# * GRPC: add a direct dep on @com_github_grpc_grpc//:grpc++_public_hdrs. # def cc_header_only_library(name, deps = [], includes = [], extra_deps = [], **kwargs): _transitive_hdrs(name = name + "_gather", deps = deps) diff --git a/tensorflow/tools/ci_build/ci_sanity.sh b/tensorflow/tools/ci_build/ci_sanity.sh index 7189a636a29..9397bbd4f60 100755 --- a/tensorflow/tools/ci_build/ci_sanity.sh +++ b/tensorflow/tools/ci_build/ci_sanity.sh @@ -357,12 +357,32 @@ do_external_licenses_check(){ # Blacklist echo ${MISSING_LICENSES_FILE} - grep -e "@bazel_tools//third_party/" -e "@bazel_tools//tools" -e "@local" -e "@com_google_absl//absl" -e "@org_tensorflow//" -e "@com_github_googlecloudplatform_google_cloud_cpp//google" -v ${MISSING_LICENSES_FILE} > temp.txt + grep \ + -e "@bazel_tools//third_party/" \ + -e "@bazel_tools//tools" \ + -e "@local" \ + -e "@com_google_absl//absl" \ + -e "@org_tensorflow//" \ + -e "@com_github_googlecloudplatform_google_cloud_cpp//google" \ + -e "@com_github_grpc_grpc//src/compiler" \ + -e "@platforms//os" \ + -v ${MISSING_LICENSES_FILE} > temp.txt mv temp.txt ${MISSING_LICENSES_FILE} # Whitelist echo ${EXTRA_LICENSE_FILE} - grep -e "//third_party/mkl_dnn" -e "@bazel_tools//src" -e "@bazel_tools//tools/" -e "@org_tensorflow//tensorflow" -e "@com_google_absl//" -e "//external" -e "@local" -e "@com_github_googlecloudplatform_google_cloud_cpp//" -e "@embedded_jdk//" -e "^//$" -v ${EXTRA_LICENSES_FILE} > temp.txt + grep \ + -e "//third_party/mkl_dnn" \ + -e "@bazel_tools//src" \ + -e "@bazel_tools//tools/" \ + -e "@org_tensorflow//tensorflow" \ + -e "@com_google_absl//" \ + -e "//external" \ + -e "@local" \ + -e "@com_github_googlecloudplatform_google_cloud_cpp//" \ + -e "@embedded_jdk//" \ + -e "^//$" \ + -v ${EXTRA_LICENSES_FILE} > temp.txt mv temp.txt ${EXTRA_LICENSES_FILE} diff --git a/tensorflow/tools/lib_package/BUILD b/tensorflow/tools/lib_package/BUILD index fb88a61b424..d68d8c333b5 100644 --- a/tensorflow/tools/lib_package/BUILD +++ b/tensorflow/tools/lib_package/BUILD @@ -164,7 +164,7 @@ genrule( "@six_archive//:LICENSE", "@snappy//:COPYING", "@sobol_data//:LICENSE", - "@zlib_archive//:zlib.h", + "@zlib//:zlib.h", ] + select({ "//tensorflow:android": [], "//tensorflow:ios": [], @@ -200,10 +200,10 @@ genrule( "//third_party/mkl:LICENSE", "//third_party/mkl_dnn:LICENSE", ]) + if_not_system_lib( - "grpc", + "com_github_grpc_grpc", [ - "@grpc//:LICENSE", - "@grpc//third_party/address_sorting:LICENSE", + "@com_github_grpc_grpc//:LICENSE", + "@com_github_grpc_grpc//third_party/address_sorting:LICENSE", ], ) + tf_additional_license_deps(), outs = ["THIRD_PARTY_TF_C_LICENSES"], @@ -228,8 +228,8 @@ genrule( "@fft2d//:fft2d/readme2d.txt", "@gemmlowp//:LICENSE", "@gif//:COPYING", - "@grpc//:LICENSE", - "@grpc//third_party/address_sorting:LICENSE", + "@com_github_grpc_grpc//:LICENSE", + "@com_github_grpc_grpc//third_party/address_sorting:LICENSE", "@highwayhash//:LICENSE", "@icu//:icu4j/main/shared/licenses/LICENSE", "@libjpeg_turbo//:LICENSE.md", @@ -244,7 +244,7 @@ genrule( "@six_archive//:LICENSE", "@snappy//:COPYING", "@sobol_data//:LICENSE", - "@zlib_archive//:zlib.h", + "@zlib//:zlib.h", ] + select({ "//tensorflow:android": [], "//tensorflow:ios": [], diff --git a/tensorflow/tools/pip_package/BUILD b/tensorflow/tools/pip_package/BUILD index f6e17a6e46c..c50dea89482 100644 --- a/tensorflow/tools/pip_package/BUILD +++ b/tensorflow/tools/pip_package/BUILD @@ -190,7 +190,7 @@ filegroup( "@sobol_data//:LICENSE", "@swig//:LICENSE", "@termcolor_archive//:COPYING.txt", - "@zlib_archive//:zlib.h", + "@zlib//:zlib.h", ] + select({ "//tensorflow:android": [], "//tensorflow:ios": [], @@ -235,10 +235,10 @@ filegroup( "@absl_py//absl/third_party/unittest3_backport:LICENSE", ], ) + if_not_system_lib( - "grpc", + "com_github_grpc_grpc", [ - "@grpc//:LICENSE", - "@grpc//third_party/address_sorting:LICENSE", + "@com_github_grpc_grpc//:LICENSE", + "@com_github_grpc_grpc//third_party/address_sorting:LICENSE", ], ) + if_ngraph([ "@ngraph//:LICENSE", diff --git a/tensorflow/workspace.bzl b/tensorflow/workspace.bzl index dfe6a9e4499..6d74a7fed92 100755 --- a/tensorflow/workspace.bzl +++ b/tensorflow/workspace.bzl @@ -476,8 +476,6 @@ def tf_repositories(path_prefix = "", tf_repo_name = ""): 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( @@ -562,20 +560,20 @@ def tf_repositories(path_prefix = "", tf_repo_name = ""): # WARNING: make sure ncteisen@ and vpai@ are cc-ed on any CL to change the below rule tf_http_archive( - name = "grpc", - sha256 = "67a6c26db56f345f7cee846e681db2c23f919eba46dd639b09462d1b6203d28c", - strip_prefix = "grpc-4566c2a29ebec0835643b972eb99f4306c4234a3", + name = "com_github_grpc_grpc", + sha256 = "b956598d8cbe168b5ee717b5dafa56563eb5201a947856a6688bbeac9cac4e1f", + strip_prefix = "grpc-b54a5b338637f92bfcf4b0bc05e0f57a5fd8fadd", system_build_file = clean_dep("//third_party/systemlibs:grpc.BUILD"), urls = [ - "https://storage.googleapis.com/mirror.tensorflow.org/github.com/grpc/grpc/archive/4566c2a29ebec0835643b972eb99f4306c4234a3.tar.gz", - "https://github.com/grpc/grpc/archive/4566c2a29ebec0835643b972eb99f4306c4234a3.tar.gz", + "https://storage.googleapis.com/mirror.tensorflow.org/github.com/grpc/grpc/archive/b54a5b338637f92bfcf4b0bc05e0f57a5fd8fadd.tar.gz", + "https://github.com/grpc/grpc/archive/b54a5b338637f92bfcf4b0bc05e0f57a5fd8fadd.tar.gz", ], ) tf_http_archive( name = "com_github_nanopb_nanopb", sha256 = "8bbbb1e78d4ddb0a1919276924ab10d11b631df48b657d960e0c795a25515735", - build_file = "@grpc//third_party:nanopb.BUILD", + build_file = "@com_github_grpc_grpc//third_party:nanopb.BUILD", strip_prefix = "nanopb-f8ac463766281625ad710900479130c7fcb4d63b", urls = [ "https://storage.googleapis.com/mirror.tensorflow.org/github.com/nanopb/nanopb/archive/f8ac463766281625ad710900479130c7fcb4d63b.tar.gz", @@ -649,7 +647,7 @@ def tf_repositories(path_prefix = "", tf_repo_name = ""): ) tf_http_archive( - name = "zlib_archive", + name = "zlib", build_file = clean_dep("//third_party:zlib.BUILD"), sha256 = "c3e5e9fdd5004dcb542feda5ee4f0ff0744628baf8ed2dd5d66f8ca1197cb1a1", strip_prefix = "zlib-1.2.11", @@ -1071,21 +1069,21 @@ def tf_bind(): # Needed by Protobuf native.bind( name = "grpc_cpp_plugin", - actual = "@grpc//:grpc_cpp_plugin", + actual = "@com_github_grpc_grpc//src/compiler:grpc_cpp_plugin", ) native.bind( name = "grpc_python_plugin", - actual = "@grpc//:grpc_python_plugin", + actual = "@com_github_grpc_grpc//src/compiler:grpc_python_plugin", ) native.bind( name = "grpc_lib", - actual = "@grpc//:grpc++", + actual = "@com_github_grpc_grpc//:grpc++", ) native.bind( name = "grpc_lib_unsecure", - actual = "@grpc//:grpc++_unsecure", + actual = "@com_github_grpc_grpc//:grpc++_unsecure", ) # Needed by gRPC @@ -1134,5 +1132,5 @@ def tf_bind(): # Needed by gRPC native.bind( name = "zlib", - actual = "@zlib_archive//:zlib", + actual = "@zlib", ) diff --git a/third_party/curl.BUILD b/third_party/curl.BUILD index 10316df91e3..f3a7e3f59e7 100644 --- a/third_party/curl.BUILD +++ b/third_party/curl.BUILD @@ -321,7 +321,7 @@ cc_library( }), visibility = ["//visibility:public"], deps = [ - "@zlib_archive//:zlib", + "@zlib", ] + select({ "@org_tensorflow//tensorflow:ios": [], "@org_tensorflow//tensorflow:windows": [], diff --git a/third_party/llvm/llvm.autogenerated.BUILD b/third_party/llvm/llvm.autogenerated.BUILD index 8c53968111b..c80a2d2fce2 100644 --- a/third_party/llvm/llvm.autogenerated.BUILD +++ b/third_party/llvm/llvm.autogenerated.BUILD @@ -3752,7 +3752,7 @@ cc_library( deps = [ ":config", ":demangle", - "@zlib_archive//:zlib", + "@zlib", ], ) diff --git a/third_party/png.BUILD b/third_party/png.BUILD index e82948648e4..719d4c7c670 100644 --- a/third_party/png.BUILD +++ b/third_party/png.BUILD @@ -54,7 +54,7 @@ cc_library( "//conditions:default": ["-lm"], }), visibility = ["//visibility:public"], - deps = ["@zlib_archive//:zlib"], + deps = ["@zlib"], ) genrule( diff --git a/third_party/protobuf/protobuf.patch b/third_party/protobuf/protobuf.patch index efbe3340169..decd92e9d03 100644 --- a/third_party/protobuf/protobuf.patch +++ b/third_party/protobuf/protobuf.patch @@ -7,7 +7,7 @@ index 2fb26050..c2744d5b 100644 ################################################################################ -ZLIB_DEPS = ["@zlib//:zlib"] -+ZLIB_DEPS = ["@zlib_archive//:zlib"] ++ZLIB_DEPS = ["@zlib"] ################################################################################ # Protobuf Runtime Library diff --git a/third_party/systemlibs/syslibs_configure.bzl b/third_party/systemlibs/syslibs_configure.bzl index 0cfc289dffd..7a96fdf9d21 100644 --- a/third_party/systemlibs/syslibs_configure.bzl +++ b/third_party/systemlibs/syslibs_configure.bzl @@ -14,6 +14,7 @@ VALID_LIBS = [ "boringssl", "com_github_googleapis_googleapis", "com_github_googlecloudplatform_google_cloud_cpp", + "com_github_grpc_grpc", "com_google_protobuf", "com_googlesource_code_re2", "curl", @@ -24,7 +25,6 @@ VALID_LIBS = [ "functools32_archive", "gast_archive", "gif", - "grpc", "hwloc", "icu", "jsoncpp_git", @@ -42,7 +42,7 @@ VALID_LIBS = [ "swig", "termcolor_archive", "wrapt", - "zlib_archive", + "zlib", ] def auto_configure_fail(msg):