diff options
author | UebelAndre <github@uebelandre.com> | 2024-01-29 16:01:38 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-30 00:01:38 +0000 |
commit | 649b32d8607a5bfa377468e681b355b9a88ef8f0 (patch) | |
tree | 4f31694bbdbaa3a10e42f8da0957767bdc38f66d | |
parent | fe610dab73c3c61560a547bc661177dd5115fed7 (diff) | |
download | bazelbuild-rules_rust-649b32d8607a5bfa377468e681b355b9a88ef8f0.tar.gz |
Added `incompatible_no_rustc_sysroot_env` (#2428)
To remove `SYSROOT` from Rustc actions
-rw-r--r-- | rust/private/rustc.bzl | 3 | ||||
-rw-r--r-- | rust/settings/BUILD.bazel | 7 | ||||
-rw-r--r-- | rust/toolchain.bzl | 4 |
3 files changed, 13 insertions, 1 deletions
diff --git a/rust/private/rustc.bzl b/rust/private/rustc.bzl index eff542eb..ad682f35 100644 --- a/rust/private/rustc.bzl +++ b/rust/private/rustc.bzl @@ -1059,7 +1059,8 @@ def construct_arguments( )) # Ensure the sysroot is set for the target platform - env["SYSROOT"] = toolchain.sysroot + if not toolchain._incompatible_no_rustc_sysroot_env: + env["SYSROOT"] = toolchain.sysroot if toolchain._experimental_toolchain_generated_sysroot: rustc_flags.add(toolchain.sysroot, format = "--sysroot=%s") diff --git a/rust/settings/BUILD.bazel b/rust/settings/BUILD.bazel index 1f23709f..faaa1489 100644 --- a/rust/settings/BUILD.bazel +++ b/rust/settings/BUILD.bazel @@ -98,3 +98,10 @@ incompatible_flag( build_setting_default = True, issue = "https://github.com/bazelbuild/rules_rust/issues/2324", ) + +# A flag to remove the SYSROOT environment variable from `Rustc` actions. +incompatible_flag( + name = "incompatible_no_rustc_sysroot_env", + build_setting_default = True, + issue = "https://github.com/bazelbuild/rules_rust/issues/2429", +) diff --git a/rust/toolchain.bzl b/rust/toolchain.bzl index a9b2e1f5..9580d7cf 100644 --- a/rust/toolchain.bzl +++ b/rust/toolchain.bzl @@ -643,6 +643,7 @@ def _rust_toolchain_impl(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, + _incompatible_no_rustc_sysroot_env = ctx.attr._incompatible_no_rustc_sysroot_env[IncompatibleFlagInfo].enabled, _incompatible_test_attr_crate_and_srcs_mutually_exclusive = ctx.attr._incompatible_test_attr_crate_and_srcs_mutually_exclusive[IncompatibleFlagInfo].enabled, _no_std = no_std, ) @@ -807,6 +808,9 @@ rust_toolchain = rule( "This flag is only relevant when used together with --@rules_rust//rust/settings:experimental_use_global_allocator." ), ), + "_incompatible_no_rustc_sysroot_env": attr.label( + default = Label("//rust/settings:incompatible_no_rustc_sysroot_env"), + ), "_incompatible_test_attr_crate_and_srcs_mutually_exclusive": attr.label( default = Label("//rust/settings:incompatible_test_attr_crate_and_srcs_mutually_exclusive"), ), |