fn extra_args(
gctx: &GlobalContext,
requested_kinds: &[CompileKind],
host_triple: &str,
target_cfg: Option<&[Cfg]>,
kind: CompileKind,
flags: Flags,
) -> CargoResult<Vec<String>>Expand description
Acquire extra flags to pass to the compiler from various locations.
The locations are:
- the
CARGO_ENCODED_RUSTFLAGSenvironment variable - the
RUSTFLAGSenvironment variable
then if none of those were found
target.*.rustflagsfrom the config (.cargo/config)target.cfg(..).rustflagsfrom the confighost.*.rustflagsfrom the config if compiling a host artifact or without--target(requires-Zhost-config)
then if none of those were found
build.rustflagsfrom the config
The behavior differs slightly when cross-compiling (or, specifically, when --target is
provided) for artifacts that are always built for the host (plugins, build scripts, …).
For those artifacts, only host.*.rustflags is respected, and no other configuration
sources, regardless of the value of target-applies-to-host. This is counterintuitive, but
necessary to retain backwards compatibility with older versions of Cargo.
Rules above also applies to rustdoc. Just the key would be rustdocflags/RUSTDOCFLAGS.