-
Notifications
You must be signed in to change notification settings - Fork 13.8k
link.exe: Don't embed full path to PDB file in binary. #121297
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
Conversation
#122306 updated backtrace-rs to a version that includes rust-lang/backtrace-rs#584, so this is unblocked now. @rustbot ping windows r? compiler |
Hey Windows Group! This bug has been identified as a good "Windows candidate". cc @albertlarsan68 @arlosi @ChrisDenton @danielframpton @gdr-at-ms @kennykerr @luqmana @lzybkr @nico-abram @retep998 @sivadeilra @wesleywiser |
@bors rollup=never since this touching an |
Looks good! |
r? compiler |
Thanks @michaelwoerister for fixing this and landing that fix to backtrace-rs to unblock it! @bors r+ |
Merged and backtrace has been updated, so this can land, yep. |
…=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
💔 Test failed - checks-actions |
r? @wesleywiser Let's see if this is the same i686 backtracing issue already encountered in rust-lang/backtrace-rs#584, where backtracing was pretty flaky without frame pointers enabled. |
@bors r=wesleywiser |
…=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
💔 Test failed - checks-actions |
d3af77c
to
0a094ba
Compare
I modified the test code in 0a094ba, so that unwinding will more reliably produce a stack trace that actually contains frames from the test. Unwinding not always working is a pre-existing issue on |
@bors r+ |
☀️ Test successful - checks-actions |
Finished benchmarking commit (c5b5713): comparison URL. Overall result: no relevant changes - no action needed@rustbot label: -perf-regression Instruction countThis benchmark run did not return any relevant results for this metric. Max RSS (memory usage)ResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesThis benchmark run did not return any relevant results for this metric. Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 671.321s -> 670.605s (-0.11%) |
…inaries Rust Bins: Bake the full PDB path into the Rust binaries Starting with rustc 1.78 and later, the compiler (rustc) will automatically pass the flag /PDBALTPATH:%_PDB% to the linker (rust-lld). Note that %_PDB% is not read from the environment; instead, The linker will replace %_PDB% with the base name of the module being linked. This is not the desired behavior for us as it will break WinDBG in multiple ways, as we need the full path to the PDB file. Fortunately, if the flag exists but is empty, LLD will populate it with the full path of the PDB file! Ref: rust-lang/rust#121297 https://github.com/rust-lang/rust/blob/75530e9f72a1990ed2305e16fd51d02f47048f12/compiler/rustc_codegen_ssa/src/back/linker.rs#L1049-L1056 https://github.com/llvm/llvm-project/blob/9ed772cecc23f5f5b060720399b010275bbb7457/lld/COFF/Driver.cpp#L2433-L2446 Signed-off-by: Vineel Kovvuri[MSFT] <[email protected]> ---- #### AI description (iteration 1) #### PR Classification New feature #### PR Summary This pull request ensures that the full PDB path is baked into Rust binaries to avoid issues with WinDBG. - Updated `/.cargo/config.toml` to include the `-C link-arg=/PDBALTPATH:` flag for various targets, ensuring the full path to the PDB file is used. <!-- GitOpsUserAgent=GitOps.Apps.Server.pullrequestcopilot -->
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 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 if it is in the same directory as the binary.r? @ghost
Fixes #87825