-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Only with all
or split-debuginfo
can -Zremap-path-scope
remap SO
symbols on macOS
#117652
Comments
with all
or split-debuginfo
can -Zremap-path-scope
remap SO
symbolsall
or split-debuginfo
can -Zremap-path-scope
remap SO
symbols
all
or split-debuginfo
can -Zremap-path-scope
remap SO
symbolsall
or split-debuginfo
can -Zremap-path-scope
remap SO
symbols on macOS
One of the goal of
On macOS, |
The issue here is that we currently decide if we should remap paths for the entire compilation unit. [1] This is because I don't think rustc can generate in the same invocation different path for the executable and debuginfo files as we can only give one at a time to LLVM. EDIT: While what I said is true, it has nothing to do with the current issue about |
The |
fix(trim-paths): trim `SO` and `DW_AT_comp_dir` symbols for root DI node This is one way to fix <rust-lang#117652>. ## The issue When `--remap-path-scope=object` is specified, user expect that there is no local path embedded in final executables. Under `object` scope, the current implementation only remap debug symbols if debug info is splitted into its own file. In other words, when `split-debuginfo=packed|unpacked` is set, rustc assumes there is no embedded path in the final executable needing to be remapped. However, this doesn't work. * On Linux, the root `DW_AT_comp_dir` of a compile unit seems to go into the binary executables. * On macOS, `SO` symbols are embedded in binary executables and libraries regardless a split-debuginfo file is built. Each `SO` symbol contains a path to the root source file of a debug info compile unit. ## The approach Path of working directory in the root DI node seems to be embedded in executables. Hence, we trim them when the scope of `unsplit-debuginfo` is present, as if it is kinda a "unsplit" debuginfo. ## Unresolved issue * Not sure where to add more test to consolidate it. * Haven't investigate if we should apply the same logic to cranelift [here](https://github.com/rust-lang/rust/blob/64d7e0d0b61c460fbc882ae37c0f236756dd9c39/compiler/rustc_codegen_cranelift/src/debuginfo/mod.rs#L68-L80). * Not sure if there is any other consequence doing this, but AFAIK debugging still works on macOS and Linux with `profile.dev.trim-paths="object"` fairly (with some extra tweaks in cargo).
Found on Linux $ rustc -g main.rs \
-C split-debuginfo=packed \
-Zremap-path-scope=object \
--remap-path-prefix="/absolute/path"
$ readelf -wi main | rg 'dwo'
<10> DW_AT_comp_dir : (indirect string, offset: 0x0): /absolute/path/to/working/dir A fix is also present in #118518 together as well. |
fix(trim-paths): trim `SO` and `DW_AT_comp_dir` symbols for root DI node This is one way to fix <rust-lang#117652>. ## The issue When `--remap-path-scope=object` is specified, user expect that there is no local path embedded in final executables. Under `object` scope, the current implementation only remap debug symbols if debug info is splitted into its own file. In other words, when `split-debuginfo=packed|unpacked` is set, rustc assumes there is no embedded path in the final executable needing to be remapped. However, this doesn't work. * On Linux, the root `DW_AT_comp_dir` of a compile unit seems to go into the binary executables. * On macOS, `SO` symbols are embedded in binary executables and libraries regardless a split-debuginfo file is built. Each `SO` symbol contains a path to the root source file of a debug info compile unit. ## The approach Path of working directory in the root DI node seems to be embedded in executables. Hence, we trim them when the scope of `unsplit-debuginfo` is present, as if it is kinda a "unsplit" debuginfo. ## Unresolved issue * Not sure where to add more test to consolidate it. * Haven't investigate if we should apply the same logic to cranelift [here](https://github.com/rust-lang/rust/blob/64d7e0d0b61c460fbc882ae37c0f236756dd9c39/compiler/rustc_codegen_cranelift/src/debuginfo/mod.rs#L68-L80). * Not sure if there is any other consequence doing this, but AFAIK debugging still works on macOS and Linux with `profile.dev.trim-paths="object"` fairly (with some extra tweaks in cargo). * This might be related? from <https://github.com/llvm/llvm-project/blob/847d8457d16a7334ba39bdd35c70faa1b295304d/clang/lib/CodeGen/CGDebugInfo.cpp#L623-L631> ``` The DIFile used by the CU is distinct from the main source file. Its directory part specifies what becomes the DW_AT_comp_dir (the compilation directory), even if the source file was specified with an absolute path. ```
Problem
It's very clear in RFC that
split-debuginfo
only happen in split debuginfo files.unsplit-debuginfo
only happen in compiled executables or libraries.split-debuginfo-path
only remap paths pointing to split debuginfo files.However, on macOS even you have split debuginfo,
SO
symbols is still there in the executable.Although it seems like expected as scope
object
is a union ofunsplit-debuginfo | split-debuginfo-path | macro
. However, since absolute paths are still embedded in executables, the doc lies on "This ensures all paths in compiled executables or libraries are remapped.rustc --version --verbose
The text was updated successfully, but these errors were encountered: