diff --git a/rust/private/rustc.bzl b/rust/private/rustc.bzl index a28ad50b78..34ad397a9e 100644 --- a/rust/private/rustc.bzl +++ b/rust/private/rustc.bzl @@ -1580,9 +1580,12 @@ def rustc_compile_action( toolchain.stdlib_linkflags.linking_context, ] - for dep in crate_info.deps.to_list(): - if dep.cc_info: - linking_contexts.append(dep.cc_info.linking_context) + linking_contexts += [ + ddep.cc_info.linking_context + for dep in crate_info.deps.to_list() + for ddep in (dep.crate_group_info.dep_variant_infos.to_list() if dep.crate_group_info else [dep]) + if ddep.cc_info + ] # In the cc_common.link action we need to pass the name of the final # binary (output) relative to the package of this target.