Warn if dsymutil returns an error code

This checks the error code returned by `dsymutil` and warns if it failed. It
also provides the stdout and stderr logs from `dsymutil`, similar to the native
linker step.

Fixes https://github.com/rust-lang/rust/issues/78770
This commit is contained in:
J. Ryan Stinnett 2020-11-28 15:09:18 +00:00
parent 8b18f41b98
commit 4ed9083561

View File

@ -643,8 +643,6 @@ fn is_illegal_instruction(_status: &ExitStatus) -> bool {
} }
} }
match prog {
Ok(prog) => {
fn escape_string(s: &[u8]) -> String { fn escape_string(s: &[u8]) -> String {
str::from_utf8(s).map(|s| s.to_owned()).unwrap_or_else(|_| { str::from_utf8(s).map(|s| s.to_owned()).unwrap_or_else(|_| {
let mut x = "Non-UTF-8 output: ".to_string(); let mut x = "Non-UTF-8 output: ".to_string();
@ -652,6 +650,9 @@ fn escape_string(s: &[u8]) -> String {
x x
}) })
} }
match prog {
Ok(prog) => {
if !prog.status.success() { if !prog.status.success() {
let mut output = prog.stderr.clone(); let mut output = prog.stderr.clone();
output.extend_from_slice(&prog.stdout); output.extend_from_slice(&prog.stdout);
@ -760,8 +761,21 @@ fn escape_string(s: &[u8]) -> String {
&& sess.opts.debuginfo != DebugInfo::None && sess.opts.debuginfo != DebugInfo::None
&& !preserve_objects_for_their_debuginfo(sess) && !preserve_objects_for_their_debuginfo(sess)
{ {
if let Err(e) = Command::new("dsymutil").arg(out_filename).output() { let prog = Command::new("dsymutil").arg(out_filename).output();
sess.fatal(&format!("failed to run dsymutil: {}", e)) match prog {
Ok(prog) => {
if !prog.status.success() {
let mut output = prog.stderr.clone();
output.extend_from_slice(&prog.stdout);
sess.struct_warn(&format!(
"processing debug info with `dsymutil` failed: {}",
prog.status
))
.note(&escape_string(&output))
.emit();
}
}
Err(e) => sess.fatal(&format!("unable to run `dsymutil`: {}", e)),
} }
} }
} }