Rolling forward the addition of build flag --experimental_cc_shared_library to tf/.bazelrc after patching the iOS build failure. This basically is e635ec06c6 with an additional patch to rules_swift. This change is part of the build refactoring described in https://github.com/tensorflow/community/pull/179

PiperOrigin-RevId: 289909322
Change-Id: I06f10d811f0ca598047e837acc0230afbf290e6f
This commit is contained in:
Smit Hinsu 2020-01-15 12:07:13 -08:00 committed by TensorFlower Gardener
parent 9a021222ac
commit b7f05ca3e4
24 changed files with 18 additions and 145 deletions

View File

@ -123,11 +123,6 @@ build:monolithic --define framework_shared_object=false
# opts in to modular op registration support by default. # opts in to modular op registration support by default.
build --define framework_shared_object=true build --define framework_shared_object=true
# As part of Tensorflow's build refactoring, https://github.com/tensorflow/community/pull/179,
# we plan on migrating TF to use bazel's cc_shared_library. This requires always setting
# the flag "--experimental_cc_shared_library" on all builds: https://github.com/bazelbuild/rules_cc/blob/7e650b11fe6d49f70f2ca7a1c4cb8bcc4a1fe239/examples/experimental_cc_shared_library.bzl#L3-L5
build --experimental_cc_shared_library
# Flags for open source build, always set to be true. # Flags for open source build, always set to be true.
build --define open_source_build=true build --define open_source_build=true
test --define open_source_build=true test --define open_source_build=true

View File

