Skip to content

Commit 81d2cba

Browse files
committed
Enable cfg checking of cargo features for everything but std
1 parent 468492c commit 81d2cba

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

src/bootstrap/builder.rs

+14-5
Original file line numberDiff line numberDiff line change
@@ -1131,13 +1131,22 @@ impl<'a> Builder<'a> {
11311131
rustflags.arg("-Zunstable-options");
11321132
}
11331133

1134-
// #[cfg(not(bootstrap)]
1134+
// FIXME(Urgau): This a hack as it shouldn't be gated on stage 0 but until `rustc_llvm`
1135+
// is made to work with `--check-cfg` which is currently not easly possible until cargo
1136+
// get some support for setting `--check-cfg` within build script, it's the least invasive
1137+
// hack that still let's us have cfg checking for the vast majority of the codebase.
11351138
if stage != 0 {
1136-
// Enable cfg checking of cargo features
1137-
// FIXME: De-comment this when cargo beta get support for it
1138-
// cargo.arg("-Zcheck-cfg-features");
1139+
// Enable cfg checking of cargo features for everything but std.
1140+
//
1141+
// Note: `std`, `alloc` and `core` imports some dependencies by #[path] (like
1142+
// backtrace, core_simd, std_float, ...), those dependencies have their own features
1143+
// but cargo isn't involved in the #[path] and so cannot pass the complete list of
1144+
// features, so for that reason we don't enable checking of features for std.
1145+
if mode != Mode::Std {
1146+
cargo.arg("-Zcheck-cfg-features");
1147+
}
11391148

1140-
// Enable cfg checking of rustc well-known names
1149+
// Enable cfg checking of well known names/values
11411150
rustflags
11421151
.arg("-Zunstable-options")
11431152
// Enable checking of well known names

0 commit comments

Comments
 (0)