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
This commit is contained in:
commit
8b0c31d492
@ -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 {
|
||||
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 escape_string(s: &[u8]) -> String {
|
||||
&& 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)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -214,7 +214,7 @@ pub enum SymbolManglingVersion {
|
||||
|
||||
impl_stable_hash_via_hash!(SymbolManglingVersion);
|
||||
|
||||
#[derive(Clone, Copy, PartialEq, Hash)]
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Hash)]
|
||||
pub enum DebugInfo {
|
||||
None,
|
||||
Limited,
|
||||
|
Loading…
Reference in New Issue
Block a user