Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@alexeagle
Copy link
Collaborator

@alexeagle alexeagle commented Oct 22, 2025

Upstreamed from my https://github.com/aspect-build/toolchains_protoc which provided this feature outside the protobuf repo.

Adds:

  • private API: module_extension + tag protoc.prebuilt_toolchain to provide and register toolchain for bzlmod users
  • WORKSPACE users can live with the inconvenience of having to create toolchains themselves
  • example of proto_library rule with intentionally non-functional cc toolchain, exercising the feature

This needs work with @thesayyn to:

Work towards #19558

@alexeagle alexeagle requested a review from a team as a code owner October 22, 2025 01:58
@alexeagle alexeagle requested review from Logofile and removed request for a team October 22, 2025 01:58
@Logofile Logofile requested review from honglooker and removed request for Logofile October 22, 2025 12:25
@honglooker honglooker removed their request for review October 22, 2025 15:49
@alexeagle alexeagle requested a review from thesayyn October 22, 2025 20:48
@alexeagle alexeagle changed the title WIP: wire up prebuilt protoc toolchain feat(bazel): wire up prebuilt protoc toolchain Nov 5, 2025
@alexeagle alexeagle force-pushed the alexeagle/use_prebuilt_toolchain branch from 46f35dc to 7e9cd2c Compare November 5, 2025 02:02
@alexeagle alexeagle force-pushed the alexeagle/use_prebuilt_toolchain branch from 7e9cd2c to d76fbd6 Compare November 14, 2025 18:36
@mkruskal-google
Copy link
Member

This looks reasonable to me. But it's still missing the validation layer AFAICT. Is this PR waiting for that? Also the tests are all still broken

@alexeagle
Copy link
Collaborator Author

Sure, I can pick up something like #23539 - the only comment I got there was "cannot reproduce" but I'd like to know if the guarantee is strong enough.

Separately I'd be very happy to land this one first. That could unblock the flag flip in time for Bazel 9 due in a month.

@alexeagle alexeagle force-pushed the alexeagle/use_prebuilt_toolchain branch from d76fbd6 to f45a2a4 Compare November 17, 2025 01:24
@zhangskz
Copy link
Member

Sure, I can pick up something like #23539 - the only comment I got there was "cannot reproduce" but I'd like to know if the guarantee is strong enough.

Separately I'd be very happy to land this one first. That could unblock the flag flip in time for Bazel 9 due in a month.

I'd probably like to see version check to prevent use of arbitrarily old versions of prebuilt protoc or newer versions of protoc from being used like w https://protobuf.dev/support/cross-version-runtime-guarantee/.

}
# An arbitrary version of protobuf that includes pre-built binaries.
# See /examples/example_without_cc_toolchain which uses this for testing.
_TEST_VERSION = "v33.0"
Copy link
Member

Choose a reason for hiding this comment

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

We probably still want this updated to ensure it doesn't end up too ancient. Perhaps this can get updated via GHA too triggered by a new release to update this when there are new minor releases (e.g. v33.0) in at least main and the corresponding release branch.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sure, that's possible, I can propose some GHA automation after this lands.

