Skip to content

Commit 285fdce

Browse files
Googlercopybara-github
authored andcommitted
Factor out function should_create_test_dwp_for_statically_linked_test
PiperOrigin-RevId: 827968328 Change-Id: Ibb35c4aa4ae13a01fed8e7419df1b3f7942d8630
1 parent b5a6559 commit 285fdce

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

cc/common/cc_helper.bzl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1082,6 +1082,9 @@ def _has_target_constraints(ctx, constraints):
10821082
return True
10831083
return False
10841084

1085+
def _should_create_test_dwp_for_statically_linked_test(is_test, linking_mode, cpp_config):
1086+
return is_test and linking_mode != linker_mode.LINKING_DYNAMIC and cpp_config.build_test_dwp()
1087+
10851088
cc_helper = struct(
10861089
rule_error = _rule_error,
10871090
attribute_error = _attribute_error,
@@ -1138,5 +1141,6 @@ cc_helper = struct(
11381141
should_create_per_object_debug_info = should_create_per_object_debug_info,
11391142
has_target_constraints = _has_target_constraints,
11401143
package_exec_path = _package_exec_path,
1144+
should_create_test_dwp_for_statically_linked_test = _should_create_test_dwp_for_statically_linked_test,
11411145
)
11421146
# LINT.ThenChange(https://github.com/bazelbuild/bazel/blob/master/src/main/starlark/builtins_bzl/common/cc/cc_helper.bzl:forked_exports)

cc/private/rules_impl/cc_binary.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -713,7 +713,7 @@ def cc_binary_impl(ctx, additional_linkopts, force_linkstatic = False):
713713
explicit_dwp_file = dwp_file
714714
if not cc_helper.should_create_per_object_debug_info(feature_configuration, cpp_config):
715715
explicit_dwp_file = None
716-
elif ctx.attr._is_test and linking_mode != linker_mode.LINKING_DYNAMIC and cpp_config.build_test_dwp():
716+
elif cc_helper.should_create_test_dwp_for_statically_linked_test(ctx.attr._is_test, linking_mode, cpp_config):
717717
files_to_build_list.append(dwp_file)
718718

719719
# If the binary is linked dynamically and COPY_DYNAMIC_LIBRARIES_TO_BINARY is enabled, collect

0 commit comments

Comments
 (0)