From d88c7f35189177a21430869bbd3ce77d0e83ef83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thi=20Do=C3=A3n?= Date: Wed, 4 Oct 2023 22:23:35 +0900 Subject: [PATCH] Collect debug info context from implementation deps --- .../builtins_bzl/common/cc/cc_library.bzl | 5 +- .../cpp/CcLibraryConfiguredTargetTest.java | 53 +++++++++++++++++++ 2 files changed, 57 insertions(+), 1 deletion(-) diff --git a/src/main/starlark/builtins_bzl/common/cc/cc_library.bzl b/src/main/starlark/builtins_bzl/common/cc/cc_library.bzl index fe827d3db78d0e..a41ee7470874b6 100755 --- a/src/main/starlark/builtins_bzl/common/cc/cc_library.bzl +++ b/src/main/starlark/builtins_bzl/common/cc/cc_library.bzl @@ -304,7 +304,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, diff --git a/src/test/java/com/google/devtools/build/lib/rules/cpp/CcLibraryConfiguredTargetTest.java b/src/test/java/com/google/devtools/build/lib/rules/cpp/CcLibraryConfiguredTargetTest.java index 8a9bed3ce9075f..b353a77eb8caf2 100644 --- a/src/test/java/com/google/devtools/build/lib/rules/cpp/CcLibraryConfiguredTargetTest.java +++ b/src/test/java/com/google/devtools/build/lib/rules/cpp/CcLibraryConfiguredTargetTest.java @@ -2000,6 +2000,59 @@ 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");