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: 289776116
Change-Id: I7f29e0e0b4447334a334ad888f464e12fbe29485
This commit is contained in:
Brian Zhao 2020-01-14 18:51:50 -08:00 committed by TensorFlower Gardener
parent b0bcaca5ee
commit e3668c51b1
24 changed files with 145 additions and 18 deletions

View File

@ -123,6 +123,11 @@ build:monolithic --define framework_shared_object=false
# opts in to modular op registration support by default.
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.
build --define open_source_build=true
test --define open_source_build=true

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

25
third_party/rules_swift.patch vendored Normal file
View File

@ -0,0 +1,25 @@
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