Skip to content

Commit

Permalink
Collect debug info context from implementation deps
Browse files Browse the repository at this point in the history
Fixes bazelbuild#19146

Closes bazelbuild#19725.

PiperOrigin-RevId: 573751305
Change-Id: I9b5df85dc5e52822b3a0b44fc42d90b727a5abf0
  • Loading branch information
thii authored and iancha1992 committed Oct 16, 2023
1 parent 90f08c4 commit a2f750a
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/main/starlark/builtins_bzl/common/cc/cc_library.bzl
Expand Up @@ -14,7 +14,9 @@

"""cc_library Starlark implementation replacing native"""

load(":common/cc/cc_common.bzl", "cc_common")
load(":common/cc/cc_helper.bzl", "cc_helper")
load(":common/cc/cc_info.bzl", "CcInfo")
load(":common/cc/semantics.bzl", "semantics")

CcInfo = _builtins.toplevel.CcInfo
Expand Down Expand Up @@ -311,7 +313,10 @@ def _cc_library_impl(ctx):
data_runfiles = data_runfiles,
))

debug_context = cc_helper.merge_cc_debug_contexts(compilation_outputs, cc_helper.get_providers(ctx.attr.deps, CcInfo))
debug_context = cc_helper.merge_cc_debug_contexts(
compilation_outputs,
cc_helper.get_providers(ctx.attr.deps + ctx.attr.implementation_deps, CcInfo),
)
cc_info = CcInfo(
compilation_context = compilation_context,
linking_context = linking_context,
Expand Down
Expand Up @@ -2004,6 +2004,63 @@ public void testImplementationDepsLinkingContextIsPropagated() throws Exception
.contains("bin foo/libimplementation_dep.a");
}

@Test
public void testImplementationDepsDebugContextIsPropagated() throws Exception {
useConfiguration(
"--experimental_cc_implementation_deps",
"--fission=yes",
"--features=per_object_debug_info");
scratch.file(
"foo/BUILD",
"cc_binary(",
" name = 'bin',",
" srcs = ['bin.cc'],",
" deps = ['lib'],",
")",
"cc_library(",
" name = 'lib',",
" srcs = ['lib.cc'],",
" deps = ['public_dep'],",
")",
"cc_library(",
" name = 'public_dep',",
" srcs = ['public_dep.cc'],",
" hdrs = ['public_dep.h'],",
" implementation_deps = ['implementation_dep'],",
" deps = ['interface_dep'],",
")",
"cc_library(",
" name = 'interface_dep',",
" srcs = ['interface_dep.cc'],",
" hdrs = ['interface_dep.h'],",
")",
"cc_library(",
" name = 'implementation_dep',",
" srcs = ['implementation_dep.cc'],",
" hdrs = ['implementation_dep.h'],",
")");

ConfiguredTarget lib = getConfiguredTarget("//foo:lib");
assertThat(
lib
.get(CcInfo.PROVIDER)
.getCcDebugInfoContext()
.getTransitiveDwoFiles()
.toList()
.stream()
.map(Artifact::getFilename))
.contains("public_dep.dwo");
assertThat(
lib
.get(CcInfo.PROVIDER)
.getCcDebugInfoContext()
.getTransitiveDwoFiles()
.toList()
.stream()
.map(Artifact::getFilename))
.contains("implementation_dep.dwo");
}

@Test
public void testImplementationDepsRunfilesArePropagated() throws Exception {
useConfiguration("--experimental_cc_implementation_deps");
Expand Down

0 comments on commit a2f750a

Please sign in to comment.