Skip to content

Commit

Permalink
Auto merge of #3180 - jsha:print-rustc-error-output, r=JohnTitor
Browse files Browse the repository at this point in the history
build.rs: print rustc stderr if exit status != 0

I was trying to run benchmarks locally with rustc-perf and found that many of them failed to build with a message from libc's build.rs "Failed to get rustc version." I made this change locally to help debug, and I think it would be generally useful. In my case it quickly revealed that rustc was failing to find libLLVM and so `rustc --version` was emitting nothing on stdout.

I think this may have been part of what was intended with #3000 and might help debug rust-lang/crater#663.
  • Loading branch information
bors committed Apr 3, 2023
2 parents c64bfc5 + 88e27b8 commit 557f644
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,11 @@ fn rustc_minor_nightly() -> (u32, bool) {
.output()
.ok()
.expect("Failed to get rustc version");
if !output.status.success() {
let stderr = std::string::String::from_utf8_lossy(output.stderr.as_slice());
eprintln!("failed to run rustc: {stderr}");
}

let version = otry!(str::from_utf8(&output.stdout).ok());
let mut pieces = version.split('.');

Expand Down

0 comments on commit 557f644

Please sign in to comment.