about summary refs log tree commit diff
diff options
context:
space:
mode:
authorPietro Albini <pietro.albini@ferrous-systems.com>2023-03-08 12:14:19 +0100
committerPietro Albini <pietro.albini@ferrous-systems.com>2023-03-08 12:14:19 +0100
commitead8b96281334c58fdec64362d9d03b82e85f788 (patch)
tree2b05424a13b54c7fdfe69c72b557421ed29828a9
parent64165aac68af780182ff89a6eb3982e3c262266e (diff)
downloadrust-ead8b96281334c58fdec64362d9d03b82e85f788.tar.gz
rust-ead8b96281334c58fdec64362d9d03b82e85f788.zip
set LIBC_CHECK_CFG=1 when building Rust code in bootstrap
-rw-r--r--src/bootstrap/builder.rs9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs
index b33fc02f49c..9beccd4f8f2 100644
--- a/src/bootstrap/builder.rs
+++ b/src/bootstrap/builder.rs
@@ -1718,6 +1718,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