Skip to content

Commit 8f81cfb

Browse files
beckerheGoogle-ML-Automation
authored andcommitted
Fix protobuf dependencies in OSS
Since the builtin proto targets that come with the protobuf package are now supported in OSS, we can get rid of the `if_google` guards. Also we will need these explicit dependencies in OSS for the layering check. PiperOrigin-RevId: 837119260
1 parent 457056f commit 8f81cfb

File tree

4 files changed

+24
-11
lines changed

4 files changed

+24
-11
lines changed

xla/service/gpu/transforms/BUILD

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ load(
66
"if_gpu_is_configured",
77
)
88
load("//xla/tests:build_defs.bzl", "xla_test")
9-
load("//xla/tsl:tsl.bzl", "if_google", "if_oss")
9+
load("//xla/tsl:tsl.bzl", "if_oss")
1010
load(
1111
"//xla/tsl/platform:build_config_root.bzl",
1212
"tf_gpu_tests_tags",
@@ -812,14 +812,13 @@ cc_library(
812812
"@com_google_absl//absl/status:statusor",
813813
"@com_google_absl//absl/strings",
814814
"@com_google_absl//absl/types:span",
815+
"@com_google_protobuf//:wrappers_cc_proto",
815816
"@tsl//tsl/platform:errors",
816817
"@tsl//tsl/platform:logging",
817818
"@tsl//tsl/platform:statusor",
818819
] + if_cuda_is_configured([
819820
"@local_config_cuda//cuda:cuda_headers",
820821
"@local_config_cuda//cuda:cudnn_header",
821-
]) + if_google([
822-
"@com_google_protobuf//:wrappers_cc_proto",
823822
]),
824823
)
825824

xla/stream_executor/BUILD

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,8 @@ cc_library(
200200
"@com_google_absl//absl/status",
201201
"@com_google_absl//absl/status:statusor",
202202
"@com_google_absl//absl/types:span",
203-
] + if_google(["@com_google_protobuf//:wrappers_cc_proto"]),
203+
"@com_google_protobuf//:wrappers_cc_proto",
204+
],
204205
)
205206

206207
cc_library(
@@ -372,13 +373,14 @@ cc_library(
372373
"@com_google_absl//absl/strings",
373374
"@com_google_absl//absl/strings:str_format",
374375
"@com_google_absl//absl/types:span",
376+
"@com_google_protobuf//:wrappers_cc_proto",
375377
"@eigen_archive//:eigen3", # buildcleaner: keep
376378
"@tsl//tsl/platform:errors",
377379
"@tsl//tsl/platform:logging",
378380
"@tsl//tsl/platform:ml_dtypes",
379381
"@tsl//tsl/platform:status",
380382
"@tsl//tsl/platform:statusor",
381-
] + if_google(["@com_google_protobuf//:wrappers_cc_proto"]),
383+
],
382384
)
383385

384386
tf_proto_library(

xla/tools/BUILD

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1027,6 +1027,7 @@ tsl_gpu_library(
10271027
"@com_google_absl//absl/status:statusor",
10281028
"@com_google_absl//absl/strings",
10291029
"@com_google_absl//absl/synchronization",
1030+
"@com_google_protobuf//:duration_cc_proto",
10301031
"@com_google_protobuf//:protobuf",
10311032
"@llvm-project//mlir:ArithDialect",
10321033
"@llvm-project//mlir:FuncDialect",
@@ -1045,7 +1046,7 @@ tsl_gpu_library(
10451046
"//xla/service/gpu:nvptx_compiler",
10461047
]) + if_rocm_is_configured([
10471048
"//xla/service/gpu:amdgpu_compiler",
1048-
]) + if_google(["@com_google_protobuf//:duration_cc_proto"]),
1049+
]),
10491050
)
10501051

10511052
xla_test(
@@ -1079,14 +1080,15 @@ xla_test(
10791080
"@com_google_absl//absl/strings",
10801081
"@com_google_absl//absl/synchronization",
10811082
"@com_google_googletest//:gtest",
1083+
"@com_google_protobuf//:duration_cc_proto",
10821084
"@tsl//tsl/platform:env",
10831085
"@tsl//tsl/platform:env_time",
10841086
"@tsl//tsl/platform:errors",
10851087
"@tsl//tsl/platform:path",
10861088
"@tsl//tsl/platform:status_matchers",
10871089
"@tsl//tsl/platform:statusor",
10881090
"@tsl//tsl/platform:test",
1089-
] + if_google(["@com_google_protobuf//:duration_cc_proto"]) + if_cuda([
1091+
] + if_cuda([
10901092
"//xla/tsl/cuda:nvml",
10911093
]),
10921094
)

xla/tsl/platform/default/build_config.bzl

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -419,18 +419,28 @@ def tf_fingerprint_deps():
419419
"@farmhash_archive//:farmhash",
420420
]
421421

422+
def _protobuf_deps():
423+
return [
424+
clean_dep("@com_google_protobuf//:delimited_message_util"),
425+
clean_dep("@com_google_protobuf//:differencer"),
426+
clean_dep("@com_google_protobuf//:json_util"),
427+
clean_dep("@com_google_protobuf//:type_resolver"),
428+
clean_dep("@com_google_protobuf//:protobuf"),
429+
clean_dep("@com_google_protobuf//:protobuf_lite"),
430+
clean_dep("@com_google_protobuf//src/google/protobuf/io"),
431+
clean_dep("@com_google_protobuf//src/google/protobuf/io:tokenizer"),
432+
]
433+
422434
def tf_protobuf_deps():
423435
return if_static(
424-
[
425-
clean_dep("@com_google_protobuf//:protobuf"),
426-
],
436+
_protobuf_deps(),
427437
otherwise = [clean_dep("@com_google_protobuf//:protobuf_headers")],
428438
)
429439

430440
# TODO(b/356020232): remove completely after migration is done
431441
# Link protobuf, unless the tsl_link_protobuf build flag is explicitly set to false.
432442
def tsl_protobuf_deps():
433-
return if_tsl_link_protobuf([clean_dep("@com_google_protobuf//:protobuf")], [clean_dep("@com_google_protobuf//:protobuf_headers")])
443+
return if_tsl_link_protobuf(_protobuf_deps(), [clean_dep("@com_google_protobuf//:protobuf_headers")])
434444

435445
def strict_cc_test(
436446
name,

0 commit comments

Comments
 (0)