diff options
| author | Dylan DPC <99973273+Dylan-DPC@users.noreply.github.com> | 2023-05-08 11:39:23 +0530 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-05-08 11:39:23 +0530 |
| commit | 172ddccc5086b1b7fe1f2374c9f116974af75f6a (patch) | |
| tree | 5379e342cdfc0cf9e4881c22c8d2efbd83247b28 | |
| parent | 940567068c2da9eceec21239e7aad75ad20b0b4e (diff) | |
| parent | 654f56e086fad836da5931e1a3defad804d9cfe9 (diff) | |
| download | rust-172ddccc5086b1b7fe1f2374c9f116974af75f6a.tar.gz rust-172ddccc5086b1b7fe1f2374c9f116974af75f6a.zip | |
Rollup merge of #111323 - jyn514:shim-error, r=Mark-Simulacrum
Give a more helpful error when running the rustc shim directly cc https://rust-lang.zulipchat.com/#narrow/stream/326414-t-infra.2Fbootstrap/topic/Building.20.60coretests.60.20by.20hand
| -rw-r--r-- | src/bootstrap/bin/rustc.rs | 9 | ||||
| -rw-r--r-- | src/bootstrap/bin/rustdoc.rs | 9 |
2 files changed, 14 insertions, 4 deletions
diff --git a/src/bootstrap/bin/rustc.rs b/src/bootstrap/bin/rustc.rs index dd86634b47c..e87125a49a6 100644 --- a/src/bootstrap/bin/rustc.rs +++ b/src/bootstrap/bin/rustc.rs @@ -19,7 +19,7 @@ include!("../dylib_util.rs"); use std::env; use std::path::PathBuf; -use std::process::{Child, Command}; +use std::process::{exit, Child, Command}; use std::str::FromStr; use std::time::Instant; @@ -47,7 +47,12 @@ fn main() { } else { ("RUSTC_REAL", "RUSTC_LIBDIR") }; - let stage = env::var("RUSTC_STAGE").expect("RUSTC_STAGE was not set"); + let stage = env::var("RUSTC_STAGE").unwrap_or_else(|_| { + // Don't panic here; it's reasonable to try and run these shims directly. Give a helpful error instead. + eprintln!("rustc shim: fatal: RUSTC_STAGE was not set"); + eprintln!("rustc shim: note: use `x.py build -vvv` to see all environment variables set by bootstrap"); + exit(101); + }); let sysroot = env::var_os("RUSTC_SYSROOT").expect("RUSTC_SYSROOT was not set"); let on_fail = env::var_os("RUSTC_ON_FAIL").map(Command::new); diff --git a/src/bootstrap/bin/rustdoc.rs b/src/bootstrap/bin/rustdoc.rs index 23828f4758d..d2b85f7a629 100644 --- a/src/bootstrap/bin/rustdoc.rs +++ b/src/bootstrap/bin/rustdoc.rs @@ -5,13 +5,18 @@ use std::env; use std::ffi::OsString; use std::path::PathBuf; -use std::process::Command; +use std::process::{exit, Command}; 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 stage = env::var("RUSTC_STAGE").unwrap_or_else(|_| { + // Don't panic here; it's reasonable to try and run these shims directly. Give a helpful error instead. + eprintln!("rustc shim: fatal: RUSTC_STAGE was not set"); + eprintln!("rustc shim: note: use `x.py build -vvv` to see all environment variables set by bootstrap"); + exit(101); + }); 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"); |
