diff options
author | bors <bors@rust-lang.org> | 2023-04-04 08:21:00 +0000 |
---|---|---|
committer | bors <bors@rust-lang.org> | 2023-04-04 08:21:00 +0000 |
commit | b9f037292b144a416a454ca457c6d6f94662a59e (patch) | |
tree | b71f0c9d97d74fa692423fb69463991d5bfc8909 | |
parent | 26744a7ad42974a1d62ba8ca9820a63c8949f40a (diff) | |
parent | 52808cef25e8404488e5e8dec9330c90b59df6d0 (diff) | |
download | rust-libc-0.2.141.tar.gz |
Auto merge of #3180 - jsha:print-rustc-error-output, r=JohnTitor0.2.141
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 https://github.com/rust-lang/crater/issues/663.
-rw-r--r-- | build.rs | 8 |
1 files changed, 8 insertions, 0 deletions
@@ -1,6 +1,7 @@ use std::env; use std::process::Command; use std::str; +use std::string::String; // List of cfgs this build script is allowed to set. The list is needed to support check-cfg, as we // 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) { .output() .ok() .expect("Failed to get rustc version"); + if !output.status.success() { + panic!( + "failed to run rustc: {}", + String::from_utf8_lossy(output.stderr.as_slice()) + ); + } + let version = otry!(str::from_utf8(&output.stdout).ok()); let mut pieces = version.split('.'); |