rust-lang / cargo

The Rust package manager
https://doc.rust-lang.org/cargo
Apache License 2.0
12.55k stars 2.38k forks source link

`split-debuginfo="packed"` create incorrect `*.dSYM` bundle on macOS #13365

Open inflation opened 7 months ago

inflation commented 7 months ago

Problem

Wrong filename for the DWARF file inside the .dSYM bundle.

Steps

  1. cargo new testing
  2. Add split-debuginfo = "packed" in cargo.toml
  3. cargo build
  4. objdump -d target/debug/testing

    target/release/testing: file format mach-o arm64
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/objdump: error: 'target/release/testing.dSYM/Contents/Resources/DWARF/testing': No such file or directory
  5. ls target/release/testing.dSYM/Contents/Resources/DWARF
    testing-297be036e0344749

Possible Solution(s)

Strip id when creating the debug bundle

Notes

No response

Version

cargo 1.75.0 (1d8b05cdd 2023-11-20)
release: 1.75.0
commit-hash: 1d8b05cdd1287c64467306cf3ca2c8ac60c11eb0
commit-date: 2023-11-20
host: aarch64-apple-darwin
libgit2: 1.7.1 (sys:0.18.1 vendored)
libcurl: 8.4.0 (sys:0.4.68+curl-8.4.0 system ssl:(SecureTransport) LibreSSL/3.3.6)
ssl: OpenSSL 1.1.1u  30 May 2023
os: Mac OS 14.3.0 [64-bit]
weihanglo commented 7 months ago

This seems to be an issue after artifact uplifting in Cargo

If I understand correctly, objdump -d binary should just work if no binary.dSYM co-exists. The dSYM bundle under target/release/testing.dSYM is a symlink to the actual dSYM at target/release/deps/testing-297be036e0344749.dSYM. And should be sufficient to use it with lldb to debug.

I am not sure if the name mismatch affects things other than objdump -d.

inflation commented 7 months ago

Rename the file or remove the bundle both works. I assume that objdump takes dSYM file for priority.