bazelbuild / bazelbuild/rules_rust
CARGO_CFG_TARGET_OS not passed to specific build subcommand
- Dominant language
- Starlark
- Stars
- 843
- Forks
- 651
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 15
Description
When building the following rule I get an error stating `Unable to get target_os='environment variable not found'!`. Debugging into the sandbox environment shows that for the subcommand it fails on it doesn't have `CARGO_CFG_TARGET_OS` but for prior ones it does have `CARGO_CFG_TARGET_OS` set. I have no idea why this would be the case.
```
rust_binary(
name = "hello",
srcs = ["hello.rs"],
deps = [
"//3rdparty/cargo:piston",
"//3rdparty/cargo:piston_window",
"//3rdparty/cargo:piston_shaders",
],
)
```
```
SUBCOMMAND: # //3rdparty/cargo/vendor/rustc_version-0.2.3:rustc_version [action 'Compiling Rust lib rustc_version v0.2.3 (2 files) [for host]', configuration: 0e11c9a2f02baa2ac90a2f12f65e2efa4b23eb9c0e167dd41cf1d9f808cb43ad]
(cd /home/tanner/.cache/bazel/_bazel_tanner/d181a7da3571313ad6565f41cfee172a/execroot/core && \
exec env - \
CARGO_CFG_TARGET_ARCH=x86_64 \
CARGO_CFG_TARGET_OS=linux \
CARGO_MANIFEST_DIR='${pwd}/3rdparty/cargo/vendor/rustc_version-0.2.3' \
CARGO_PKG_AUTHORS='' \
CARGO_PKG_DESCRIPTION='' \
CARGO_PKG_HOMEPAGE='' \
CARGO_PKG_NAME=rustc_version \
CARGO_PKG_VERSION=0.2.3 \
CARGO_PKG_VERSION_MAJOR=0 \
CARGO_PKG_VERSION_MINOR=2 \
CARGO_PKG_VERSION_PATCH=3 \
CARGO_PKG_VERSION_PRE='' \
SYSROOT='' \
bazel-out/host/bin/external/io_bazel_rules_rust/util/process_wrapper/process_wrapper --subst 'pwd=${pwd}' -- external/rustc/bin/rustc 3rdparty/cargo/vendor/rustc_version-0.2.3/src/lib.rs '--crate-name=rustc_version' '--crate-type=lib' '--codegen=metadata=-1375011430' '--out-dir=bazel-out/host/bin/3rdparty/cargo/vendor/rustc_version-0.2.3' '--codegen=extra-filename=-1375011430' '--codegen=opt-level=3' '--codegen=debuginfo=0' '--emit=dep-info,link' '--color=always' '--target=x86_64-unknown-linux-gnu' -L external/rustc/lib/rustlib/x86_64-unknown-linux-gnu/lib '--cap-lints=allow' '--codegen=linker=/home/tanner/.nix-profile/bin/gcc' --codegen 'link-args=-fuse-ld=gold -Wl,-no-as-needed -Wl,-z,relro,-z,now -B/home/tanner/.nix-profile/bin -pass-exit-codes -lstdc++ -lm -Wl,--gc-sections' --extern 'semver=bazel-out/host/bin/3rdparty/cargo/vendor/semver-0.9.0/libsemver-1646363846.rlib' '-Ldependency=bazel-out/host/bin/3rdparty/cargo/vendor/semver-0.9.0' '-Ldependency=bazel-out/host/bin/3rdparty/cargo/vendor/semver-parser-0.7.0')
SUBCOMMAND: # //3rdparty/cargo/vendor/libloading-0.6.3:libloading_build_script [action 'CargoBuildScriptRun 3rdparty/cargo/vendor/libloading-0.6.3/libloading_build_script.out_dir [for host]', configuration: 0e11c9a2f02baa2ac90a2f12f65e2efa4b23eb9c0e167dd41cf1d9f808cb43ad]
(cd /home/tanner/.cache/bazel/_bazel_tanner/d181a7da3571313ad6565f41cfee172a/execroot/core && \
exec env - \
AR=/home/tanner/.nix-profile/bin/ar \
CARGO_CFG_TARGET_ARCH=x86_64 \
CARGO_MANIFEST_DIR=bazel-out/host/bin/3rdparty/cargo/vendor/libloading-0.6.3/libloading_build_script_script_.runfiles/core \
CARGO_PKG_NAME=libloading \
CARGO_PKG_VERSION=0.6.3 \
CARGO_PKG_VERSION_MAJOR=0 \
CARGO_PKG_VERSION_MINOR=6 \
CARGO_PKG_VERSION_PATCH=3 \
CARGO_PKG_VERSION_PRE='' \
CC=/home/tanner/.nix-profile/bin/gcc \
HOST=x86_64-unknown-linux-gnu \
OPT_LEVEL=3 \
RUSTC=external/rustc/bin/rustc \
TARGET=x86_64-unknown-linux-gnu \
bazel-out/host/bin/external/io_bazel_rules_rust/cargo/cargo_build_script_runner/cargo_build_script_runner bazel-out/host/bin/3rdparty/cargo/vendor/libloading-0.6.3/libloading_build_script_script_ libloading bazel-out/host/bin/3rdparty/cargo/vendor/libloading-0.6.3/libloading_build_script.out_dir bazel-out/host/bin/3rdparty/cargo/vendor/libloading-0.6.3/libloading_build_script.env bazel-out/host/bin/3rdparty/cargo/vendor/libloading-0.6.3/libloading_build_script.flags bazel-out/host/bin/3rdparty/cargo/vendor/libloading-0.6.3/libloading_build_script.linkflags bazel-out/host/bin/3rdparty/cargo/vendor/libloading-0.6.3/libloading_build_script.depenv)
```
Contributor guide
Assessment
This issue has not been assessed yet.