Skip to content

Commit 4ed9083

Browse files
committed
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 #78770
1 parent 8b18f41 commit 4ed9083

File tree

1 file changed

+23
-9
lines changed
  • compiler/rustc_codegen_ssa/src/back

1 file changed

+23
-9
lines changed

compiler/rustc_codegen_ssa/src/back/link.rs

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -643,15 +643,16 @@ fn link_natively<'a, B: ArchiveBuilder<'a>>(
643643
}
644644
}
645645

646+
fn escape_string(s: &[u8]) -> String {
647+
str::from_utf8(s).map(|s| s.to_owned()).unwrap_or_else(|_| {
648+
let mut x = "Non-UTF-8 output: ".to_string();
649+
x.extend(s.iter().flat_map(|&b| ascii::escape_default(b)).map(char::from));
650+
x
651+
})
652+
}
653+
646654
match prog {
647655
Ok(prog) => {
648-
fn escape_string(s: &[u8]) -> String {
649-
str::from_utf8(s).map(|s| s.to_owned()).unwrap_or_else(|_| {
650-
let mut x = "Non-UTF-8 output: ".to_string();
651-
x.extend(s.iter().flat_map(|&b| ascii::escape_default(b)).map(char::from));
652-
x
653-
})
654-
}
655656
if !prog.status.success() {
656657
let mut output = prog.stderr.clone();
657658
output.extend_from_slice(&prog.stdout);
@@ -760,8 +761,21 @@ fn link_natively<'a, B: ArchiveBuilder<'a>>(
760761
&& sess.opts.debuginfo != DebugInfo::None
761762
&& !preserve_objects_for_their_debuginfo(sess)
762763
{
763-
if let Err(e) = Command::new("dsymutil").arg(out_filename).output() {
764-
sess.fatal(&format!("failed to run dsymutil: {}", e))
764+
let prog = Command::new("dsymutil").arg(out_filename).output();
765+
match prog {
766+
Ok(prog) => {
767+
if !prog.status.success() {
768+
let mut output = prog.stderr.clone();
769+
output.extend_from_slice(&prog.stdout);
770+
sess.struct_warn(&format!(
771+
"processing debug info with `dsymutil` failed: {}",
772+
prog.status
773+
))
774+
.note(&escape_string(&output))
775+
.emit();
776+
}
777+
}
778+
Err(e) => sess.fatal(&format!("unable to run `dsymutil`: {}", e)),
765779
}
766780
}
767781
}

0 commit comments

Comments
 (0)