Skip to content

Commit e55fee2

Browse files
thiicopybara-github
authored andcommitted
Collect debug info context from implementation deps
Fixes #19146 Closes #19725. PiperOrigin-RevId: 573751305 Change-Id: I9b5df85dc5e52822b3a0b44fc42d90b727a5abf0
1 parent 774fdb4 commit e55fee2

2 files changed

Lines changed: 63 additions & 3 deletions

File tree

src/main/starlark/builtins_bzl/common/cc/cc_library.bzl

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@
1414

1515
"""cc_library Starlark implementation replacing native"""
1616

17+
load(":common/cc/cc_common.bzl", "cc_common")
1718
load(":common/cc/cc_helper.bzl", "cc_helper")
18-
load(":common/cc/semantics.bzl", "semantics")
1919
load(":common/cc/cc_info.bzl", "CcInfo")
20-
load(":common/cc/cc_common.bzl", "cc_common")
20+
load(":common/cc/semantics.bzl", "semantics")
2121

2222
cc_internal = _builtins.internal.cc_internal
2323

@@ -304,7 +304,10 @@ def _cc_library_impl(ctx):
304304
data_runfiles = data_runfiles,
305305
))
306306

307-
debug_context = cc_helper.merge_cc_debug_contexts(compilation_outputs, cc_helper.get_providers(ctx.attr.deps, CcInfo))
307+
debug_context = cc_helper.merge_cc_debug_contexts(
308+
compilation_outputs,
309+
cc_helper.get_providers(ctx.attr.deps + ctx.attr.implementation_deps, CcInfo),
310+
)
308311
cc_info = CcInfo(
309312
compilation_context = compilation_context,
310313
linking_context = linking_context,

src/test/java/com/google/devtools/build/lib/rules/cpp/CcLibraryConfiguredTargetTest.java

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2000,6 +2000,63 @@ public void testImplementationDepsLinkingContextIsPropagated() throws Exception
20002000
.contains("bin foo/libimplementation_dep.a");
20012001
}
20022002

2003+
@Test
2004+
public void testImplementationDepsDebugContextIsPropagated() throws Exception {
2005+
useConfiguration(
2006+
"--experimental_cc_implementation_deps",
2007+
"--fission=yes",
2008+
"--features=per_object_debug_info");
2009+
scratch.file(
2010+
"foo/BUILD",
2011+
"cc_binary(",
2012+
" name = 'bin',",
2013+
" srcs = ['bin.cc'],",
2014+
" deps = ['lib'],",
2015+
")",
2016+
"cc_library(",
2017+
" name = 'lib',",
2018+
" srcs = ['lib.cc'],",
2019+
" deps = ['public_dep'],",
2020+
")",
2021+
"cc_library(",
2022+
" name = 'public_dep',",
2023+
" srcs = ['public_dep.cc'],",
2024+
" hdrs = ['public_dep.h'],",
2025+
" implementation_deps = ['implementation_dep'],",
2026+
" deps = ['interface_dep'],",
2027+
")",
2028+
"cc_library(",
2029+
" name = 'interface_dep',",
2030+
" srcs = ['interface_dep.cc'],",
2031+
" hdrs = ['interface_dep.h'],",
2032+
")",
2033+
"cc_library(",
2034+
" name = 'implementation_dep',",
2035+
" srcs = ['implementation_dep.cc'],",
2036+
" hdrs = ['implementation_dep.h'],",
2037+
")");
2038+
2039+
ConfiguredTarget lib = getConfiguredTarget("//foo:lib");
2040+
assertThat(
2041+
lib
2042+
.get(CcInfo.PROVIDER)
2043+
.getCcDebugInfoContext()
2044+
.getTransitiveDwoFiles()
2045+
.toList()
2046+
.stream()
2047+
.map(Artifact::getFilename))
2048+
.contains("public_dep.dwo");
2049+
assertThat(
2050+
lib
2051+
.get(CcInfo.PROVIDER)
2052+
.getCcDebugInfoContext()
2053+
.getTransitiveDwoFiles()
2054+
.toList()
2055+
.stream()
2056+
.map(Artifact::getFilename))
2057+
.contains("implementation_dep.dwo");
2058+
}
2059+
20032060
@Test
20042061
public void testImplementationDepsRunfilesArePropagated() throws Exception {
20052062
useConfiguration("--experimental_cc_implementation_deps");

0 commit comments

Comments
 (0)