-
Notifications
You must be signed in to change notification settings - Fork 431
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
Added a build setting for toolchain channels #1671
Conversation
9258d43
to
557c799
Compare
This PR introduces select statements to toolchain definitions: toolchain(
name = "toolchain",
exec_compatible_with = ["@platforms//cpu:x86_64","@platforms//os:osx"],
target_compatible_with = ["@platforms//cpu:x86_64","@platforms//os:osx"],
toolchain = select({"@rules_rust//rust/toolchain/channel:nightly":"@rust_darwin_x86_64__x86_64-apple-darwin_nightly_tools//:rust_toolchain","@rules_rust//rust/toolchain/channel:stable":"@rust_darwin_x86_64__x86_64-apple-darwin_stable_tools//:rust_toolchain"}),
toolchain_type = "@rules_rust//rust:toolchain",
) The conditions for these are defined as config settings that match on a build_setting rule I wrote in the config_setting(
name = "nightly",
flag_values = {
":channel": "nightly",
},
visibility = ["//visibility:public"],
)
config_setting(
name = "stable",
flag_values = {
":channel": "stable",
},
visibility = ["//visibility:public"],
) I'm now confused as to why my test is failing at
@illicitonion @scentini @krasimirgg Would any of you have an idea as to why the toolchain is not being transitioned? |
re: The issue was was resolved with the following diff. diff --git a/test/unit/channel_transitions/channel_transiitons_test.bzl b/test/unit/channel_transitions/channel_transiitons_test.bzl
index 748b454a..668f2ca6 100644
--- a/test/unit/channel_transitions/channel_transiitons_test.bzl
+++ b/test/unit/channel_transitions/channel_transiitons_test.bzl
@@ -30,7 +30,7 @@ nightly_transition_test = analysistest.make(
_nightly_transition_test_impl,
doc = "Test that targets can be forced to use a nightly toolchain",
config_settings = {
- "@rules_rust//rust/toolchain/channel:channel": "nightly",
+ "@//rust/toolchain/channel:channel": "nightly",
},
)
@@ -41,7 +41,7 @@ stable_transition_test = analysistest.make(
_stable_transition_test_impl,
doc = "Test that targets can be forced to use a stable toolchain",
config_settings = {
- "@rules_rust//rust/toolchain/channel:channel": "stable",
+ "@//rust/toolchain/channel:channel": "stable",
},
) The behavior around labels has been frustratingly inconsistent. I wish it was clearer what style should be used where or if wrapping a string in |
9c0f119
to
7cbe167
Compare
The label syntax is confusing. When you specify the label as Can you use repo-relative labels like |
I tried, repo-relative labels didn't work 😞 |
With respect to You currently have this toolchain:
This is equivalent to the following:
The benefits of the second form is that it's clearer to users when they read it, it's clearer to rule authors when they want to edit it, and the two different toolchains are listed properly in toolchain debugging. I need to document |
b69f4b6
to
1610bc5
Compare
Thanks for the suggestion @katre! I was able to cleanup some things to come up with a much nicer implementation. I had no idea toolchain.target_settings existed. |
TIL about |
If you have a toolchain with a target setting that matches the config, and one without, then the normal toolchain mechanism of registration order will apply. Note that if you register toolchains using |
Anyone have time to review this this week? 😅 |
Thank you for the ping! I will review this tomorrow. |
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 good! I've got a few nits.
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.
Thank you!
This pull request introduces the
@rules_rust//rust/toolchain/channel
build setting which is used to support transitioning targets to use a toolchain of a different Rust toolchain channels (e.g. "nightly").By default
rust_register_toolchains
will now register a stable and nightly toolchain. The stable toolchain will be the default but users can switch to using the nightly toolchain by passing--@rules_rust//rust/toolchain/channel=nightly
with their Bazel invocation.This pull-request is intended to unlock future changes where transitions might be incorporated into existing rules to make accessing the right Rust tools more convenient.