Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/bootstrap/src/core/builder/cargo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -396,6 +398,7 @@ impl From<Cargo> 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,
Expand Down Expand Up @@ -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,
Expand Down
11 changes: 11 additions & 0 deletions src/build_helper/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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::<Vec<_>>().join(" ");
eprintln!("Bootstrap failed while executing `{bootstrap_args}`");
}

// otherwise, exit with provided status code
std::process::exit(code);
}
Expand Down
Loading