diff options
| author | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2020-12-01 23:46:09 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-12-01 23:46:09 +0100 |
| commit | 8b0c31d492e1b9e98c706ed631dffcc2c72913c5 (patch) | |
| tree | 779ef561fdc882a918c5f4f9a2aec159b589866d /compiler/rustc_codegen_ssa/src/back | |
| parent | 4cbda829c00af2c3ac362c979fa97ea90be0be7d (diff) | |
| parent | 4ed90835615f96f1260c633027bd673cd011ab36 (diff) | |
| download | rust-8b0c31d492e1b9e98c706ed631dffcc2c72913c5.tar.gz rust-8b0c31d492e1b9e98c706ed631dffcc2c72913c5.zip | |
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, https://github.com/rust-lang/rust/issues/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 https://github.com/rust-lang/rust/issues/78770
Diffstat (limited to 'compiler/rustc_codegen_ssa/src/back')
| -rw-r--r-- | compiler/rustc_codegen_ssa/src/back/link.rs | 32 |
1 files changed, 23 insertions, 9 deletions
diff --git a/compiler/rustc_codegen_ssa/src/back/link.rs b/compiler/rustc_codegen_ssa/src/back/link.rs index 22e2aa3b5c8..70cf876a08a 100644 --- a/compiler/rustc_codegen_ssa/src/back/link.rs +++ b/compiler/rustc_codegen_ssa/src/back/link.rs @@ -643,15 +643,16 @@ fn link_natively<'a, B: ArchiveBuilder<'a>>( } } + 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 { 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() { let mut output = prog.stderr.clone(); output.extend_from_slice(&prog.stdout); @@ -760,8 +761,21 @@ fn link_natively<'a, B: ArchiveBuilder<'a>>( && sess.opts.debuginfo != DebugInfo::None && !preserve_objects_for_their_debuginfo(sess) { - if let Err(e) = Command::new("dsymutil").arg(out_filename).output() { - sess.fatal(&format!("failed to run dsymutil: {}", e)) + let prog = Command::new("dsymutil").arg(out_filename).output(); + 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)), } } } |