@ -478,7 +478,6 @@ bzl_library(
visibility = ["//visibility:public"], visibility = ["//visibility:public"],
deps = [ deps = [
"//tensorflow/core/platform:build_config_root_bzl", "//tensorflow/core/platform:build_config_root_bzl",
"//tensorflow/core/platform:rules_cc_bzl",
"//tensorflow/core/platform/default:cuda_build_defs_bzl", "//tensorflow/core/platform/default:cuda_build_defs_bzl",
"//third_party/mkl:build_defs_bzl", "//third_party/mkl:build_defs_bzl",
"//third_party/mkl_dnn:build_defs_bzl", "//third_party/mkl_dnn:build_defs_bzl",

View File

@ -132,10 +132,6 @@ load(
"tf_protos_profiler_impl", "tf_protos_profiler_impl",
"tf_pyclif_proto_library", "tf_pyclif_proto_library",
) )
load(
"//tensorflow/core/platform:rules_cc.bzl",
"cc_library",
)
load( load(
"//tensorflow/core/platform:build_config_root.bzl", "//tensorflow/core/platform:build_config_root.bzl",
"if_dynamic_kernels", "if_dynamic_kernels",

View File

@ -15,10 +15,6 @@ load(
"//tensorflow/core/platform:build_config_root.bzl", "//tensorflow/core/platform:build_config_root.bzl",
"if_static", "if_static",
) )
load(
"//tensorflow/core/platform:rules_cc.bzl",
"cc_library",
)
package( package(
default_visibility = [ default_visibility = [

View File

@ -1,8 +1,3 @@
load(
"//tensorflow/core/platform:rules_cc.bzl",
"cc_library",
)
package( package(
default_visibility = [ default_visibility = [
"//tensorflow:__subpackages__", "//tensorflow:__subpackages__",

View File

@ -1,8 +1,4 @@
load("//tensorflow/core/platform:build_config.bzl", "tf_proto_library") load("//tensorflow/core/platform:build_config.bzl", "tf_proto_library")
load(
"//tensorflow/core/platform:rules_cc.bzl",
"cc_library",
)
package( package(
default_visibility = [ default_visibility = [

View File

@ -2,10 +2,6 @@
# Libraries for storing tensors in SQL databases. # Libraries for storing tensors in SQL databases.
load("//tensorflow:tensorflow.bzl", "tf_cc_test", "tf_copts") load("//tensorflow:tensorflow.bzl", "tf_cc_test", "tf_copts")
load(
"//tensorflow/core/platform:rules_cc.bzl",
"cc_library",
)
package( package(
default_visibility = ["//tensorflow:internal"], default_visibility = ["//tensorflow:internal"],

View File

@ -1,8 +1,3 @@
load(
"//tensorflow/core/platform:rules_cc.bzl",
"cc_library",
)
package( package(
default_visibility = [ default_visibility = [
# tensorflow/core:lib effectively exposes all targets under tensorflow/core/lib/** # tensorflow/core:lib effectively exposes all targets under tensorflow/core/lib/**

View File

@ -3,10 +3,6 @@ load(
"if_linux_x86_64", "if_linux_x86_64",
"tf_copts", "tf_copts",
) )
load(
"//tensorflow/core/platform:rules_cc.bzl",
"cc_library",
)
package( package(
default_visibility = [ default_visibility = [

View File

@ -1,8 +1,3 @@
load(
"//tensorflow/core/platform:rules_cc.bzl",
"cc_library",
)
package( package(
default_visibility = [ default_visibility = [
# tensorflow/core:lib effectively exposes all targets under tensorflow/core/lib/** # tensorflow/core:lib effectively exposes all targets under tensorflow/core/lib/**

View File

@ -1,8 +1,3 @@
load(
"//tensorflow/core/platform:rules_cc.bzl",
"cc_library",
)
package( package(
default_visibility = [ default_visibility = [
"//tensorflow/c/experimental/filesystem:__pkg__", "//tensorflow/c/experimental/filesystem:__pkg__",

View File

@ -1,8 +1,3 @@
load(
"//tensorflow/core/platform:rules_cc.bzl",
"cc_library",
)
package( package(
default_visibility = [ default_visibility = [
"//tensorflow:__subpackages__", "//tensorflow:__subpackages__",

View File

@ -1,8 +1,3 @@
load(
"//tensorflow/core/platform:rules_cc.bzl",
"cc_library",
)
package( package(
default_visibility = [ default_visibility = [
# tensorflow/core:lib effectively exposes all targets under tensorflow/core/lib/** # tensorflow/core:lib effectively exposes all targets under tensorflow/core/lib/**

View File

@ -1,8 +1,3 @@
load(
"//tensorflow/core/platform:rules_cc.bzl",
"cc_library",
)
package( package(
default_visibility = [ default_visibility = [
# tensorflow/core:lib effectively exposes all targets under tensorflow/core/lib/** # tensorflow/core:lib effectively exposes all targets under tensorflow/core/lib/**

View File

@ -1,8 +1,3 @@
load(
"//tensorflow/core/platform:rules_cc.bzl",
"cc_library",
)
package( package(
default_visibility = [ default_visibility = [
# tensorflow/core:lib effectively exposes all targets under tensorflow/core/lib/** # tensorflow/core:lib effectively exposes all targets under tensorflow/core/lib/**

View File

@ -1,8 +1,3 @@
load(
"//tensorflow/core/platform:rules_cc.bzl",
"cc_library",
)
package( package(
default_visibility = [ default_visibility = [
# tensorflow/core:lib effectively exposes all targets under tensorflow/core/lib/** # tensorflow/core:lib effectively exposes all targets under tensorflow/core/lib/**

View File

@ -30,11 +30,6 @@ load(
"tf_protobuf_deps", "tf_protobuf_deps",
"tf_windows_aware_platform_deps", "tf_windows_aware_platform_deps",
) )
load(
"//tensorflow/core/platform:rules_cc.bzl",
"cc_binary",
"cc_library",
)
load( load(
"//tensorflow:tensorflow.bzl", "//tensorflow:tensorflow.bzl",
"if_not_android", "if_not_android",
@ -1467,12 +1462,6 @@ bzl_library(
name = "build_config_root_bzl", name = "build_config_root_bzl",
srcs = [ srcs = [
"build_config_root.bzl", "build_config_root.bzl",
] + tf_platform_alias("build_config_root.bzl"), "//tensorflow/core/platform/default:build_config_root.bzl",
) ],
bzl_library(
name = "rules_cc_bzl",
srcs = [
"rules_cc.bzl",
] + tf_platform_alias("rules_cc.bzl"),
) )

View File

@ -1,10 +1,6 @@
# Tensorflow default + linux implementations of tensorflow/core/platform libraries. # Tensorflow default + linux implementations of tensorflow/core/platform libraries.
load("@bazel_skylib//:bzl_library.bzl", "bzl_library") load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
load("//tensorflow:tensorflow.bzl", "tf_copts") load("//tensorflow:tensorflow.bzl", "tf_copts")
load(
"//tensorflow/core/platform:rules_cc.bzl",
"cc_library",
)
package( package(
default_visibility = [ default_visibility = [

View File

@ -4,10 +4,6 @@ load(
"if_windows", "if_windows",
"tf_copts", "tf_copts",
) )
load(
"//tensorflow/core/platform:rules_cc.bzl",
"cc_library",
)
package( package(
default_visibility = [ default_visibility = [

View File

@ -3,10 +3,6 @@ load(
"tf_kernel_tests_linkstatic", "tf_kernel_tests_linkstatic",
"tf_proto_library", "tf_proto_library",
) )
load(
"//tensorflow/core/platform:rules_cc.bzl",
"cc_library",
)
load( load(
"//tensorflow:tensorflow.bzl", "//tensorflow:tensorflow.bzl",
"tf_cc_test", "tf_cc_test",

View File

@ -147,7 +147,6 @@ tensorflow/third_party/pybind11.BUILD
tensorflow/third_party/python_runtime/BUILD tensorflow/third_party/python_runtime/BUILD
tensorflow/third_party/repo.bzl tensorflow/third_party/repo.bzl
tensorflow/third_party/rules_closure.patch tensorflow/third_party/rules_closure.patch
tensorflow/third_party/rules_swift.patch
tensorflow/third_party/six.BUILD tensorflow/third_party/six.BUILD
tensorflow/third_party/snappy.BUILD tensorflow/third_party/snappy.BUILD
tensorflow/third_party/sqlite.BUILD tensorflow/third_party/sqlite.BUILD

View File

@ -11,12 +11,6 @@ load(
"tf_gpu_tests_tags", "tf_gpu_tests_tags",
"tf_sycl_tests_tags", "tf_sycl_tests_tags",
) )
load(
"//tensorflow/core/platform:rules_cc.bzl",
"cc_binary",
"cc_library",
"cc_test",
)
load( load(
"@local_config_tensorrt//:build_defs.bzl", "@local_config_tensorrt//:build_defs.bzl",
"if_tensorrt", "if_tensorrt",
@ -117,7 +111,7 @@ def tf_android_core_proto_headers(core_proto_sources_relative):
# Wrapper for portable protos which currently just creates an empty rule. # Wrapper for portable protos which currently just creates an empty rule.
def tf_portable_proto_library(name, proto_deps, deps = [], **kwargs): def tf_portable_proto_library(name, proto_deps, deps = [], **kwargs):
_ignore = [kwargs] _ignore = [kwargs]
cc_library(name = name, deps = deps + [dep + "_cc" for dep in proto_deps]) native.cc_library(name = name, deps = deps + [dep + "_cc" for dep in proto_deps])
# Sanitize a dependency so that it works correctly from code that includes # Sanitize a dependency so that it works correctly from code that includes
# TensorFlow as a submodule. # TensorFlow as a submodule.
@ -366,7 +360,7 @@ def tf_gen_op_libs(op_lib_names, deps = None, is_external = True):
if not deps: if not deps:
deps = [] deps = []
for n in op_lib_names: for n in op_lib_names:
cc_library( native.cc_library(
name = n + "_op_lib", name = n + "_op_lib",
copts = tf_copts(is_external = is_external), copts = tf_copts(is_external = is_external),
srcs = ["ops/" + n + ".cc"], srcs = ["ops/" + n + ".cc"],
@ -570,7 +564,7 @@ def tf_cc_shared_object(
if framework_so != []: if framework_so != []:
data_extra = tf_binary_additional_data_deps() data_extra = tf_binary_additional_data_deps()
cc_binary( native.cc_binary(
name = name_os_full, name = name_os_full,
srcs = srcs + framework_so, srcs = srcs + framework_so,
deps = deps, deps = deps,
@ -631,7 +625,7 @@ def tf_cc_binary(
else: else:
names = [name] names = [name]
for name_os in names: for name_os in names:
cc_binary( native.cc_binary(
name = name_os, name = name_os,
copts = copts, copts = copts,
srcs = srcs + tf_binary_additional_srcs(), srcs = srcs + tf_binary_additional_srcs(),
@ -674,7 +668,7 @@ def tf_native_cc_binary(
copts = tf_copts(), copts = tf_copts(),
linkopts = [], linkopts = [],
**kwargs): **kwargs):
cc_binary( native.cc_binary(
name = name, name = name,
copts = copts, copts = copts,
linkopts = select({ linkopts = select({
@ -814,7 +808,7 @@ def tf_gen_op_wrappers_cc(
internalsrcs += ["ops/" + n + "_internal.cc"] internalsrcs += ["ops/" + n + "_internal.cc"]
internalhdrs += ["ops/" + n + "_internal.h"] internalhdrs += ["ops/" + n + "_internal.h"]
cc_library( native.cc_library(
name = name, name = name,
srcs = subsrcs, srcs = subsrcs,
hdrs = subhdrs, hdrs = subhdrs,
@ -831,7 +825,7 @@ def tf_gen_op_wrappers_cc(
alwayslink = 1, alwayslink = 1,
visibility = visibility, visibility = visibility,
) )
cc_library( native.cc_library(
name = name + "_internal", name = name + "_internal",
srcs = internalsrcs, srcs = internalsrcs,
hdrs = internalhdrs, hdrs = internalhdrs,
@ -995,7 +989,7 @@ def tf_cc_test(
linkopts = [], linkopts = [],
kernels = [], kernels = [],
**kwargs): **kwargs):
cc_test( native.cc_test(
name = "%s%s" % (name, suffix), name = "%s%s" % (name, suffix),
srcs = srcs + tf_binary_additional_srcs(), srcs = srcs + tf_binary_additional_srcs(),
copts = tf_copts() + extra_copts, copts = tf_copts() + extra_copts,
@ -1152,7 +1146,7 @@ def tf_gpu_only_cc_test(
deps = deps, deps = deps,
testonly = 1, testonly = 1,
) )
cc_test( native.cc_test(
name = "%s%s" % (name, "_gpu"), name = "%s%s" % (name, "_gpu"),
size = size, size = size,
args = args, args = args,
@ -1239,7 +1233,7 @@ def tf_cc_test_mkl(
disable_header_modules = ["-use_header_modules"] disable_header_modules = ["-use_header_modules"]
for src in srcs: for src in srcs:
cc_test( native.cc_test(
name = src_to_test_name(src), name = src_to_test_name(src),
srcs = if_mkl([src]) + tf_binary_additional_srcs(), srcs = if_mkl([src]) + tf_binary_additional_srcs(),
copts = tf_copts(allow_exceptions = True) + tf_openmp_copts(), copts = tf_copts(allow_exceptions = True) + tf_openmp_copts(),
@ -1401,7 +1395,7 @@ def tf_gpu_library(deps = None, cuda_deps = None, copts = tf_copts(), **kwargs):
cuda_deps = [] cuda_deps = []
kwargs["features"] = kwargs.get("features", []) + ["-use_header_modules"] kwargs["features"] = kwargs.get("features", []) + ["-use_header_modules"]
cc_library( native.cc_library(
deps = deps + if_cuda_is_configured_compat(cuda_deps + [ deps = deps + if_cuda_is_configured_compat(cuda_deps + [
clean_dep("//tensorflow/stream_executor/cuda:cudart_stub"), clean_dep("//tensorflow/stream_executor/cuda:cudart_stub"),
"@local_config_cuda//cuda:cuda_headers", "@local_config_cuda//cuda:cuda_headers",
@ -1569,7 +1563,7 @@ def tf_mkl_kernel_library(
# -fno-exceptions in nocopts breaks compilation if header modules are enabled. # -fno-exceptions in nocopts breaks compilation if header modules are enabled.
disable_header_modules = ["-use_header_modules"] disable_header_modules = ["-use_header_modules"]
cc_library( native.cc_library(
name = name, name = name,
srcs = if_mkl(srcs), srcs = if_mkl(srcs),
hdrs = hdrs, hdrs = hdrs,
@ -1722,7 +1716,7 @@ def transitive_hdrs(name, deps = [], **kwargs):
# the libraries in deps. # the libraries in deps.
def cc_header_only_library(name, deps = [], includes = [], extra_deps = [], **kwargs): def cc_header_only_library(name, deps = [], includes = [], extra_deps = [], **kwargs):
_transitive_hdrs(name = name + "_gather", deps = deps) _transitive_hdrs(name = name + "_gather", deps = deps)
cc_library( native.cc_library(
name = name, name = name,
hdrs = [":" + name + "_gather"], hdrs = [":" + name + "_gather"],
includes = includes, includes = includes,
@ -2370,7 +2364,7 @@ def tf_generate_proto_text_sources(name, srcs_relative_dir, srcs, protodeps = []
visibility = visibility, visibility = visibility,
) )
cc_library( native.cc_library(
name = name, name = name,
srcs = out_srcs, srcs = out_srcs,
hdrs = out_hdrs, hdrs = out_hdrs,
@ -2426,7 +2420,7 @@ def cc_library_with_android_deps(
copts = tf_copts(), copts = tf_copts(),
**kwargs): **kwargs):
deps = if_not_android(deps) + if_android(android_deps) + common_deps deps = if_not_android(deps) + if_android(android_deps) + common_deps
cc_library(deps = deps, copts = copts, **kwargs) native.cc_library(deps = deps, copts = copts, **kwargs)
register_extension_info( register_extension_info(
extension_name = "cc_library_with_android_deps", extension_name = "cc_library_with_android_deps",
@ -2487,7 +2481,7 @@ def pybind_extension(
visibility = ["//visibility:private"], visibility = ["//visibility:private"],
testonly = testonly, testonly = testonly,
) )
cc_binary( native.cc_binary(
name = so_file, name = so_file,
srcs = srcs + hdrs, srcs = srcs + hdrs,
data = data, data = data,

View File

@ -903,7 +903,6 @@ def tf_repositories(path_prefix = "", tf_repo_name = ""):
# https://github.com/bazelbuild/rules_swift/releases # https://github.com/bazelbuild/rules_swift/releases
tf_http_archive( tf_http_archive(
name = "build_bazel_rules_swift", name = "build_bazel_rules_swift",
patch_file = clean_dep("//third_party:rules_swift.patch"),
sha256 = "18cd4df4e410b0439a4935f9ca035bd979993d42372ba79e7f2d4fafe9596ef0", sha256 = "18cd4df4e410b0439a4935f9ca035bd979993d42372ba79e7f2d4fafe9596ef0",
urls = [ urls = [
"http://mirror.tensorflow.org/github.com/bazelbuild/rules_swift/releases/download/0.12.1/rules_swift.0.12.1.tar.gz", "http://mirror.tensorflow.org/github.com/bazelbuild/rules_swift/releases/download/0.12.1/rules_swift.0.12.1.tar.gz",

View File

@ -1,25 +0,0 @@
From 4c1a4d676d1633ff9f67bda3540d24ea5fa31c8f Mon Sep 17 00:00:00 2001
From: Brian Zhao <bmzhao@google.com>
Date: Tue, 14 Jan 2020 18:23:34 -0800
Subject: [PATCH] Adding linker_inputs flag to create_linking_context, in
preparation for bazel's cc_shared_library rule. Note that this cannot be
enabled as of now unless --experimental_cc_shared_library is passed to bazel.
---
swift/internal/utils.bzl | 1 +
1 file changed, 1 insertion(+)
diff --git a/swift/internal/utils.bzl b/swift/internal/utils.bzl
index 5cf1498..44d7559 100644
--- a/swift/internal/utils.bzl
+++ b/swift/internal/utils.bzl
@@ -98,6 +98,7 @@ def create_cc_info(
this_cc_info = CcInfo(
linking_context = cc_common.create_linking_context(
+ linker_inputs = None,
additional_inputs = all_additional_inputs,
libraries_to_link = libraries_to_link,
user_link_flags = all_user_link_flags,
--
2.25.0.rc1.283.g88dfdc4193-goog