Skip to content

Commit f3d7607

Browse files
committed
Auto merge of #3180 - jsha:print-rustc-error-output, r=JohnTitor
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.
2 parents c64bfc5 + 52808ce commit f3d7607

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

build.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use std::env;
22
use std::process::Command;
33
use std::str;
4+
use std::string::String;
45

56
// List of cfgs this build script is allowed to set. The list is needed to support check-cfg, as we
67
// need to know all the possible cfgs that this script will set. If you need to set another cfg
@@ -181,6 +182,13 @@ fn rustc_minor_nightly() -> (u32, bool) {
181182
.output()
182183
.ok()
183184
.expect("Failed to get rustc version");
185+
if !output.status.success() {
186+
panic!(
187+
"failed to run rustc: {}",
188+
String::from_utf8_lossy(output.stderr.as_slice())
189+
);
190+
}
191+
184192
let version = otry!(str::from_utf8(&output.stdout).ok());
185193
let mut pieces = version.split('.');
186194

0 commit comments

Comments
 (0)