-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
--remap-path-prefix doesn't map paths to .pdb
files, even in release mode
#87825
Comments
Assigning priority as discussed in the Zulip thread of the Prioritization Working Group. @rustbot label -I-prioritize +P-medium |
Perhaps this should be amended to say compiler output but not linker outputs. PDB files are generated at the linking step, which is probably why #88982 sees non-determinism for --crate-type=bin (linked) and not for --crate-type=rlib (not linked). Passing Doing this with rustc could provide a switch to remove the absolute path to PDB files, which would just map to Determinism is important for both release and debug builds, so I don't believe there is anything release-mode specific here or that a solution should be chosen that doesn't deal with debug mode?
Could you say what is breaking about backtraces with |
Without that flag I get something like: Backtrace
But with it it just prints: Backtrace
This seems to happen because the pdb file is searched relative to the current working directory, and when running |
Can |
Wouldn't that break any workflow that relies on the current working directory always being where |
I think this meant the crate root instead of the cwd? I had no idea that would be a common thing, but you're right. It would change any use of Regardless, I can see why changing It seems the options are:
Have I missed an option? There's no option that I can see with both deterministic output and backtraces working from arbitrary working directories. AIUI, this github issue is about --remap-path-prefix not adding a As a convenience, maybe |
Would it be possible to have |
It'd probably be easier to have |
Any update on this? :) |
I've just opened #121297 which solves the problem by making |
…=wesleywiser link.exe: Don't embed full path to PDB file in binary. This PR makes `rustc` unconditionally pass `/PDBALTPATH:%_PDB%` to MSVC-style linkers, causing the linker to only embed the filename of the PDB in the binary instead of the full path. This will help implement the [trim-paths RFC](rust-lang#111540) for `*-msvc` targets. Passing `/PDBALTPATH:%_PDB%` to the linker is already done by many projects that need reproducible builds and [debugger's should still be able to find the PDB](https://learn.microsoft.com/cpp/build/reference/pdbpath) if it is in the same directory as the binary. r? `@ghost` Fixes rust-lang#87825
…=wesleywiser link.exe: Don't embed full path to PDB file in binary. This PR makes `rustc` unconditionally pass `/PDBALTPATH:%_PDB%` to MSVC-style linkers, causing the linker to only embed the filename of the PDB in the binary instead of the full path. This will help implement the [trim-paths RFC](rust-lang#111540) for `*-msvc` targets. Passing `/PDBALTPATH:%_PDB%` to the linker is already done by many projects that need reproducible builds and [debugger's should still be able to find the PDB](https://learn.microsoft.com/cpp/build/reference/pdbpath) if it is in the same directory as the binary. r? `@ghost` Fixes rust-lang#87825
link.exe: Don't embed full path to PDB file in binary. This PR makes `rustc` unconditionally pass `/PDBALTPATH:%_PDB%` to MSVC-style linkers, causing the linker to only embed the filename of the PDB in the binary instead of the full path. This will help implement the [trim-paths RFC](rust-lang/rust#111540) for `*-msvc` targets. Passing `/PDBALTPATH:%_PDB%` to the linker is already done by many projects that need reproducible builds and [debugger's should still be able to find the PDB](https://learn.microsoft.com/cpp/build/reference/pdbpath) if it is in the same directory as the binary. r? `@ghost` Fixes rust-lang/rust#87825
Spawned off of #87805 (comment)
When passing
--remap-path-prefix C:\\path\\to\\project=nothing_to_see_here
to rustc I would expect all paths that start withC:\path\to\project
to be replaced withnothing_to_see_here
, instead aC:\path\to\project\target\release\deps\crate_name.pdb
is still present.Note that this happens even in release mode, because rustc always tells the msvc linker to generate
.pdb
files.This can be "fixed" by passing either
-Clink-arg=/PDBALTPATH:%_PDB%
,-Clink-arg=/DEBUG:NONE
or-Zstrip=debuginfo
to rustc, but doing so will break backtraces withRUST_BACKTRACE='full'
(RUST_BACKTRACE=1
already prints almost nothing in release mode). As a sidenote, do we really need backtraces in release mode, and by consequence.pdb
files? They will break anyway if only the.exe
is distributed or thetarget
directory is deleted.Moreover this shouldn't be needed in the first place since
--remap-path-prefix
promises to "remap source names in all output (compiler messages and output files)" (from the output ofrustc --help -v
), "including [...] debug information" (from the rustc book here). Also note that neitherrustc --help -v
nor the rustc book mention the need to pass one of those arguments to rustc to remap/remove the path to the.pdb
file, which makes it harder for non-experts to know how to remove them.rustc --version --verbose
:The text was updated successfully, but these errors were encountered: