File tree 3 files changed +13
-1
lines changed
3 files changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -1059,7 +1059,8 @@ def construct_arguments(
1059
1059
))
1060
1060
1061
1061
# 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
1063
1064
if toolchain ._experimental_toolchain_generated_sysroot :
1064
1065
rustc_flags .add (toolchain .sysroot , format = "--sysroot=%s" )
1065
1066
Original file line number Diff line number Diff line change @@ -98,3 +98,10 @@ incompatible_flag(
98
98
build_setting_default = True ,
99
99
issue = "https://github.com/bazelbuild/rules_rust/issues/2324" ,
100
100
)
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
+ )
Original file line number Diff line number Diff line change @@ -643,6 +643,7 @@ def _rust_toolchain_impl(ctx):
643
643
_experimental_use_global_allocator = experimental_use_global_allocator ,
644
644
_experimental_use_coverage_metadata_files = ctx .attr ._experimental_use_coverage_metadata_files [BuildSettingInfo ].value ,
645
645
_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 ,
646
647
_incompatible_test_attr_crate_and_srcs_mutually_exclusive = ctx .attr ._incompatible_test_attr_crate_and_srcs_mutually_exclusive [IncompatibleFlagInfo ].enabled ,
647
648
_no_std = no_std ,
648
649
)
@@ -810,6 +811,9 @@ rust_toolchain = rule(
810
811
"_incompatible_test_attr_crate_and_srcs_mutually_exclusive" : attr .label (
811
812
default = Label ("//rust/settings:incompatible_test_attr_crate_and_srcs_mutually_exclusive" ),
812
813
),
814
+ "_incompatible_rustc_sysroot_env" : attr .label (
815
+ default = Label ("//rust/settings:incompatible_rustc_sysroot_env" ),
816
+ ),
813
817
"_no_std" : attr .label (
814
818
default = Label ("//:no_std" ),
815
819
),
You can’t perform that action at this time.
0 commit comments