Skip to content

Commit

Permalink
Add alwayslink = 1 to cc_libraries to ensure that their symbols are l…
Browse files Browse the repository at this point in the history
…inked past flipping --incompatible_remove_legacy_whole_archive flag
  • Loading branch information
scentini committed Aug 28, 2019
1 parent 9f8d8c0 commit 001117f
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 1 deletion.
3 changes: 3 additions & 0 deletions tensorflow/cc/saved_model/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ cc_library(
]) + if_android([
"//tensorflow/core:android_tensorflow_lib",
]),
alwayslink = 1,
)

cc_library(
Expand All @@ -105,6 +106,7 @@ cc_library(
"//tensorflow/core:protos_all_cc",
# mobile not supported yet
]),
alwayslink = 1,
)

cc_library(
Expand All @@ -123,6 +125,7 @@ cc_library(
"//tensorflow/core/util/tensor_bundle:naming",
# mobile not supported yet
]),
alwayslink = 1,
)

tf_cc_test(
Expand Down
2 changes: 2 additions & 0 deletions tensorflow/core/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -780,6 +780,7 @@ cc_library(
":lib_proto_parsing",
":protos_all_cc",
],
alwayslink = 1,
)

# DEPRECATED: use platform:stringpiece instead.
Expand Down Expand Up @@ -2504,6 +2505,7 @@ cc_library(
"@com_google_protobuf//:protobuf",
] + tf_protos_all_impl() + tf_protos_grappler_impl() +
tf_additional_numa_deps(),
alwayslink = 1,
)

# File compiled with extra flags to get cpu-specific acceleration.
Expand Down
7 changes: 6 additions & 1 deletion tensorflow/core/platform/default/build_config.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ def cc_proto_library(
# An empty cc_library to make rule dependency consistent.
native.cc_library(
name = name,
alwayslink = 1,
**kargs
)
return
Expand Down Expand Up @@ -228,12 +229,14 @@ def cc_proto_library(
hdrs = gen_hdrs,
deps = cc_libs + deps,
includes = includes,
alwayslink = 1,
**kargs
)
native.cc_library(
name = header_only_name,
deps = ["@com_google_protobuf//:protobuf_headers"] + if_static([impl_name]),
hdrs = gen_hdrs,
alwayslink = 1,
**kargs
)

Expand Down Expand Up @@ -343,7 +346,7 @@ def tf_proto_library_cc(
if not srcs:
# This is a collection of sub-libraries. Build header-only and impl
# libraries containing all the sources.
proto_gen(
proto_gen(y
name = cc_name + "_genproto",
protoc = "@com_google_protobuf//:protoc",
visibility = ["//visibility:public"],
Expand All @@ -354,10 +357,12 @@ def tf_proto_library_cc(
deps = cc_deps + ["@com_google_protobuf//:protobuf_headers"] + if_static([name + "_cc_impl"]),
testonly = testonly,
visibility = visibility,
alwayslink = 1,
)
native.cc_library(
name = cc_name + "_impl",
deps = [s + "_impl" for s in cc_deps] + ["@com_google_protobuf//:cc_wkt_protos"],
alwayslink = 1,
)

return
Expand Down
1 change: 1 addition & 0 deletions tensorflow/python/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -634,6 +634,7 @@ cc_library(
"//tensorflow/core:op_gen_lib",
"//tensorflow/core:protos_all_cc",
],
alwayslink = 1,
)

py_library(
Expand Down
2 changes: 2 additions & 0 deletions third_party/systemlibs/protobuf.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ def cc_proto_library(
# An empty cc_library to make rule dependency consistent.
native.cc_library(
name = name,
alwayslink = 1,
**kargs
)
return
Expand Down Expand Up @@ -262,6 +263,7 @@ def cc_proto_library(
hdrs = gen_hdrs,
deps = cc_libs + deps,
includes = includes,
alwayslink = 1,
**kargs
)

Expand Down

0 comments on commit 001117f

Please sign in to comment.