bool_flag(
name = "prefer_prebuilt_protoc",
# TODO(alexeagle): this should be True after the feature is vetted with some adoption
build_setting_default = False,
Copy link
Member

Choose a reason for hiding this comment

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

This will need to be set to false for most of our CI tests at least.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sure, I wouldn't expect the default for end-users to be motivated similarly to how protobuf team will test. In fact, this default could vary between this repo and the Bazel module we publish, using the BCR patches feature.

@mkruskal-google
Copy link
Member

mkruskal-google commented Nov 18, 2025

Sure, I can pick up something like #23539 - the only comment I got there was "cannot reproduce" but I'd like to know if the guarantee is strong enough.

Separately I'd be very happy to land this one first. That could unblock the flag flip in time for Bazel 9 due in a month.

+1 to Sandy, while we might be ok with landing this PR first, we definitely wouldn't want to flip the flag without the validation we laid out in the design.

I'm not sure what guarantee is in that prototype, but it does seem like an appropriate place to add the validation

@alexeagle alexeagle force-pushed the alexeagle/use_prebuilt_toolchain branch 2 times, most recently from 1fd7854 to 6dce826 Compare November 20, 2025 11:44
@alexeagle
Copy link
Collaborator Author

okay @zhangskz I've added the version verification to this PR, PTAL

@alexeagle alexeagle force-pushed the alexeagle/use_prebuilt_toolchain branch 2 times, most recently from ebad988 to ab033ab Compare December 9, 2025 20:57
Users can manually register this in their MODULE.bazel so that registration overrides the default, which is still building protoc from source.
@alexeagle alexeagle force-pushed the alexeagle/use_prebuilt_toolchain branch from ab033ab to 3d734ea Compare December 9, 2025 21:58
copybara-service bot pushed a commit that referenced this pull request Dec 12, 2025
Upstreamed from my https://github.com/aspect-build/toolchains_protoc which provided this feature outside the protobuf repo.

Adds:
- private API: module_extension + tag `protoc.prebuilt_toolchain` to provide and register toolchain for bzlmod users
- WORKSPACE users can live with the inconvenience of having to create toolchains themselves
- example of proto_library rule with intentionally non-functional cc toolchain, exercising the feature

This needs work with @thesayyn to:
- constrain users to choosing a protoc version agreeing with design doc
https://docs.google.com/document/d/16N-eU-0zHbWmxEuaUAIFTJwQLekIXZ8zIC3K4XDr20E/edit
- also register lang toolchains when the flag is enabled

Work towards #19558

Closes #24115

COPYBARA_INTEGRATE_REVIEW=#24115 from protocolbuffers:alexeagle/use_prebuilt_toolchain b18667d
FUTURE_COPYBARA_INTEGRATE_REVIEW=#24115 from protocolbuffers:alexeagle/use_prebuilt_toolchain b18667d
PiperOrigin-RevId: 843732324
copybara-service bot pushed a commit that referenced this pull request Dec 12, 2025
Upstreamed from my https://github.com/aspect-build/toolchains_protoc which provided this feature outside the protobuf repo.

Adds:
- private API: module_extension + tag `protoc.prebuilt_toolchain` to provide and register toolchain for bzlmod users
- WORKSPACE users can live with the inconvenience of having to create toolchains themselves
- example of proto_library rule with intentionally non-functional cc toolchain, exercising the feature

This needs work with @thesayyn to:
- constrain users to choosing a protoc version agreeing with design doc
https://docs.google.com/document/d/16N-eU-0zHbWmxEuaUAIFTJwQLekIXZ8zIC3K4XDr20E/edit
- also register lang toolchains when the flag is enabled

Work towards #19558

Closes #24115

COPYBARA_INTEGRATE_REVIEW=#24115 from protocolbuffers:alexeagle/use_prebuilt_toolchain b18667d
FUTURE_COPYBARA_INTEGRATE_REVIEW=#24115 from protocolbuffers:alexeagle/use_prebuilt_toolchain b18667d
PiperOrigin-RevId: 843732324
copybara-service bot pushed a commit that referenced this pull request Dec 12, 2025
Upstreamed from my https://github.com/aspect-build/toolchains_protoc which provided this feature outside the protobuf repo.

Adds:
- private API: module_extension + tag `protoc.prebuilt_toolchain` to provide and register toolchain for bzlmod users
- WORKSPACE users can live with the inconvenience of having to create toolchains themselves
- example of proto_library rule with intentionally non-functional cc toolchain, exercising the feature

This needs work with @thesayyn to:
- constrain users to choosing a protoc version agreeing with design doc
https://docs.google.com/document/d/16N-eU-0zHbWmxEuaUAIFTJwQLekIXZ8zIC3K4XDr20E/edit
- also register lang toolchains when the flag is enabled

Work towards #19558

Closes #24115

COPYBARA_INTEGRATE_REVIEW=#24115 from protocolbuffers:alexeagle/use_prebuilt_toolchain b18667d
FUTURE_COPYBARA_INTEGRATE_REVIEW=#24115 from protocolbuffers:alexeagle/use_prebuilt_toolchain b18667d
PiperOrigin-RevId: 843732324
copybara-service bot pushed a commit that referenced this pull request Dec 15, 2025
Upstreamed from my https://github.com/aspect-build/toolchains_protoc which provided this feature outside the protobuf repo.

Adds:
- private API: module_extension + tag `protoc.prebuilt_toolchain` to provide and register toolchain for bzlmod users
- WORKSPACE users can live with the inconvenience of having to create toolchains themselves
- example of proto_library rule with intentionally non-functional cc toolchain, exercising the feature

This needs work with @thesayyn to:
- constrain users to choosing a protoc version agreeing with design doc
https://docs.google.com/document/d/16N-eU-0zHbWmxEuaUAIFTJwQLekIXZ8zIC3K4XDr20E/edit
- also register lang toolchains when the flag is enabled

Work towards #19558

Closes #24115

COPYBARA_INTEGRATE_REVIEW=#24115 from protocolbuffers:alexeagle/use_prebuilt_toolchain b18667d
FUTURE_COPYBARA_INTEGRATE_REVIEW=#24115 from protocolbuffers:alexeagle/use_prebuilt_toolchain b18667d
PiperOrigin-RevId: 844815128
copybara-service bot pushed a commit that referenced this pull request Dec 15, 2025
Upstreamed from my https://github.com/aspect-build/toolchains_protoc which provided this feature outside the protobuf repo.

Adds:
- private API: module_extension + tag `protoc.prebuilt_toolchain` to provide and register toolchain for bzlmod users
- WORKSPACE users can live with the inconvenience of having to create toolchains themselves
- example of proto_library rule with intentionally non-functional cc toolchain, exercising the feature

This needs work with @thesayyn to:
- constrain users to choosing a protoc version agreeing with design doc
https://docs.google.com/document/d/16N-eU-0zHbWmxEuaUAIFTJwQLekIXZ8zIC3K4XDr20E/edit
- also register lang toolchains when the flag is enabled

Work towards #19558

Closes #24115

COPYBARA_INTEGRATE_REVIEW=#24115 from protocolbuffers:alexeagle/use_prebuilt_toolchain b18667d
FUTURE_COPYBARA_INTEGRATE_REVIEW=#24115 from protocolbuffers:alexeagle/use_prebuilt_toolchain b18667d
PiperOrigin-RevId: 844815128
karenwuz pushed a commit that referenced this pull request Dec 18, 2025
Upstreamed from my https://github.com/aspect-build/toolchains_protoc which provided this feature outside the protobuf repo.

Adds:
- private API: module_extension + tag `protoc.prebuilt_toolchain` to provide and register toolchain for bzlmod users
- WORKSPACE users can live with the inconvenience of having to create toolchains themselves
- example of proto_library rule with intentionally non-functional cc toolchain, exercising the feature

This needs work with @thesayyn to:
- constrain users to choosing a protoc version agreeing with design doc
https://docs.google.com/document/d/16N-eU-0zHbWmxEuaUAIFTJwQLekIXZ8zIC3K4XDr20E/edit
- also register lang toolchains when the flag is enabled

Work towards #19558

Closes #24115

COPYBARA_INTEGRATE_REVIEW=#24115 from protocolbuffers:alexeagle/use_prebuilt_toolchain b18667d
PiperOrigin-RevId: 844859103
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.

7 participants