diff --git a/prelude/rust/build.bzl b/prelude/rust/build.bzl index 9294a7a9f4d0..646d22c81871 100644 --- a/prelude/rust/build.bzl +++ b/prelude/rust/build.bzl @@ -1352,7 +1352,7 @@ def _rustc_invoke( toolchain_info = compile_ctx.toolchain_info - plain_env, path_env = process_env(compile_ctx, ctx.attrs.env, exec_is_windows) + plain_env, path_env = process_env(compile_ctx, toolchain_info.rustc_env |ctx.attrs.env, exec_is_windows) more_plain_env, more_path_env = process_env(compile_ctx, env, exec_is_windows) plain_env.update(more_plain_env) diff --git a/prelude/rust/rust_toolchain.bzl b/prelude/rust/rust_toolchain.bzl index a69e40d69ae4..48d16d5f29d5 100644 --- a/prelude/rust/rust_toolchain.bzl +++ b/prelude/rust/rust_toolchain.bzl @@ -53,6 +53,8 @@ rust_toolchain_attrs = { # FIXME(JakobDegen): Can't use `list[str]` here, because then the default is wrong, but can't # use a non-empty list as the default because lists are mutable "rustc_coverage_flags": provider_field(typing.Any, default = ("-Cinstrument-coverage",)), + # Extra env variables that should be made available to the rustc executable. + "rustc_env": provider_field(dict[str, typing.Any], default = {}), # Extra env variables that should be made available to the rustdoc executable. "rustdoc_env": provider_field(dict[str, typing.Any], default = {}), # Extra flags for rustdoc invocations