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,15 +643,16 @@ fn is_illegal_instruction(_status: &ExitStatus) -> bool {
} }
} }
fn escape_string(s: &[u8]) -> String {
str::from_utf8(s).map(|s| s.to_owned()).unwrap_or_else(|_| {
let mut x = "Non-UTF-8 output: ".to_string();
x.extend(s.iter().flat_map(|&b| ascii::escape_default(b)).map(char::from));
x
})
}
match prog { match prog {
Ok(prog) => { Ok(prog) => {
fn escape_string(s: &[u8]) -> String {
str::from_utf8(s).map(|s| s.to_owned()).unwrap_or_else(|_| {
let mut x = "Non-UTF-8 output: ".to_string();
x.extend(s.iter().flat_map(|&b| ascii::escape_default(b)).map(char::from));
x
})
}
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)),
} }
} }
} }