Skip to content

Commit cafca7d

Browse files
authored
Rollup merge of #101921 - est31:bootstrap_cfg_rustdoc, r=joshtriplett
Pass --cfg=bootstrap for rustdoc for proc_macro crates This PR does three things: * First, it passes --cfg=bootstrap on stage 0 for rustdoc invocations on proc_macro crates. This mirrors what we do already for rustc invocations of those, and is needed because cargo doesn't respect RUSTFLAGS or RUSTDOCFLAGS when confronted with a proc macro. * Second, it marks the bootstrap config variable as expected. This is needed both on later stages where it's not set, but also on stage 0, where it is set. * Third, it adjusts the comment in the rustc wrapper to better reflect the reason why we set the bootstrap variable as expected: due to recent changes, setting it as expected is also required even if the cfg variable is passed: ebf4cc3 .
2 parents bba939e + 706f0f0 commit cafca7d

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

src/bootstrap/bin/rustc.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -139,10 +139,8 @@ fn main() {
139139
// Cargo doesn't pass RUSTFLAGS to proc_macros:
140140
// https://github.com/rust-lang/cargo/issues/4423
141141
// Thus, if we are on stage 0, we explicitly set `--cfg=bootstrap`.
142-
// We also declare that the flag is expected, which is mainly needed for
143-
// later stages so that they don't warn about #[cfg(bootstrap)],
144-
// but enabling it for stage 0 too lets any warnings, if they occur,
145-
// occur more early on, e.g. about #[cfg(bootstrap = "foo")].
142+
// We also declare that the flag is expected, which we need to do to not
143+
// get warnings about it being unexpected.
146144
if stage == "0" {
147145
cmd.arg("--cfg=bootstrap");
148146
}

src/bootstrap/bin/rustdoc.rs

+11
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ include!("../dylib_util.rs");
1111

1212
fn main() {
1313
let args = env::args_os().skip(1).collect::<Vec<_>>();
14+
let stage = env::var("RUSTC_STAGE").expect("RUSTC_STAGE was not set");
1415
let rustdoc = env::var_os("RUSTDOC_REAL").expect("RUSTDOC_REAL was not set");
1516
let libdir = env::var_os("RUSTDOC_LIBDIR").expect("RUSTDOC_LIBDIR was not set");
1617
let sysroot = env::var_os("RUSTC_SYSROOT").expect("RUSTC_SYSROOT was not set");
@@ -62,6 +63,16 @@ fn main() {
6263
cmd.arg("-Clink-arg=-Wl,--threads=1");
6364
}
6465
}
66+
// Cargo doesn't pass RUSTDOCFLAGS to proc_macros:
67+
// https://github.com/rust-lang/cargo/issues/4423
68+
// Thus, if we are on stage 0, we explicitly set `--cfg=bootstrap`.
69+
// We also declare that the flag is expected, which we need to do to not
70+
// get warnings about it being unexpected.
71+
if stage == "0" {
72+
cmd.arg("--cfg=bootstrap");
73+
}
74+
cmd.arg("-Zunstable-options");
75+
cmd.arg("--check-cfg=values(bootstrap)");
6576

6677
if verbose > 1 {
6778
eprintln!(

0 commit comments

Comments
 (0)