Skip to content
This repository has been archived by the owner on Jul 18, 2024. It is now read-only.

Commit

Permalink
Added incompatible_no_rustc_sysroot_env (bazelbuild#2428)
Browse files Browse the repository at this point in the history
To remove `SYSROOT` from Rustc actions
  • Loading branch information
UebelAndre authored Jan 30, 2024
1 parent fe610da commit 649b32d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
3 changes: 2 additions & 1 deletion rust/private/rustc.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
7 changes: 7 additions & 0 deletions rust/settings/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -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",
)
4 changes: 4 additions & 0 deletions rust/toolchain.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Expand Down Expand Up @@ -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"),
),
Expand Down

0 comments on commit 649b32d

Please sign in to comment.