about summary refs log tree commit diff
diff options
context:
space:
mode:
authorLoïc BRANSTETT <lolo.branstett@numericable.fr>2022-05-03 14:27:15 +0200
committerLoïc BRANSTETT <lolo.branstett@numericable.fr>2022-05-03 14:27:15 +0200
commit81d2cba36ff9e31dbdc009b49aa7fe8857052e0b (patch)
treebba29765e33b9a57939e9fdb085b15594bf76f33
parent468492c2af3993f18b1fe98052200575c4a2e678 (diff)
downloadrust-81d2cba36ff9e31dbdc009b49aa7fe8857052e0b.tar.gz
rust-81d2cba36ff9e31dbdc009b49aa7fe8857052e0b.zip
Enable cfg checking of cargo features for everything but std
-rw-r--r--src/bootstrap/builder.rs19
1 files changed, 14 insertions, 5 deletions
diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs
index edfe31319e8..1033c0f2d6b 100644
--- a/src/bootstrap/builder.rs
+++ b/src/bootstrap/builder.rs
@@ -1131,13 +1131,22 @@ impl<'a> Builder<'a> {
             rustflags.arg("-Zunstable-options");
         }
 
-        // #[cfg(not(bootstrap)]
+        // FIXME(Urgau): This a hack as it shouldn't be gated on stage 0 but until `rustc_llvm`
+        // is made to work with `--check-cfg` which is currently not easly possible until cargo
+        // get some support for setting `--check-cfg` within build script, it's the least invasive
+        // hack that still let's us have cfg checking for the vast majority of the codebase.
         if stage != 0 {
-            // Enable cfg checking of cargo features
-            // FIXME: De-comment this when cargo beta get support for it
-            // cargo.arg("-Zcheck-cfg-features");
+            // Enable cfg checking of cargo features for everything but std.
+            //
+            // Note: `std`, `alloc` and `core` imports some dependencies by #[path] (like
+            // backtrace, core_simd, std_float, ...), those dependencies have their own features
+            // but cargo isn't involved in the #[path] and so cannot pass the complete list of
+            // features, so for that reason we don't enable checking of features for std.
+            if mode != Mode::Std {
+                cargo.arg("-Zcheck-cfg-features");
+            }
 
-            // Enable cfg checking of rustc well-known names
+            // Enable cfg checking of well known names/values
             rustflags
                 .arg("-Zunstable-options")
                 // Enable checking of well known names