Skip to content

Commit b2aaf0f

Browse files
committed
[BUILD] Support to build GPU with Bazel>=1.0.0.
Cherry-pick from TF: 5caa9e8 Signed-off-by: Tongxuan Liu <tongxuan.ltx@alibaba-inc.com>
1 parent 9e65506 commit b2aaf0f

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

.bazelrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,8 @@ build --announce_rc
216216
# Other build flags.
217217
build --define=grpc_no_ares=true
218218

219+
build --incompatible_remove_legacy_whole_archive
220+
219221
# Modular TF build options
220222
build:dynamic_kernels --define=dynamic_loaded_kernels=true
221223
build:dynamic_kernels --copt=-DAUTOLOAD_DYNAMIC_KERNELS

tensorflow/BUILD

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -622,6 +622,18 @@ tf_cc_shared_object(
622622
] + tf_additional_binary_deps(),
623623
)
624624

625+
# This is intended to be the same as tf_binary_additional_srcs:
626+
# https://github.com/tensorflow/tensorflow/blob/cd67f4f3723f9165aabedd0171aaadc6290636e5/tensorflow/tensorflow.bzl#L396-L425
627+
# And is usable in the "deps" attribute instead of the "srcs" attribute
628+
# as a workaround for https://github.com/tensorflow/tensorflow/issues/34117
629+
cc_import(
630+
name = "libtensorflow_framework_import_lib",
631+
shared_library = select({
632+
"//tensorflow:macos": ":libtensorflow_framework.dylib",
633+
"//conditions:default": ":libtensorflow_framework.so",
634+
}),
635+
)
636+
625637
# -------------------------------------------
626638
# New rules should be added above this target.
627639
# -------------------------------------------

tensorflow/tensorflow.bzl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -629,6 +629,11 @@ def tf_cc_binary(
629629
[
630630
clean_dep("//third_party/mkl:intel_binary_blob"),
631631
],
632+
) + if_static(
633+
extra_deps = [],
634+
otherwise = [
635+
clean_dep("//tensorflow:libtensorflow_framework_import_lib"),
636+
],
632637
),
633638
data = depset(data + added_data_deps),
634639
linkopts = linkopts + _rpath_linkopts(name_os),

0 commit comments

Comments
 (0)