Resolve Go and C++ toolchains for each Go target#4439
Merged
Conversation
Member
Author
|
@dzbarsky @jesses-canva @anguslees FYI, this could use some testing :-) |
jayconrod
approved these changes
Sep 3, 2025
Collaborator
jayconrod
left a comment
There was a problem hiding this comment.
If this passes all the tests, then it's probably good. I don't know if there's a way to test that the original problem is fixed (C++ and Go toolchains resolved for different platforms). Probably not without a very contrived, complicated example.
If I remember correctly, when toolchains were introduced, there were no optional toolchains, so an optional dependency on a fake target was the only way to get that. It seems like config_common.toolchain_type(mandatory = False) is the missing piece.
dzbarsky
approved these changes
Sep 4, 2025
Contributor
dzbarsky
left a comment
There was a problem hiding this comment.
I don't have access to any complicated go repos at the moment, but this seems reasonable!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What type of PR is this?
Bug fix
What does this PR do? Why is it needed?
Before this change, rules_go would resolve the C++ toolchain for a fixed helper target and use it in Go targets via a provider. This results in problems for multi-platform builds since the execution platform of the C++ toolchain needs to match that of the Go toolchain, which can only be enforced if both toolchain requirements are declared on the same rule.
Which issues(s) does this PR fix?
Fixes #4127
Work towards #3740 (comment)
Other notes for review