Open csmulhern opened 3 weeks ago
This is just a guess, but I suspect the issue is to do with the fact that remapped paths become relative paths, whereas OSO paths seem to always be absolute.
For example, if I use the oso_prefix
linker argument to do path remapping specifically for the OSO stabs, the path becomes the relative path rooted at /
.
rustc main.rs --codegen=debuginfo=2 --codegen=split-debuginfo=unpacked --codegen=link-args=-Wl,-oso_prefix,/Users/cameron/Desktop/broken
> nm -pa main | rg OSO
0000000000000000 - 00 0001 OSO /main.main.4b21619d1e36c66a-cgu.0.rcgu.o
0000000000000000 - 00 0001 OSO /Users/cameron/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libstd-0b4a354a5d882f18.rlib(std-0b4a354a5d882f18.std.d8d90c69e022292b-cgu.0.rcgu.o)
0000000000000000 - 00 0001 OSO /Users/cameron/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libpanic_unwind-00e89274fccf37d9.rlib(panic_unwind-00e89274fccf37d9.panic_unwind.ea3026af965941fa-cgu.0.rcgu.o)
0000000000000000 - 00 0001 OSO /Users/cameron/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libmemchr-726032628236814d.rlib(memchr-726032628236814d.memchr.5ae0b6d692968ecf-cgu.0.rcgu.o)
0000000000000000 - 00 0001 OSO /Users/cameron/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/liballoc-a7504b44dda8a2a3.rlib(alloc-a7504b44dda8a2a3.alloc.764fc8c78a1bb3e1-cgu.0.rcgu.o)
0000000000000000 - 00 0001 OSO /Users/cameron/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libcore-a17e2a568e77fc15.rlib(core-a17e2a568e77fc15.core.fafc87a594706398-cgu.0.rcgu.o)
After a little more investigation, I'm wondering if the fact that DW_AT_comp_dir
is missing when --remap-path-prefix is used is responsible for this. It's possible ld-prime
is only emitting OSO stabs when both DW_AT_name
and DW_AT_comp_dir
are specified in the debug info. I don't have access to an old version of macOS using ld64 to see if the same issue is present there as well.
I will file feedback with Apple and hopefully ld-prime
can be updated to support this. A mitigation on the rustc side would be to not remap paths in DWARF debug info on macOS, and rely on the oso_prefix
linker option for path remapping instead.
This can be easily reproduced with a simple program.
Without --remap-path-prefix, building with unpacked debug info:
Results in a binary that has an OSO entry pointing to the object file containing the debug info:
With --remap-path-prefix:
Results in a binary that is missing OSO entries for the remapped object files:
Note how the first OSO entry from the first command is missing from the second:
I believe the same underlying issue prevents
--split-debuginfo=packed
from generating a dSYM containing debug info for the object files containing the remapped path prefix, as I believe dsymutil is just using the OSO entries to create a self contained set of DWARF debug info.Packed debug info without remapping:
Results in a complete dSYM:
Whereas the remapped version:
Does not:
All these issues are reproducible on a recent nightly (
rustc version 1.84.0-nightly (a93c1718c 2024-10-24)
).