about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorMichael Howell <michael@notriddle.com>2022-09-16 20:37:17 -0700
committerGitHub <noreply@github.com>2022-09-16 20:37:17 -0700
commitcafca7d2197e3fbfbd9efe8870fb0fa559e11fb3 (patch)
treeae066dd3db948279ed91842ed459e5d20f17f0c5 /src
parentbba939ee94bc91a3134634e435652caded217164 (diff)
parent706f0f018b2e186aa9c464e0e8d7e20b0dfd324a (diff)
downloadrust-cafca7d2197e3fbfbd9efe8870fb0fa559e11fb3.tar.gz
rust-cafca7d2197e3fbfbd9efe8870fb0fa559e11fb3.zip
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: ebf4cc361e0d0f11a25b42372bd629953365d17e .
Diffstat (limited to 'src')
-rw-r--r--src/bootstrap/bin/rustc.rs6
-rw-r--r--src/bootstrap/bin/rustdoc.rs11
2 files changed, 13 insertions, 4 deletions
diff --git a/src/bootstrap/bin/rustc.rs b/src/bootstrap/bin/rustc.rs
index bd5790d2ea8..e96f8b0d312 100644
--- a/src/bootstrap/bin/rustc.rs
+++ b/src/bootstrap/bin/rustc.rs
@@ -139,10 +139,8 @@ fn main() {
         // 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 is mainly needed for
-        // later stages so that they don't warn about #[cfg(bootstrap)],
-        // but enabling it for stage 0 too lets any warnings, if they occur,
-        // occur more early on, e.g. about #[cfg(bootstrap = "foo")].
+        // We also declare that the flag is expected, which we need to do to not
+        // get warnings about it being unexpected.
         if stage == "0" {
             cmd.arg("--cfg=bootstrap");
         }
diff --git a/src/bootstrap/bin/rustdoc.rs b/src/bootstrap/bin/rustdoc.rs
index 87c1d22e771..e69cab956c5 100644
--- a/src/bootstrap/bin/rustdoc.rs
+++ b/src/bootstrap/bin/rustdoc.rs
@@ -11,6 +11,7 @@ include!("../dylib_util.rs");
 
 fn main() {
     let args = env::args_os().skip(1).collect::<Vec<_>>();
+    let stage = env::var("RUSTC_STAGE").expect("RUSTC_STAGE was not set");
     let rustdoc = env::var_os("RUSTDOC_REAL").expect("RUSTDOC_REAL was not set");
     let libdir = env::var_os("RUSTDOC_LIBDIR").expect("RUSTDOC_LIBDIR was not set");
     let sysroot = env::var_os("RUSTC_SYSROOT").expect("RUSTC_SYSROOT was not set");
@@ -62,6 +63,16 @@ fn main() {
             cmd.arg("-Clink-arg=-Wl,--threads=1");
         }
     }
+    // Cargo doesn't pass RUSTDOCFLAGS 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.
+    if stage == "0" {
+        cmd.arg("--cfg=bootstrap");
+    }
+    cmd.arg("-Zunstable-options");
+    cmd.arg("--check-cfg=values(bootstrap)");
 
     if verbose > 1 {
         eprintln!(