Skip to content

Conversation

@fmeum
Copy link
Member

@fmeum fmeum commented Sep 3, 2025

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

# Conflicts:
#	go/private/context.bzl
@fmeum fmeum marked this pull request as ready for review September 3, 2025 16:33
@fmeum fmeum requested a review from jayconrod September 3, 2025 16:33
@fmeum
Copy link
Member Author

fmeum commented Sep 3, 2025

@dzbarsky @jesses-canva @anguslees FYI, this could use some testing :-)

Copy link
Collaborator

@jayconrod jayconrod left a comment

Choose a reason for hiding this comment

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

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.

Copy link
Contributor

@dzbarsky dzbarsky left a comment

Choose a reason for hiding this comment

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

I don't have access to any complicated go repos at the moment, but this seems reasonable!

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.

Go rules run cpp toolchain from cgo_context_data on an incompatible execution platform

4 participants