Skip to content

Commit 8b0c31d

Browse files
Rollup merge of #79508 - jryans:check-dsymutil-result, r=nagisa
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. I tried to think of ways to test this change, but so far I haven't found a good way, as you'd likely need to inject some nonsensical args into `dsymutil` to induce failure, which feels too artificial to me. Also, #79361 suggests Rust is on the verge of disabling `dsymutil` by default, so perhaps it's okay for this change to be untested. In any case, I'm happy to add a test if someone sees a good approach. Fixes #78770
2 parents 4cbda82 + 4ed9083 commit 8b0c31d

File tree

2 files changed

+24
-10
lines changed

2 files changed

+24
-10
lines changed

compiler/rustc_codegen_ssa/src/back/link.rs

+23-9
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
}

compiler/rustc_session/src/config.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ pub enum SymbolManglingVersion {
214214

215215
impl_stable_hash_via_hash!(SymbolManglingVersion);
216216

217-
#[derive(Clone, Copy, PartialEq, Hash)]
217+
#[derive(Clone, Copy, Debug, PartialEq, Hash)]
218218
pub enum DebugInfo {
219219
None,
220220
Limited,

0 commit comments

Comments
 (0)