Skip to content

Traverse CrateGroupInfo when gathering CcInfo linking_context entries for use_cc_common_link#3787

Open
ObsidianMinor wants to merge 1 commit intobazelbuild:mainfrom
ObsidianMinor:fix/crate-group-common-link
Open

Traverse CrateGroupInfo when gathering CcInfo linking_context entries for use_cc_common_link#3787
ObsidianMinor wants to merge 1 commit intobazelbuild:mainfrom
ObsidianMinor:fix/crate-group-common-link

Conversation

@ObsidianMinor
Copy link

This fixes rust_library_group and rust_prost_library for experimental_use_cc_common_link

Closes #3786

Copy link
Collaborator

@UebelAndre UebelAndre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Is there a unit test you could add somewhere in //test/unit or something? Would love to have some protection against regressions.

@ObsidianMinor
Copy link
Author

Yeah I was wondering where I should put that, since there's only one test I think actually exercising this experimental flag and the configuration looks mildly complex. But I'll see if I can add something to it.

@ObsidianMinor ObsidianMinor force-pushed the fix/crate-group-common-link branch from 6983cb3 to ac7d5c0 Compare December 23, 2025 05:21
@ObsidianMinor
Copy link
Author

Turns out with further testing there's more places that don't account for crate groups. So this patch was incomplete and would fix direct dependencies, but not indirect dependencies, which happens during establish_cc_info. I've updated it to factor out the crate group flattening into a separate function plus the added tests.

@xiaopeng-tranxmart
Copy link

We also encountered the same issue, and this PR works well for us.
Looking forward to it being merged. Thanks for the pr & review work! @UebelAndre

Copy link
Collaborator

@UebelAndre UebelAndre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general I think the change looks good, I just want to always make sure there's some regression testing. For the new tests, can you show what the error looks like without the fix applied? I otherwise defer to @krasimirgg to make sure this solves for their needs as well 😄

Thanks again!

@krasimirgg
Copy link
Collaborator

Looks very reasonable! +1 for adding some test coverage, as these types of things tend to regress due to "spooky action at a distance" sometimes.

To share some context: internally, we don't use rust_library_group at all today, so we don't have any needs around that. We haven't looked at its compatibility with cc_common.link at detail. At a high-level, internally we focus on a minimal set of rules and make sure they work well together and are well integrated with a variety of additional internal infrastructure. Onboarding something like rust_library_group would have high costs for us for not so much benefit comparatively.

@ObsidianMinor
Copy link
Author

Is there somewhere else I should be adding coverage that isn't covered by what I've added in this PR?

@UebelAndre
Copy link
Collaborator

Is there somewhere else I should be adding coverage that isn't covered by what I've added in this PR?

No, I think you found it but if this feature is ever going to move out of experimental we'll probably need to add unit tests for it at //test/unit/cc_common_link or something.

I just want to know what the failure signature looks like without the fix and then see this fix resolve that for now.

@ObsidianMinor ObsidianMinor force-pushed the fix/crate-group-common-link branch from ac7d5c0 to c342400 Compare March 16, 2026 15:41
… for use_cc_common_link

Certain code written before crate groups were introduced wasn't adjusted to traverse
groups, specifically code that traverses crate deps to discover cc_info. collect_deps
properly does flatten crate_groups, so this moves the code for flattening a list of
DepVariantInfo into a utility function, 'flatten_crate_groups'.

This fixes rust_library_group and rust_prost_library for experimental_use_cc_common_link.
@ObsidianMinor ObsidianMinor force-pushed the fix/crate-group-common-link branch from c342400 to 0f11b65 Compare March 16, 2026 16:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CrateGroupInfo cannot provide CcInfo dependencies for experimental_cc_common_link

4 participants