Does `cc` need to be on PATH if I specify it with RUSTFLAGS?

If I use CARGO_TARGET_<triple>_RUSTFLAGS to set -C linker=/usr/bin/cc (or do so with similar environment variables, or Cargo.toml configuration) is it also necessary that cc be visible on PATH?

I've been stuck on a bug for a few days that appears to be fixed by ensuring my cargo invocation has the environment variable PATH=/usr/bin set. But this feels like it shouldn't be necessary if we specify the absolute path to the linker.

Perhaps you have Cargo dependencies that compile C code, separately from Rust? The linker flag is just for linking Rust code at the end.

Ah, that's a very real possibility. So I take it there's no standard environment variable that dependencies can look to for a linker? Nothing stops a build.rs file from just invoking an unqualified cc, anyway.

CC is the standard env var for it. If you're cross-compiling, then there's HOST_CC, or various combinations with the target prefix.