CARGO_CFG_TARGET_FAMILY is not defined for build-script in no_std #12728
Labels
A-build-scripts
Area: build.rs scripts
A-documenting-cargo-itself
Area: Cargo's documentation
C-bug
Category: bug
S-accepted
Status: Issue or feature is accepted, and has a team member available to help mentor or review
Problem
There is an issue reported downstream where the
CARGO_CFG_TARGET_FAMILY
environment variable is not defined when executing a build-script for ano_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
main.rs
to be[no_std]
build.rs
CARGO_CFG_TARGET_FAMILY
inbuild.rs
while building theno_std
-binary.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 ano_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, whileCARGO_CFG_TARGET_FAMILY
is not.Version
The text was updated successfully, but these errors were encountered: