Rollup merge of #108898 - ferrocene:pa-libc-check-cfg, r=Mark-Simulacrum

Set `LIBC_CHECK_CFG=1` when building Rust code in bootstrap

Downstream forks of the Rust compiler might want to use a custom `libc` to add support for targets that are not yet available upstream. Adding a patch to replace `libc` with a custom one would cause compilation errors though, because Cargo would interpret the custom `libc` as part of the workspace, and apply the check-cfg lints on it.

Since https://github.com/rust-lang/libc/pull/3037, the `libc` build script emits check-cfg flags only when the `LIBC_CHECK_CFG` environment variable is set, so this PR allows the use of custom `libc`s.
This commit is contained in:
Matthias Krüger 2023-03-08 21:26:52 +01:00 committed by GitHub
commit 2ebb5b1ddc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1721,6 +1721,15 @@ impl<'a> Builder<'a> {
cargo.env("RUSTC_VERBOSE", self.verbosity.to_string());
// Downstream forks of the Rust compiler might want to use a custom libc to add support for
// targets that are not yet available upstream. Adding a patch to replace libc with a
// custom one would cause compilation errors though, because Cargo would interpret the
// custom libc as part of the workspace, and apply the check-cfg lints on it.
//
// The libc build script emits check-cfg flags only when this environment variable is set,
// so this line allows the use of custom libcs.
cargo.env("LIBC_CHECK_CFG", "1");
if source_type == SourceType::InTree {
let mut lint_flags = Vec::new();
// When extending this list, add the new lints to the RUSTFLAGS of the