Skip to content

Commit

Permalink
Make tsl_cc_test default to linkstatic to catch duplicate symbols at …
Browse files Browse the repository at this point in the history
…build time.

PiperOrigin-RevId: 726616180
  • Loading branch information
Google-ML-Automation committed Feb 13, 2025
1 parent e19d695 commit 4c37dda
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions third_party/tsl/tsl/platform/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -764,6 +764,7 @@ tsl_cc_test(
srcs = [
"stacktrace_handler_test.cc",
],
linkstatic = False, # In the OSS build, static linking affects the stacktrace.
tags = ["no_windows"],
deps = [
":stacktrace",
Expand Down Expand Up @@ -998,6 +999,7 @@ tsl_cc_test(
srcs = [
"stacktrace_test.cc",
],
linkstatic = False, # In the OSS build, static linking affects the stacktrace.
tags = ["no_windows"],
deps = [
":stacktrace",
Expand Down
5 changes: 5 additions & 0 deletions xla/tsl/platform/default/build_config.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -814,15 +814,20 @@ def tsl_protobuf_deps():
# back into our binaries explicitly.
def tsl_cc_test(
name,
linkstatic = True,
deps = [],
**kwargs):
"""A wrapper around cc_test that adds protobuf deps if needed.
It also defaults to linkstatic = True, which is a good practice for catching duplicate
symbols at link time (e.g. linking in two main() functions).
Use tsl_cc_test instead of cc_test in all .../tsl/... directories.
"""

native.cc_test(
name = name,
linkstatic = linkstatic,
deps = deps + if_tsl_link_protobuf(
[],
[
Expand Down
2 changes: 2 additions & 0 deletions xla/tsl/profiler/rpc/client/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ cc_library(
tsl_cc_test(
name = "profiler_client_test",
srcs = ["profiler_client_test.cc"],
linkstatic = False, # This test is incompatible with linkstatic in the OSS build.
deps = [
":profiler_client",
":profiler_client_impl", # for oss
Expand Down Expand Up @@ -199,6 +200,7 @@ cc_library(
tsl_cc_test(
name = "remote_profiler_session_manager_test",
srcs = ["remote_profiler_session_manager_test.cc"],
linkstatic = False, # This test is incompatible with linkstatic in the OSS build.
deps = [
":profiler_client_impl", # for oss
":profiler_client_test_util",
Expand Down

0 comments on commit 4c37dda

Please sign in to comment.