diff --git a/.bazelrc b/.bazelrc index f1d84afc993..97b50e43147 100644 --- a/.bazelrc +++ b/.bazelrc @@ -216,6 +216,8 @@ build --announce_rc # Other build flags. build --define=grpc_no_ares=true +build --incompatible_remove_legacy_whole_archive + # Modular TF build options build:dynamic_kernels --define=dynamic_loaded_kernels=true build:dynamic_kernels --copt=-DAUTOLOAD_DYNAMIC_KERNELS diff --git a/WORKSPACE b/WORKSPACE index afa4fa7b1a8..a29c6e3df63 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -6,6 +6,8 @@ http_archive( name = "io_bazel_rules_closure", sha256 = "5b00383d08dd71f28503736db0500b6fb4dda47489ff5fc6bed42557c07c6ba9", strip_prefix = "rules_closure-308b05b2419edb5c8ee0471b67a40403df940149", + patch_args = ["-p1"], + patches = ["//third_party:io_bazel_rules_closure.patch"], urls = [ "https://storage.googleapis.com/mirror.tensorflow.org/github.com/bazelbuild/rules_closure/archive/308b05b2419edb5c8ee0471b67a40403df940149.tar.gz", "https://github.com/bazelbuild/rules_closure/archive/308b05b2419edb5c8ee0471b67a40403df940149.tar.gz", # 2019-06-13 diff --git a/serving/configure.py b/serving/configure.py index 0aa695bfb60..8e86ebb271d 100644 --- a/serving/configure.py +++ b/serving/configure.py @@ -26,6 +26,7 @@ def write_config(): bazel_rc.write('build --define grpc_no_ares=true\n') bazel_rc.write('build --define open_source_build=true\n') + bazel_rc.write('build --spawn_strategy=standalone\n') bazel_rc.write('build --cxxopt="-std=c++14"\n') bazel_rc.write('build --host_cxxopt=-std=c++14\n') bazel_rc.write('build --action_env TF_USE_CCACHE="0"\n') diff --git a/tensorflow/BUILD b/tensorflow/BUILD index 493247a2162..a8d4a46dc17 100644 --- a/tensorflow/BUILD +++ b/tensorflow/BUILD @@ -622,6 +622,18 @@ tf_cc_shared_object( ] + tf_additional_binary_deps(), ) +# This is intended to be the same as tf_binary_additional_srcs: +# https://github.com/tensorflow/tensorflow/blob/cd67f4f3723f9165aabedd0171aaadc6290636e5/tensorflow/tensorflow.bzl#L396-L425 +# And is usable in the "deps" attribute instead of the "srcs" attribute +# as a workaround for https://github.com/tensorflow/tensorflow/issues/34117 +cc_import( + name = "libtensorflow_framework_import_lib", + shared_library = select({ + "//tensorflow:macos": ":libtensorflow_framework.dylib", + "//conditions:default": ":libtensorflow_framework.so", + }), +) + # ------------------------------------------- # New rules should be added above this target. # ------------------------------------------- @@ -684,6 +696,7 @@ tf_cc_shared_object( per_os_targets = True, soversion = VERSION, visibility = ["//visibility:public"], + linkstatic = 1, # add win_def_file for tensorflow_cc win_def_file = select({ # We need this DEF file to properly export symbols on Windows @@ -706,6 +719,21 @@ tf_cc_shared_object( "//tensorflow/contrib/tensor_forest:model_ops_lib", "//tensorflow/contrib/tensor_forest:forest_proto_impl", "//tensorflow/contrib/tensor_forest/kernels/v4:decision-tree-resource_impl", + "//tensorflow/core:lib", + "//tensorflow/core:lib_internal", + "//tensorflow/core:lib_internal_impl", + "//tensorflow/core:core_cpu_impl", + "//tensorflow/core:framework_internal", + "//tensorflow/core:framework_internal_impl", + "//tensorflow/core:gpu_runtime_impl", + "//tensorflow/cc/saved_model:loader", + "//tensorflow/cc/saved_model:loader_lite", + "//tensorflow/cc/saved_model:loader_lite_impl", + "//tensorflow/stream_executor:dnn_proto_cc", + "//tensorflow/stream_executor:dnn_proto_cc_impl", + "//tensorflow/core/platform:tensor_float_32_utils", + "//tensorflow/core/grappler/optimizers:custom_graph_optimizer_registry_impl", + "@nsync//:nsync_cpp", ] + if_ngraph(["@ngraph_tf//:ngraph_tf"]), ) diff --git a/tensorflow/c/BUILD b/tensorflow/c/BUILD index 47c98b52df0..cf1add0f292 100644 --- a/tensorflow/c/BUILD +++ b/tensorflow/c/BUILD @@ -86,6 +86,7 @@ tf_cuda_library( ":tf_status_internal", ":tf_tensor_internal", ], + alwayslink = 1, ) cc_library( @@ -110,6 +111,8 @@ tf_cuda_library( ":c_api_internal", ":tf_attrtype", ":tf_status_internal", + ":tf_status", + "@com_google_protobuf//:protobuf", ] + select({ "//tensorflow:with_xla_support": [ "//tensorflow/compiler/tf2xla:xla_compiler", @@ -117,6 +120,7 @@ tf_cuda_library( ], "//conditions:default": [], }), + alwayslink = 1, ) tf_cuda_library( @@ -176,6 +180,7 @@ tf_cuda_library( "//tensorflow/core:lib", ], }), + alwayslink = 1, ) cc_library( @@ -192,6 +197,7 @@ cc_library( "//tensorflow/core:lib", ], }), + alwayslink = 1, ) cc_library( diff --git a/tensorflow/core/platform/BUILD b/tensorflow/core/platform/BUILD index e897a606aa3..aa008551de9 100644 --- a/tensorflow/core/platform/BUILD +++ b/tensorflow/core/platform/BUILD @@ -86,6 +86,7 @@ cc_library( ":platform", ":types", ], + alwayslink = 1, ) cc_library( @@ -176,6 +177,7 @@ cc_library( "platform_strings_computed.h", ], hdrs = ["platform_strings.h"], + alwayslink = 1, ) cc_library( diff --git a/tensorflow/tensorflow.bzl b/tensorflow/tensorflow.bzl index b2644a95730..ed93dc75b22 100644 --- a/tensorflow/tensorflow.bzl +++ b/tensorflow/tensorflow.bzl @@ -629,6 +629,11 @@ def tf_cc_binary( [ clean_dep("//third_party/mkl:intel_binary_blob"), ], + ) + if_static( + extra_deps = [], + otherwise = [ + clean_dep("//tensorflow:libtensorflow_framework_import_lib"), + ], ), data = depset(data + added_data_deps), linkopts = linkopts + _rpath_linkopts(name_os), diff --git a/tensorflow/tools/pip_package/setup.py b/tensorflow/tools/pip_package/setup.py index 32b84a44ac4..06b7084aa77 100644 --- a/tensorflow/tools/pip_package/setup.py +++ b/tensorflow/tools/pip_package/setup.py @@ -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', diff --git a/tensorflow/workspace.bzl b/tensorflow/workspace.bzl index a04b7b6f908..46af6074a5d 100755 --- a/tensorflow/workspace.bzl +++ b/tensorflow/workspace.bzl @@ -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( diff --git a/third_party/io_bazel_rules_closure.patch b/third_party/io_bazel_rules_closure.patch new file mode 100644 index 00000000000..c367ff97017 --- /dev/null +++ b/third_party/io_bazel_rules_closure.patch @@ -0,0 +1,37 @@ +From 18efd193ad8e10e2ea95bcf1754459fe34f6e96a Mon Sep 17 00:00:00 2001 +From: Tongxuan Liu +Date: Thu, 27 Apr 2023 16:10:04 +0800 +Subject: [PATCH] update zlib urls. + +--- + WORKSPACE | 2 +- + closure/repositories.bzl | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +diff --git a/WORKSPACE b/WORKSPACE +index cb9eee5..1b03da7 100644 +--- a/WORKSPACE ++++ b/WORKSPACE +@@ -11,7 +11,7 @@ http_archive( + build_file = "//:third_party/zlib.BUILD", + sha256 = "c3e5e9fdd5004dcb542feda5ee4f0ff0744628baf8ed2dd5d66f8ca1197cb1a1", + strip_prefix = "zlib-1.2.11", +- urls = ["https://zlib.net/zlib-1.2.11.tar.gz"], ++ urls = ["https://mirror.bazel.build/zlib.net/zlib-1.2.11.tar.gz"], + ) + + http_archive( +diff --git a/closure/repositories.bzl b/closure/repositories.bzl +index f21ff2b..dee10ba 100644 +--- a/closure/repositories.bzl ++++ b/closure/repositories.bzl +@@ -1005,5 +1005,5 @@ def zlib(): + build_file = "@io_bazel_rules_closure//:third_party/zlib.BUILD", + sha256 = "c3e5e9fdd5004dcb542feda5ee4f0ff0744628baf8ed2dd5d66f8ca1197cb1a1", + strip_prefix = "zlib-1.2.11", +- urls = ["https://zlib.net/zlib-1.2.11.tar.gz"], ++ urls = ["https://mirror.bazel.build/zlib.net/zlib-1.2.11.tar.gz"], + ) +-- +2.37.1 + diff --git a/third_party/protobuf/protobuf.patch b/third_party/protobuf/protobuf.patch index 4e053c4310e..f8830f00134 100644 --- a/third_party/protobuf/protobuf.patch +++ b/third_party/protobuf/protobuf.patch @@ -1,30 +1,69 @@ +From 92fc8b1f8fe8bc095708f200fa59e7808ef55fc0 Mon Sep 17 00:00:00 2001 +From: Tongxuan Liu +Date: Thu, 20 Apr 2023 19:11:22 +0800 +Subject: [PATCH] Protobuf patch for DeepRec. + +--- + BUILD | 4 +++- + protobuf.bzl | 2 ++ + protobuf_deps.bzl | 2 +- + 3 files changed, 6 insertions(+), 2 deletions(-) + diff --git a/BUILD b/BUILD -index 2fb26050..c2744d5b 100644 +index dbae719..87dc384 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 e065332..92ae3b4 100644 +--- a/protobuf.bzl ++++ b/protobuf.bzl +@@ -85,6 +85,8 @@ 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( +diff --git a/protobuf_deps.bzl b/protobuf_deps.bzl +index 57509ee..00325aa 100644 +--- a/protobuf_deps.bzl ++++ b/protobuf_deps.bzl +@@ -11,7 +11,7 @@ def protobuf_deps(): + build_file = "@com_google_protobuf//:third_party/zlib.BUILD", + sha256 = "c3e5e9fdd5004dcb542feda5ee4f0ff0744628baf8ed2dd5d66f8ca1197cb1a1", + strip_prefix = "zlib-1.2.11", +- urls = ["https://zlib.net/zlib-1.2.11.tar.gz"], ++ urls = ["https://mirror.bazel.build/zlib.net/zlib-1.2.11.tar.gz"], + ) + + if not native.existing_rule("six"): +-- +2.37.1 +