Skip to content

Commit ad378be

Browse files
authored
Rollup merge of #142160 - Urgau:check-cfg-bootstrap-only-rustc, r=Kobzol
Only allow `bootstrap` cfg in rustc & related Fixes #142150 r? bootstrap
2 parents 45cf4fb + 9b1cd72 commit ad378be

File tree

3 files changed

+14
-9
lines changed

3 files changed

+14
-9
lines changed

library/core/src/iter/sources/generator.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
/// ```
2121
#[unstable(feature = "iter_macro", issue = "none", reason = "generators are unstable")]
2222
#[allow_internal_unstable(coroutines, iter_from_coroutine)]
23-
#[cfg_attr(not(bootstrap), rustc_builtin_macro)]
23+
#[rustc_builtin_macro]
2424
pub macro iter($($t:tt)*) {
2525
/* compiler-builtin */
2626
}

src/bootstrap/src/core/builder/cargo.rs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -636,6 +636,15 @@ impl Builder<'_> {
636636
for (restricted_mode, name, values) in EXTRA_CHECK_CFGS {
637637
if restricted_mode.is_none() || *restricted_mode == Some(mode) {
638638
rustflags.arg(&check_cfg_arg(name, *values));
639+
640+
if *name == "bootstrap" {
641+
// Cargo doesn't pass RUSTFLAGS to proc_macros:
642+
// https://github.com/rust-lang/cargo/issues/4423
643+
// Thus, if we are on stage 0, we explicitly set `--cfg=bootstrap`.
644+
// We also declare that the flag is expected, which we need to do to not
645+
// get warnings about it being unexpected.
646+
hostflags.arg(check_cfg_arg(name, *values));
647+
}
639648
}
640649
}
641650

@@ -645,13 +654,6 @@ impl Builder<'_> {
645654
if stage == 0 {
646655
hostflags.arg("--cfg=bootstrap");
647656
}
648-
// Cargo doesn't pass RUSTFLAGS to proc_macros:
649-
// https://github.com/rust-lang/cargo/issues/4423
650-
// Thus, if we are on stage 0, we explicitly set `--cfg=bootstrap`.
651-
// We also declare that the flag is expected, which we need to do to not
652-
// get warnings about it being unexpected.
653-
hostflags.arg("-Zunstable-options");
654-
hostflags.arg("--check-cfg=cfg(bootstrap)");
655657

656658
// FIXME: It might be better to use the same value for both `RUSTFLAGS` and `RUSTDOCFLAGS`,
657659
// but this breaks CI. At the very least, stage0 `rustdoc` needs `--cfg bootstrap`. See

src/bootstrap/src/lib.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,10 @@ const LLD_FILE_NAMES: &[&str] = &["ld.lld", "ld64.lld", "lld-link", "wasm-ld"];
8181
/// (Mode restriction, config name, config values (if any))
8282
#[expect(clippy::type_complexity)] // It's fine for hard-coded list and type is explained above.
8383
const EXTRA_CHECK_CFGS: &[(Option<Mode>, &str, Option<&[&'static str]>)] = &[
84-
(None, "bootstrap", None),
84+
(Some(Mode::Rustc), "bootstrap", None),
85+
(Some(Mode::Codegen), "bootstrap", None),
86+
(Some(Mode::ToolRustc), "bootstrap", None),
87+
(Some(Mode::ToolStd), "bootstrap", None),
8588
(Some(Mode::Rustc), "llvm_enzyme", None),
8689
(Some(Mode::Codegen), "llvm_enzyme", None),
8790
(Some(Mode::ToolRustc), "llvm_enzyme", None),

0 commit comments

Comments
 (0)