Promote experimental_toolchain_generated_sysroot to non-experimental (#2849)
No functional changes intended.
We've got a use case where the ability to turn this off is useful, see
(https://github.com/bazelbuild/rules_rust/pull/2848#issuecomment-2340850076).
Closes https://github.com/bazelbuild/rules_rust/issues/2298
diff --git a/rust/private/rustc.bzl b/rust/private/rustc.bzl
index 6867138..b17a3e0 100644
--- a/rust/private/rustc.bzl
+++ b/rust/private/rustc.bzl
@@ -1068,7 +1068,7 @@
))
# Ensure the sysroot is set for the target platform
- if toolchain._experimental_toolchain_generated_sysroot:
+ if toolchain._toolchain_generated_sysroot:
rustc_flags.add(toolchain.sysroot, format = "--sysroot=%s")
if toolchain._rename_first_party_crates:
diff --git a/rust/settings/BUILD.bazel b/rust/settings/BUILD.bazel
index 91d01ea..022acd7 100644
--- a/rust/settings/BUILD.bazel
+++ b/rust/settings/BUILD.bazel
@@ -1,7 +1,6 @@
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
load("@bazel_skylib//rules:common_settings.bzl", "bool_flag", "string_flag")
load("//rust/private:unpretty.bzl", "rust_unpretty_flag")
-load(":incompatible.bzl", "incompatible_flag")
package(default_visibility = ["//visibility:public"])
@@ -85,11 +84,10 @@
build_setting_default = True,
)
-# A flag to set rustc --sysroot flag to the sysroot generated by rust_toolchain
-incompatible_flag(
- name = "experimental_toolchain_generated_sysroot",
+# A flag to set rustc --sysroot flag to the sysroot generated by rust_toolchain.
+bool_flag(
+ name = "toolchain_generated_sysroot",
build_setting_default = True,
- issue = "https://github.com/bazelbuild/rules_rust/issues/2039",
)
# A flag to control whether to link libstd dynamically.
diff --git a/rust/toolchain.bzl b/rust/toolchain.bzl
index 1ff73e6..14eb6ed 100644
--- a/rust/toolchain.bzl
+++ b/rust/toolchain.bzl
@@ -18,7 +18,6 @@
"is_std_dylib",
"make_static_lib_symlink",
)
-load("//rust/settings:incompatible.bzl", "IncompatibleFlagInfo")
rust_analyzer_toolchain = _rust_analyzer_toolchain
rustfmt_toolchain = _rustfmt_toolchain
@@ -697,7 +696,7 @@
_experimental_use_cc_common_link = _experimental_use_cc_common_link(ctx),
_experimental_use_global_allocator = experimental_use_global_allocator,
_experimental_use_coverage_metadata_files = ctx.attr._experimental_use_coverage_metadata_files[BuildSettingInfo].value,
- _experimental_toolchain_generated_sysroot = ctx.attr._experimental_toolchain_generated_sysroot[IncompatibleFlagInfo].enabled,
+ _toolchain_generated_sysroot = ctx.attr._toolchain_generated_sysroot[BuildSettingInfo].value,
_no_std = no_std,
)
return [
@@ -872,13 +871,6 @@
"_cc_toolchain": attr.label(
default = Label("@bazel_tools//tools/cpp:current_cc_toolchain"),
),
- "_experimental_toolchain_generated_sysroot": attr.label(
- default = Label("//rust/settings:experimental_toolchain_generated_sysroot"),
- doc = (
- "Label to a boolean build setting that lets the rule knows wheter to set --sysroot to rustc" +
- "This flag is only relevant when used together with --@rules_rust//rust/settings:experimental_toolchain_generated_sysroot."
- ),
- ),
"_experimental_use_coverage_metadata_files": attr.label(
default = Label("//rust/settings:experimental_use_coverage_metadata_files"),
),
@@ -901,6 +893,13 @@
"_third_party_dir": attr.label(
default = Label("//rust/settings:third_party_dir"),
),
+ "_toolchain_generated_sysroot": attr.label(
+ default = Label("//rust/settings:toolchain_generated_sysroot"),
+ doc = (
+ "Label to a boolean build setting that lets the rule knows wheter to set --sysroot to rustc. " +
+ "This flag is only relevant when used together with --@rules_rust//rust/settings:toolchain_generated_sysroot."
+ ),
+ ),
},
toolchains = [
"@bazel_tools//tools/cpp:toolchain_type",
diff --git a/test/toolchain/toolchain_test.bzl b/test/toolchain/toolchain_test.bzl
index b61a351..c92ac34 100644
--- a/test/toolchain/toolchain_test.bzl
+++ b/test/toolchain/toolchain_test.bzl
@@ -81,7 +81,7 @@
_toolchain_adds_rustc_flags_lib_impl,
config_settings = {
str(Label("//:extra_rustc_flags")): [CONFIG_FLAG],
- str(Label("//rust/settings:experimental_toolchain_generated_sysroot")): True,
+ str(Label("//rust/settings:toolchain_generated_sysroot")): True,
},
)
@@ -89,7 +89,7 @@
_toolchain_adds_rustc_flags_shared_lib_impl,
config_settings = {
str(Label("//:extra_rustc_flags")): [CONFIG_FLAG],
- str(Label("//rust/settings:experimental_toolchain_generated_sysroot")): True,
+ str(Label("//rust/settings:toolchain_generated_sysroot")): True,
},
)