diff options
| author | Matthias Krüger <476013+matthiaskrgr@users.noreply.github.com> | 2025-06-09 10:20:52 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-06-09 10:20:52 +0200 |
| commit | ad378be221eb80f6d2dca73bdc05208c2a091107 (patch) | |
| tree | eb4a424bf8e0ef04e1985f254081aff7b3091438 | |
| parent | 45cf4fb8d7fb958334fc6213a45f8c8bb04e1096 (diff) | |
| parent | 9b1cd722ca7490ae28db77b44eefb4700ef6bb19 (diff) | |
| download | rust-ad378be221eb80f6d2dca73bdc05208c2a091107.tar.gz rust-ad378be221eb80f6d2dca73bdc05208c2a091107.zip | |
Rollup merge of #142160 - Urgau:check-cfg-bootstrap-only-rustc, r=Kobzol
Only allow `bootstrap` cfg in rustc & related Fixes https://github.com/rust-lang/rust/issues/142150 r? bootstrap
| -rw-r--r-- | library/core/src/iter/sources/generator.rs | 2 | ||||
| -rw-r--r-- | src/bootstrap/src/core/builder/cargo.rs | 16 | ||||
| -rw-r--r-- | src/bootstrap/src/lib.rs | 5 |
3 files changed, 14 insertions, 9 deletions
diff --git a/library/core/src/iter/sources/generator.rs b/library/core/src/iter/sources/generator.rs index 155fa9368ad..0846974d526 100644 --- a/library/core/src/iter/sources/generator.rs +++ b/library/core/src/iter/sources/generator.rs @@ -20,7 +20,7 @@ /// ``` #[unstable(feature = "iter_macro", issue = "none", reason = "generators are unstable")] #[allow_internal_unstable(coroutines, iter_from_coroutine)] -#[cfg_attr(not(bootstrap), rustc_builtin_macro)] +#[rustc_builtin_macro] pub macro iter($($t:tt)*) { /* compiler-builtin */ } diff --git a/src/bootstrap/src/core/builder/cargo.rs b/src/bootstrap/src/core/builder/cargo.rs index 3f7421b6f49..cf7f962d026 100644 --- a/src/bootstrap/src/core/builder/cargo.rs +++ b/src/bootstrap/src/core/builder/cargo.rs @@ -636,6 +636,15 @@ impl Builder<'_> { for (restricted_mode, name, values) in EXTRA_CHECK_CFGS { if restricted_mode.is_none() || *restricted_mode == Some(mode) { rustflags.arg(&check_cfg_arg(name, *values)); + + if *name == "bootstrap" { + // Cargo doesn't pass RUSTFLAGS to proc_macros: + // https://github.com/rust-lang/cargo/issues/4423 + // Thus, if we are on stage 0, we explicitly set `--cfg=bootstrap`. + // We also declare that the flag is expected, which we need to do to not + // get warnings about it being unexpected. + hostflags.arg(check_cfg_arg(name, *values)); + } } } @@ -645,13 +654,6 @@ impl Builder<'_> { if stage == 0 { hostflags.arg("--cfg=bootstrap"); } - // Cargo doesn't pass RUSTFLAGS to proc_macros: - // https://github.com/rust-lang/cargo/issues/4423 - // Thus, if we are on stage 0, we explicitly set `--cfg=bootstrap`. - // We also declare that the flag is expected, which we need to do to not - // get warnings about it being unexpected. - hostflags.arg("-Zunstable-options"); - hostflags.arg("--check-cfg=cfg(bootstrap)"); // FIXME: It might be better to use the same value for both `RUSTFLAGS` and `RUSTDOCFLAGS`, // but this breaks CI. At the very least, stage0 `rustdoc` needs `--cfg bootstrap`. See diff --git a/src/bootstrap/src/lib.rs b/src/bootstrap/src/lib.rs index 760920104e9..7db57889009 100644 --- a/src/bootstrap/src/lib.rs +++ b/src/bootstrap/src/lib.rs @@ -81,7 +81,10 @@ const LLD_FILE_NAMES: &[&str] = &["ld.lld", "ld64.lld", "lld-link", "wasm-ld"]; /// (Mode restriction, config name, config values (if any)) #[expect(clippy::type_complexity)] // It's fine for hard-coded list and type is explained above. const EXTRA_CHECK_CFGS: &[(Option<Mode>, &str, Option<&[&'static str]>)] = &[ - (None, "bootstrap", None), + (Some(Mode::Rustc), "bootstrap", None), + (Some(Mode::Codegen), "bootstrap", None), + (Some(Mode::ToolRustc), "bootstrap", None), + (Some(Mode::ToolStd), "bootstrap", None), (Some(Mode::Rustc), "llvm_enzyme", None), (Some(Mode::Codegen), "llvm_enzyme", None), (Some(Mode::ToolRustc), "llvm_enzyme", None), |
