diff --git a/src/bootstrap/src/core/builder/cargo.rs b/src/bootstrap/src/core/builder/cargo.rs index 3ce21eb151c3c..39c91ea030df8 100644 --- a/src/bootstrap/src/core/builder/cargo.rs +++ b/src/bootstrap/src/core/builder/cargo.rs @@ -101,6 +101,7 @@ pub struct Cargo { impl Cargo { /// Calls [`Builder::cargo`] and [`Cargo::configure_linker`] to prepare an invocation of `cargo` /// to be run. + #[track_caller] pub fn new( builder: &Builder<'_>, compiler: Compiler, @@ -139,6 +140,7 @@ impl Cargo { /// Same as [`Cargo::new`] except this one doesn't configure the linker with /// [`Cargo::configure_linker`]. + #[track_caller] pub fn new_for_mir_opt_tests( builder: &Builder<'_>, compiler: Compiler, @@ -396,6 +398,7 @@ impl From for BootstrapCommand { impl Builder<'_> { /// Like [`Builder::cargo`], but only passes flags that are valid for all commands. + #[track_caller] pub fn bare_cargo( &self, compiler: Compiler, @@ -480,6 +483,7 @@ impl Builder<'_> { /// scoped by `mode`'s output directory, it will pass the `--target` flag for the specified /// `target`, and will be executing the Cargo command `cmd`. `cmd` can be `miri-cmd` for /// commands to be run with Miri. + #[track_caller] fn cargo( &self, compiler: Compiler, diff --git a/src/build_helper/src/util.rs b/src/build_helper/src/util.rs index a8355f774e9d1..1bdbb7515e252 100644 --- a/src/build_helper/src/util.rs +++ b/src/build_helper/src/util.rs @@ -3,6 +3,8 @@ use std::io::{BufRead, BufReader}; use std::path::Path; use std::process::Command; +use crate::ci::CiEnv; + /// Invokes `build_helper::util::detail_exit` with `cfg!(test)` /// /// This is a macro instead of a function so that it uses `cfg(test)` in the *calling* crate, not in build helper. @@ -20,6 +22,15 @@ pub fn detail_exit(code: i32, is_test: bool) -> ! { if is_test { panic!("status code: {code}"); } else { + // If we're in CI, print the current bootstrap invocation command, to make it easier to + // figure out what exactly has failed. + if CiEnv::is_ci() { + // Skip the first argument, as it will be some absolute path to the bootstrap binary. + let bootstrap_args = + std::env::args().skip(1).map(|a| a.to_string()).collect::>().join(" "); + eprintln!("Bootstrap failed while executing `{bootstrap_args}`"); + } + // otherwise, exit with provided status code std::process::exit(code); }