-
Notifications
You must be signed in to change notification settings - Fork 15.7k
Use prebuilt binaries instead of building protoc from sources #19727
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 30.x
Are you sure you want to change the base?
Conversation
4464bda
to
da73f4a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks pretty good if we can put the versioning back to where it was.
protobuf_version.bzl
Outdated
PROTOBUF_PYTHON_VERSION = "5.29.3" | ||
PROTOBUF_PHP_VERSION = "4.29.3" | ||
PROTOBUF_RUBY_VERSION = "4.29.3" | ||
PROTOC_VERSION = "29.1" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Once you revert these version changes, the PR should be a lot smaller.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, without the versions it's smaller. But none of the tests pass, because code is generated with a different version.
@@ -229,12 +229,22 @@ alias( | |||
visibility = ["//visibility:public"], | |||
) | |||
|
|||
cc_binary( | |||
alias( | |||
name = "protoc", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this make it impossible to opt-out? If that's the case, we should probably hold off on this until 30.x at least
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we enable this with some sort of flag, and flip the default in a subsequent breaking change if desired instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it's possible to add a completely Starlark flag, to control if prebuilt binaries are used or not.
Today we tag a release commit and then create binaries so the binaries match the github release tag. Manipulating our source archive to include a commit updating prebuilt binaries might be doable, but would make it deviate from the tagged release commit (and github's source archive) where I think we'd also have to remove prebuilts in the interim. I assume we can't have the release commit point to its own artifacts? |
1st option 2nd option 3rd option
|
While I like the direction, what's the reason for not registering a toolchain per OS/architecture with The downsides of the |
The registered toolchain points to //:protoc, so the select also gets used. If there are many execution plaforms and the first one doesn't have prebuilt binary it would fall back to the sources. |
@comius - can you update this PR to resolve the merge conflicts? |
da73f4a
to
03dc0fc
Compare
Done. (I rebased to 30.x) |
The latest test run has issues across a wide spectrum of configurations, including:
|
@JasonLunn I can fix the failures - but perhaps you missed the point, that this PR is intended to demonstrate how to use prebuilt binaries and even with fixed failures, you wouldn't be able to merge it, because it depends on a released version of binaries. |
Hey all, I've got an idea over a lunch break, how to implement this, without modifying protobuf release procedures. It wouldn't be hard to implement at all. The only caveat is, that it works only with bzlmod. The sketch of the solution is:
Why does this work? WDYT? Should we move forward with this? |
That's a pretty decent approach. The only downside I see is that users may be led to (mistakenly) believe that they should depend on This approach doesn't preclude the use of toolchains instead of |
I agree, that's a nice formulation that avoids touching the existing release procedure for the protobuf module and allows OSS maintainers to own this setup without google3 access. I think we should use toolchains rather than select from the beginning, but this is easily done based on what's already in toolchains_protoc. |
Fetch released prebuilt binaries and use them in a platform based select. That selects appropriate binary for the platform or falls back to sources. (It's mostly just about wiring stuff together for WORKSPACE and bzlmod).
Works with both WORKSPACE and bzlmod mode. It even works with --incompatible_enable_proto_toolchain_resolution, because the only configured toolchain now points to the target that has the select.
This PR should be applied during the release: after archives with prebuilt binaries are created (so that we can compute checksums), but before the source archive is created.
Please ignore changes to .pb.h and versions, those are there just to make examples work. That's because version of prebuilt binaries need to match the sources.