You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Cargo sets this list of env vars when either invoking rustc, or cargo runing or cargo testing a binary. We should be setting them all when we invoke rustc.
Cargo additionally sets this list of env vars when running (not when compiling) a build script. We should be setting them all when we invoke a build script. We should also be setting all of the rustc env vars when we invoke a build script.
Both of these lists are currently incomplete, as we've generally added stuff as-needed. Additionally, the rustc_env list contains some vars which should actually only be in the build_script list (e.g. CARGO_CFG_TARGET_ARCH and CARGO_CFG_TARGET_OS).
We should:
Make the build script env vars be a superset of the rustc ones, by calling _get_rustc_env from _build_script_impl. This will both help keep the lists in sync, and avoid duplicating things like the processing of version numbers.
Move any build_script-specific env vars out of _get_rustc_env
(Optional): Add more env vars pro-actively, rather than reactively when someone finds some third-party code doesn't build.
The text was updated successfully, but these errors were encountered:
$CARGO is definitely a tricky one. In the short term, you can probably add an annotation setting build_script_data to @rules_rust//rust/toolchain:current_cargo_files and setting build_script_env to {"CARGO": "$(execpath @rules_rust//rust/toolchain:current_cargo_files)"}. But in general, any time a build script tries to use cargo directly, it's likely to be doing something that won't be exactly compatible with how Bazel runs things.
Cargo sets this list of env vars when either invoking rustc, or
cargo run
ing orcargo test
ing a binary. We should be setting them all when we invokerustc
.Cargo additionally sets this list of env vars when running (not when compiling) a build script. We should be setting them all when we invoke a build script. We should also be setting all of the
rustc
env vars when we invoke a build script.Currently we have two lists of env vars:
This list is used for when we invoke
rustc
:rules_rust/rust/private/rustc.bzl
Lines 57 to 85 in e744b93
This list is used when we invoke an already-compiled build-script (note that we use the above list when compiling the build script):
rules_rust/cargo/cargo_build_script.bzl
Lines 79 to 132 in e744b93
Both of these lists are currently incomplete, as we've generally added stuff as-needed. Additionally, the
rustc_env
list contains some vars which should actually only be in the build_script list (e.g.CARGO_CFG_TARGET_ARCH
andCARGO_CFG_TARGET_OS
).We should:
_get_rustc_env
from_build_script_impl
. This will both help keep the lists in sync, and avoid duplicating things like the processing of version numbers._get_rustc_env
The text was updated successfully, but these errors were encountered: