Skip to content

-Zremap-path-scope=macro still remaps inlined ELF symbols #139217

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

Closed
xobs opened this issue Apr 1, 2025 · 4 comments · Fixed by #139550
Closed

-Zremap-path-scope=macro still remaps inlined ELF symbols #139217

xobs opened this issue Apr 1, 2025 · 4 comments · Fixed by #139550
Assignees
Labels
A-debuginfo Area: Debugging information in compiled programs (DWARF, PDB, etc.) A-path-remapping Area: path remapping, --remap-path-prefix, --remap-cwd-prefix, --remap-diagnostics-scope etc. C-bug Category: This is a bug. F-trim-paths Feature: trim-paths requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@xobs
Copy link
Contributor

xobs commented Apr 1, 2025

The unstable feature -Zremap-path-scope is supposed to constrain --remap-path-prefix to only a certain subset of remappings. However, it seems as though DWARF data still has paths remapped for functions that are inlined.

I tried this code:

cargo init a
cargo init --lib b
echo 'b = {path = "../b"}' >> a/Cargo.toml
echo '#[inline] pub fn get_some_value() -> i32 { 42 }' > b/src/lib.rs
echo 'fn main() { println!("{}", b::get_some_value()); }' > a/src/main.rs
cd a
RUSTFLAGS="--remap-path-prefix=/=foo -Zremap-path-scope=macro" cargo +nightly build
llvm-dwarfdump-15 --show-sources target/debug/a | grep -v ^/rust

I expected to see this happen: No DWARF symbols should contain foo, because only file!() macros should be remapped.

Instead, this happened: The inlined symbol got remapped:

user@ubuntu:/opt/Xous/simple-test/a$ llvm-dwarfdump-15 --show-sources target/debug/a | grep -v ^/rust
/home/user/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/fmt/mod.rs
/home/user/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/fmt/rt.rs
/home/user/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/hint.rs
/home/user/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/function.rs
/home/user/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ptr/mod.rs
/home/user/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/process.rs
/home/user/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/rt.rs
/home/user/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/sys/backtrace.rs
/home/user/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/sys/process/unix/common.rs
/opt/Xous/simple-test/a/foo/opt/Xous/simple-test/b/src/lib.rs
/opt/Xous/simple-test/a/src/main.rs
user@ubuntu:/opt/Xous/simple-test/a$

Meta

rustc --version --verbose:

rustc 1.88.0-nightly (fedf10752 2025-03-30)
binary: rustc
commit-hash: fedf10752b973d83f3f7c0f819b2659c21a634de
commit-date: 2025-03-30
host: x86_64-unknown-linux-gnu
release: 1.88.0-nightly
LLVM version: 20.1.1

@xobs xobs added the C-bug Category: This is a bug. label Apr 1, 2025
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Apr 1, 2025
@xobs
Copy link
Contributor Author

xobs commented Apr 1, 2025

Note: The --show-sources argument appeared in dwarfdump version 15, which is bundled with most Xcode installs on Mac. For Ubuntu, I had to install llvm-15 and refer to it explicitly as llvm-dwarfdump-15.

Other platforms may vary, but the important bit is that filenames in the debug sections are getting remapped when such remapping should only be constrained to the file!() macro.

@moxian
Copy link
Contributor

moxian commented Apr 2, 2025

@rustbot label: +F-trim-paths +T-compiler +requires-nightly +A-debuginfo

@rustbot rustbot added A-debuginfo Area: Debugging information in compiled programs (DWARF, PDB, etc.) F-trim-paths Feature: trim-paths requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Apr 2, 2025
@jieyouxu jieyouxu added A-path-remapping Area: path remapping, --remap-path-prefix, --remap-cwd-prefix, --remap-diagnostics-scope etc. and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Apr 2, 2025
@Urgau
Copy link
Member

Urgau commented Apr 6, 2025

The issue is also present with -Zremap-path-scope=diagnostics, seems like something is bypassing the scopes and unconditionally using the remapped file when available instead of checking if the scope permits it.

@rustbot claim

@rustbot

This comment has been minimized.

Zalathar added a commit to Zalathar/rust that referenced this issue May 6, 2025
…ethercote

Fix `-Zremap-path-scope` rmeta handling

This PR fixes the conditional remapping (`-Zremap-path-scope`) of rmeta file paths ~~by using the `debuginfo` scope~~ by conditionally embedding the local path in addition to the remapped path.

Fixes rust-lang#139217
@bors bors closed this as completed in 01cbc86 May 6, 2025
rust-timer added a commit to rust-lang-ci/rust that referenced this issue May 6, 2025
Rollup merge of rust-lang#139550 - Urgau:rmeta-remap-path-scope, r=nnethercote

Fix `-Zremap-path-scope` rmeta handling

This PR fixes the conditional remapping (`-Zremap-path-scope`) of rmeta file paths ~~by using the `debuginfo` scope~~ by conditionally embedding the local path in addition to the remapped path.

Fixes rust-lang#139217
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-debuginfo Area: Debugging information in compiled programs (DWARF, PDB, etc.) A-path-remapping Area: path remapping, --remap-path-prefix, --remap-cwd-prefix, --remap-diagnostics-scope etc. C-bug Category: This is a bug. F-trim-paths Feature: trim-paths requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants