Skip to content
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

[6.5.0] Proto toolchainisation cherrypicks #20925

Merged

Conversation

comius
Copy link
Contributor

@comius comius commented Jan 17, 2024

Fixes: #20921

List of cherrypicks:
5a24c8a ilist@google.com Mon Oct 9 02:27:10 2023 -0700 Support automatic exec groups in proto_common.compile
3e1e061 ilist@google.com Tue Oct 3 03:32:01 2023 -0700 Use proto toolchains in cc_proto_library
8c38be3 ilist@google.com Mon Oct 2 07:08:55 2023 -0700 Use proto toolchains in java_lite_proto_library
51970d2 ilist@google.com Mon Oct 2 07:05:16 2023 -0700 Use proto toolchains in java_proto_library
20bc11f ilist@google.com Mon Oct 2 06:56:47 2023 -0700 Decouple java_lite_proto_library from java_proto_library
3b18d3f ilist@google.com Mon Oct 2 04:11:24 2023 -0700 Refactor proto toolchainsation support utilities
42800a8 ilist@google.com Fri Sep 22 03:04:18 2023 -0700 Use proto compiler from proto_toolchain rule
d435c6d ilist@google.com Thu Sep 21 07:05:40 2023 -0700 Use proto_toolchain in proto_library
f5fb2f6 ilist@google.com Wed Sep 20 05:50:59 2023 -0700 Remove protoc from proto_lang_toolchain rule
108ef55 ilist@google.com Tue Sep 19 08:40:00 2023 -0700 Use MockProtoSupport.setup where protos are used
11cf1b7 ilist@google.com Sun Sep 17 21:57:54 2023 -0700 Implement incompatible_enable_proto_toolchain_resolution

The flag also make proto toolchain related flags a no-op when enabled.

PiperOrigin-RevId: 566186339
Change-Id: If4ddafa4e8ba4cdf9e7b3d564c5fc72ab764c7ac
Update MockProtoSupport.setup to always create rules_proto (setupWorskpace call)

PiperOrigin-RevId: 566643341
Change-Id: I755044233652597296ddcfd0c8a9ceae2e079efc
The protoc should be provided with a new proto_toolchain rule.

Issue: bazelbuild/rules_proto#179

RELNOTES[INC]: proto_compiler attribute removed from proto_lang_toolchain
(it was recently introduced, and there is no evidence of use)

PiperOrigin-RevId: 566937038
Change-Id: I7133be4d5cbcc816764c0ba35607329ea50d2406
Change --incompatible_enable_proto_toolchain_resolution flag to a loading time flag. This is partial revert of bazelbuild@11cf1b7. We need a load time flag, because toolchain type might not exist at current versions of rules repos users use.

When the flag is set, proto_library defines the toolchain and doesn't use an implicit dependency at the same time.

In Bazel the flag may only be flipped after all the rules_* repo are upgraded to define toolchain type and protobuf repository registers the toolchains.

Issue: bazelbuild/rules_proto#179
PiperOrigin-RevId: 567296665
Change-Id: Ib3fc27751dd14589fa403f45d2cbbad22537b9a3
Issue: bazelbuild/rules_proto#179
PiperOrigin-RevId: 567570286
Change-Id: Ia7e1ff08a0123a325f1df00f56b81212c01e2588
Implement reusable utils as part of proto_common and move out of semantics. Define toolchains that will be needed for lang_proto_libraries.

Because there are so many toolchains this will make the future code more readable.

Issue: bazelbuild/rules_proto#179
PiperOrigin-RevId: 570019432
Change-Id: Ie1675f1d847872bab3a250270eaa451ef4816ed8
Remove call to java_proto_library_impl from java_proto_library.

Remove hasattr from java_proto_library_impl, which handled java_lite_proto_library.

Code reuse in this case made little sense, and it incurrent more maintenance cost than benefit.

Issue: bazelbuild/rules_proto#179
PiperOrigin-RevId: 570053518
Change-Id: Ie43cadfd1fc324b6aaad08acaca8eea7df1a3669
Retrieve proto_lang_toolchain using toolchains in java_proto_library when proto toolchain resolution is enabled.
Add mocks for proto_lang_toolchain from rules_proto.
Return ToolchainInfo from proto_lang_toolchain rule. That's needed in the resolution. Also returning ProtoLangToolchainInfo directly, to support legacy mechanism.

Issue: bazelbuild/rules_proto#179
PiperOrigin-RevId: 570055332
Change-Id: Ieb0510d48778900b8576a71ddb20abfdcda220be
Retrieve proto_lang_toolchain using toolchains in java_lite_proto_library when proto toolchain resolution is enabled.

Issue: bazelbuild/rules_proto#179
PiperOrigin-RevId: 570056144
Change-Id: Ia952003017d18baca71d4e0ba75fc3134b972817
Retrieve proto_lang_toolchain using toolchains in cc_proto_library when proto toolchain resolution is enabled.

Issue: bazelbuild/rules_proto#179
PiperOrigin-RevId: 570334276
Change-Id: If7b7e25254bf3036fdcad67d36474b8fe64a8ffd
Pass toolchain_type through ProtoLangToolchainInfo into proto_common.compile and use it on ctx.actions.run. Automatic exec groups require that toolchain type is set on the `ctx.actions.run`. This information is used to select correct execution platform.

Expose INCOMPATIBLE_ENABLE_PROTO_TOOLCHAIN_RESOLUTION in proto_common. This will be needed to support lang_proto_libraries that are not part of Bazel. For example py_proto_library. Other methods in `toolchains` struct in proto_common.bzl, are both temporary and can be written in Starlark, so don't expose them. It's possible to access the value in backward compatible manner (that is with `getattr(proto_common, ...)`).

Expose INCOMPATIBLE_PASS_TOOLCHAIN_TYPE in proto_common. Second "flag" is here to mark, that builtin `proto_lang_toolchain` rule has a `toolchain_type` attribute. This way `proto_lang_toolchain` macro can pass the value in a compatible fashion with older Bazel. This should make toolchainisation work with older versions of Bazel that don't know about automatic exec groups and don't need to pass in the value.

Issue: bazelbuild/rules_proto#179
PiperOrigin-RevId: 571876657
Change-Id: I543ab862b318c9062d40430160e33ad197973094
@comius comius requested a review from a team as a code owner January 17, 2024 19:04
@comius comius requested a review from hvadehra January 17, 2024 19:04
@comius
Copy link
Contributor Author

comius commented Jan 17, 2024

cc @alexeagle @thesayyn

@iancha1992 iancha1992 changed the title Proto toolchainisation cherrypicks [6.5.0] Proto toolchainisation cherrypicks Jan 18, 2024
@iancha1992 iancha1992 added awaiting-review PR is awaiting review from an assigned reviewer team-Rules-API API for writing rules/aspects: providers, runfiles, actions, artifacts labels Jan 18, 2024
@iancha1992 iancha1992 added this pull request to the merge queue Jan 18, 2024
Merged via the queue into bazelbuild:release-6.5.0 with commit d2daa9b Jan 18, 2024
28 checks passed
@thesayyn
Copy link
Contributor

Thank you @comius

@iancha1992
Copy link
Member

The changes in this PR have been included in Bazel 6.5.0 RC2. Please test out the release candidate and report any issues as soon as possible. If you're using Bazelisk, you can point to the latest RC by setting USE_BAZEL_VERSION=last_rc.
Thanks!

iancha1992 pushed a commit that referenced this pull request Jan 23, 2024
Baseline:  50b61e3

Release Notes:

+ Fix tree file materialized as symlink to another file when building without the bytes. (#20409)
+ Don't pass --add-opens= to javac (#20472)
+ Flip --incompatible_visibility_private_attributes_at_definition (#20520)
+ Fix extraction of tar archives containing sparse files. (#20531)
+ RemoteSpawnRunner: record inbetween phases in timing profile (#20550)
+ Add profiling to `remoteActionBuildingSemaphore.acquire()` (#20549)
+ The label API shakeup & docs cleanup (#20590)
+ Disable rewriter test (#20758)
+ Disable PyTest.testSmoke on macOS (#20729)
+ Upgrade abseil-cpp to fix build on macos_arm64 (#20785)
+ Ignore read-only errors when updating the `mtime` of the `install_base` (#20568)
+ Restart at most once when prepopulating repository rule environment (#20667)
+ Fix bootstrapped Bazel binary (#20804)
+ Add flag `experimental_throttle_remote_action_building` (#20861)
+ Fix versioned shared libraries for macOS toolchain (#20847)
+ Proto toolchainisation cherrypicks (#20925)

Acknowledgements:

This release contains contributions from many people at Google, as well as bazel.build machine account, Brentley Jones, Fabian Meumertzheim, Jordan Mele, Mai Hussien, oquenchil, Rahul Butani, Son Luong Ngoc, Xùdōng Yáng.
copybara-service bot pushed a commit that referenced this pull request Jan 23, 2024
Baseline:  50b61e3

Release Notes:

+ Fix tree file materialized as symlink to another file when building without the bytes. (#20409)
+ Don't pass --add-opens= to javac (#20472)
+ Flip --incompatible_visibility_private_attributes_at_definition (#20520)
+ Fix extraction of tar archives containing sparse files. (#20531)
+ RemoteSpawnRunner: record inbetween phases in timing profile (#20550)
+ Add profiling to `remoteActionBuildingSemaphore.acquire()` (#20549)
+ The label API shakeup & docs cleanup (#20590)
+ Disable rewriter test (#20758)
+ Disable PyTest.testSmoke on macOS (#20729)
+ Upgrade abseil-cpp to fix build on macos_arm64 (#20785)
+ Ignore read-only errors when updating the `mtime` of the `install_base` (#20568)
+ Restart at most once when prepopulating repository rule environment (#20667)
+ Fix bootstrapped Bazel binary (#20804)
+ Add flag `experimental_throttle_remote_action_building` (#20861)
+ Fix versioned shared libraries for macOS toolchain (#20847)
+ Proto toolchainisation cherrypicks (#20925)

Acknowledgements:

This release contains contributions from many people at Google, as well as bazel.build machine account, Brentley Jones, Fabian Meumertzheim, Jordan Mele, Mai Hussien, oquenchil, Rahul Butani, Son Luong Ngoc, Xùdōng Yáng.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting-review PR is awaiting review from an assigned reviewer team-Rules-API API for writing rules/aspects: providers, runfiles, actions, artifacts
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants