Open MaulingMonkey opened 7 months ago
Every compilation should write the natvis files to a unique temporary directory to pass to the linker: https://github.com/rust-lang/rust/blob/9aa232ecc7bb006a1fad404f437b049482021a3a/compiler/rustc_codegen_ssa/src/back/link.rs#L2426 And only the natvis files in this directory should be passed to the linker with /NATVIS:
. It is possible that we are forgetting to mention the natvis files in the dep-info file, which could explain stale results due to the crate not getting rebuilt when the natvis files change, but that wouldn't explain why the debugger complains about duplicate files.
Every compilation should write the natvis files to a unique temporary directory
That might be the problem, actually. If link.exe /NATIVS:...
updates the pdb in-place, it might be attempting to replace the embedded natvis files by full path, not just by filename... and if each build gets a unique temporary directory, that gives each natvis a unique path. This also explains:
natvis-pdbs
- it passes absolute canonicalized paths to the original stable *.natvis
paths.-/NATVIS:%USERPROFILE%\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\etc\*.natvis
+/NATVIS:%USERPROFILE%\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\etc\*.natvis
That I had nightly
's natvis files living alongside stable
's in my .pdb
s.
Tired of wrangling Visual Studio, I created a ≈15MB .natvis file (through recursive copy+paste abuse to create a very large XML comment), and alternated between touching examples\basic.rs
and cargo b --example basic
. The only thing that noticably grew in my target
folder is debug\examples\basic.pdb
(which grew by about ≈15MB each build - no compression apparently.) Deleting it basic.pdb
reset the size of the to ≈16MB when regenerated in the next build.
If using the original natvis locations is undesirable (user might modify mid-build?), using a stable subdirectory of target
instead of a unique temp dir would help a lot... although you'll still end up with stale natvis data:
target
)basic-0.natvis
will get updated, basic-N+1.natvis
won't be)target
or one of it's parent folders is movedIf link.exe /NATIVS:... updates the pdb in-place
If that is indeed the case, that is an issue. That would mean that reproducible builds would require rustc to remove the pdb file before linking.
If using the original natvis locations is undesirable (user might modify mid-build?),
Not just modify. It might not even exist on the build system if the rlib was moved to a different machine.
using a stable subdirectory of target instead of a unique temp dir would help a lot...
Cargo wouldn't know how to remove that directory for cargo clean -p my_package
. I think removing the pdb is the best option, also for reproducibility.
Changes to my natvis files (e.g. replacing the
DisplayString
1 → 2 below) aren't always being reflected in my debugger.After enabling Visual Studio 2017's natvis diagnostic messages and stepping out of
__break
, I've started to accumulate many warnings, with one warning per build after the 1st (starting with no warnings for the first build after acargo clean
):I believe that for every build, the new contents of
my.natvis
are accumulated... and then conflict with the stale contents of previousmy.natvis
contents. These stale contents then, presumably, frequently win / take priority, resulting in not seeing the updated visualizer. Adding insult to injury, switching from stable to nightly, I ended up getting warnings for what I believe to be every type in{intrinsic, libcore, liballoc, libstd}.natvis
until Icargo clean
ed - you might have stale stdlib visualizers after a toolchain upgrade.Meta
rustc --version --verbose
: