Skip to content

Commit 2ebb5b1

Browse files
authored
Rollup merge of rust-lang#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 rust-lang/libc#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.
2 parents e6e82db + ead8b96 commit 2ebb5b1

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/bootstrap/builder.rs

+9
Original file line numberDiff line numberDiff line change
@@ -1721,6 +1721,15 @@ impl<'a> Builder<'a> {
17211721

17221722
cargo.env("RUSTC_VERBOSE", self.verbosity.to_string());
17231723

1724+
// Downstream forks of the Rust compiler might want to use a custom libc to add support for
1725+
// targets that are not yet available upstream. Adding a patch to replace libc with a
1726+
// custom one would cause compilation errors though, because Cargo would interpret the
1727+
// custom libc as part of the workspace, and apply the check-cfg lints on it.
1728+
//
1729+
// The libc build script emits check-cfg flags only when this environment variable is set,
1730+
// so this line allows the use of custom libcs.
1731+
cargo.env("LIBC_CHECK_CFG", "1");
1732+
17241733
if source_type == SourceType::InTree {
17251734
let mut lint_flags = Vec::new();
17261735
// When extending this list, add the new lints to the RUSTFLAGS of the

0 commit comments

Comments
 (0)