Skip to content

Commit ea92b08

Browse files
committedMay 7, 2022
Auto merge of #96670 - Urgau:bootstrap-check-cfg-features, r=Mark-Simulacrum
Enable cfg checking of cargo features for everything but std This PR enable `cfg` checking of cargo features for everything but std, it also adds a `FIXME` to myself. > 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. r? `@Mark-Simulacrum`
2 parents 24a0eec + 81d2cba commit ea92b08

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed
 

Diff for: ‎src/bootstrap/builder.rs

+14-5
Original file line numberDiff line numberDiff line change
@@ -1143,13 +1143,22 @@ impl<'a> Builder<'a> {
11431143
rustflags.arg("-Zunstable-options");
11441144
}
11451145

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

1152-
// Enable cfg checking of rustc well-known names
1161+
// Enable cfg checking of well known names/values
11531162
rustflags
11541163
.arg("-Zunstable-options")
11551164
// Enable checking of well known names

0 commit comments

Comments
 (0)
Please sign in to comment.