Repository navigation
msvc: do not expect a program database next to a -Fd directory - #2933
Merged
Merged
Conversation
A -Fd value with a trailing separator makes cl.exe write a shared
vc<NNN>.pdb inside that directory, but the artifact was recorded as
"<dir>.pdb", which cl.exe never creates. Storing the compilation then failed
to open the missing file, and that turned into a fatal error ("failed to zip
up compiler outputs", exit code -2) even though the compiler had succeeded:
cl /c /Zi /Fdpdb\ foo.cpp -> sccache: error: failed to open ...\pdb.pdb
Compilations like that can no longer complete. Report them as not cacheable
with the existing "shared pdb" reason, matching the -Fd-less case, so the
object file is still produced.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2933 +/- ##
=======================================
Coverage 78.20% 78.21%
=======================================
Files 74 74
Lines 43708 43728 +20
=======================================
+ Hits 34184 34202 +18
- Misses 9524 9526 +2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Collaborator
|
Thanks for your PR |
1 task done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A
-Fdvalue with a trailing separator makes cl.exe write a sharedvc<NNN>.pdbinside that directory, but sccache recorded the artifact as<dir>.pdb, a file cl.exe never creates. Writing the cache entry then failedto open it, and that failure is fatal:
Because
CacheWrite::from_objectstreats a missing artifact withoptional: falseas an error, and that error propagates out ofget_cached_or_compile, any build that passes a-Fddirectory (for examplecl /c /Zi /Fd"$(IntDir)\") could not complete at all.Report such compilations as not cacheable instead, with the
shared pdbreason already used when
-Zi/-ZIis given without-Fd: the PDB cl.exewrites into that directory is shared by every translation unit compiled into
it, so it cannot be tracked as a per-compilation artifact. The object file is
still produced, the build succeeds, and
--show-statsnames the reason.Note that this also stops the previous silent
Cacheable::Nopath fordirectory names that happen to contain a dot (CMake's
CMakeFiles/<target>.dir/), which used to be classified as "the PDB alreadyexists, so it might be shared". The existing heuristic is unchanged for real
-Fd <file>.pdbpaths.Testing
New unit test
test_parse_arguments_pdb_directorycovers:-Fdpdb\and-Fdpdb/with-Zi→CannotCache("shared pdb")-Fdpdb\without debug information → cacheable, nopdbartifact(cl.exe ignores
-Fdin that case)-Fdpdb\foo.pdb→ cacheable,pdbartifact ispdb\foo.pdbEnd to end on Windows with MSVC 19.51:
sccache cl /c /Zi /Fd"pdb\" /Foa.obj a.cpp-2, cache error0,a.objwritten,Non-cacheable reasons: shared pdb 1sccache cl /c /Zi /Fd"pdb2\a.pdb" /Foa2.obj a.cpp(twice)a2.objandpdb2\a.pdbrestoredcargo test --lib: 583 passed, 0 failed (default features; 530 with--no-default-features).cargo fmt --checkis clean.