-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Description
Problem
There is an issue reported downstream where the CARGO_CFG_TARGET_FAMILY
environment variable is not defined when executing a build-script for a no_std
binary. The said environment variable seems to be indeed not defined at all. AFAICS this is contrary to what is documented about the environment variables set by cargo, e.g. here or here.
Steps
- Set
main.rs
to be[no_std]
- Add a
build.rs
- Try to observe
CARGO_CFG_TARGET_FAMILY
inbuild.rs
while building theno_std
-binary. - While most variables are defined as documented,
CARGO_CFG_TARGET_FAMILY
is not present in the build-script's environment.
Possible Solution(s)
The way I read the documentation, the listed environment variables (including CARGO_CFG_TARGET_FAMILY
, even in a no_std
setting) should always be defined. If they have no value, possibly because they have no meaning in the given setting, they could be set to the empty string / NULL
. The exact behavior of subprocesses launched by a build-script (if any) seems to vary with respect to empty environment variables, though.
If the full set of environment variables mentioned in the documentation can't be made present in all settings, this should be documented.
Notes
Notice that CARGO_CFG_TARGET_OS: none
is defined in the downstream bug report, while CARGO_CFG_TARGET_FAMILY
is not.
Version
cargo 1.72.0 (103a7ff2e 2023-08-15)
release: 1.72.0
commit-hash: 103a7ff2ee7678d34f34d778614c5eb2525ae9de
commit-date: 2023-08-15
host: x86_64-apple-darwin
libgit2: 1.6.4 (sys:0.17.2 vendored)
libcurl: 8.1.2 (sys:0.4.63+curl-8.1.2 system ssl:(SecureTransport) LibreSSL/3.3.6)
ssl: OpenSSL 1.1.1u 30 May 2023
os: Mac OS 13.5.2 [64-bit]