Skip to content

Commit 792d003

Browse files
committed
Added incompatible_no_rustc_sysroot_env to remove SYSROOT from Rustc actions
1 parent 50b9ef3 commit 792d003

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

rust/private/rustc.bzl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1059,7 +1059,8 @@ def construct_arguments(
10591059
))
10601060

10611061
# Ensure the sysroot is set for the target platform
1062-
env["SYSROOT"] = toolchain.sysroot
1062+
if not toolchain._incompatible_no_rustc_sysroot_env:
1063+
env["SYSROOT"] = toolchain.sysroot
10631064
if toolchain._experimental_toolchain_generated_sysroot:
10641065
rustc_flags.add(toolchain.sysroot, format = "--sysroot=%s")
10651066

rust/settings/BUILD.bazel

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,3 +98,10 @@ incompatible_flag(
9898
build_setting_default = True,
9999
issue = "https://github.com/bazelbuild/rules_rust/issues/2324",
100100
)
101+
102+
# A flag to remove the SYSROOT environment variable from `Rustc` actions.
103+
incompatible_flag(
104+
name = "incompatible_no_rustc_sysroot_env",
105+
build_setting_default = True,
106+
issue = "https://github.com/bazelbuild/rules_rust/issues/2324",
107+
)

rust/toolchain.bzl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -643,6 +643,7 @@ def _rust_toolchain_impl(ctx):
643643
_experimental_use_global_allocator = experimental_use_global_allocator,
644644
_experimental_use_coverage_metadata_files = ctx.attr._experimental_use_coverage_metadata_files[BuildSettingInfo].value,
645645
_experimental_toolchain_generated_sysroot = ctx.attr._experimental_toolchain_generated_sysroot[IncompatibleFlagInfo].enabled,
646+
_incompatible_no_rustc_sysroot_env = ctx.attr._incompatible_no_rustc_sysroot_env[IncompatibleFlagInfo].enabled,
646647
_incompatible_test_attr_crate_and_srcs_mutually_exclusive = ctx.attr._incompatible_test_attr_crate_and_srcs_mutually_exclusive[IncompatibleFlagInfo].enabled,
647648
_no_std = no_std,
648649
)
@@ -810,6 +811,9 @@ rust_toolchain = rule(
810811
"_incompatible_test_attr_crate_and_srcs_mutually_exclusive": attr.label(
811812
default = Label("//rust/settings:incompatible_test_attr_crate_and_srcs_mutually_exclusive"),
812813
),
814+
"_incompatible_rustc_sysroot_env": attr.label(
815+
default = Label("//rust/settings:incompatible_rustc_sysroot_env"),
816+
),
813817
"_no_std": attr.label(
814818
default = Label("//:no_std"),
815819
),

0 commit comments

Comments
 (0)