[PATCH] D136762: [LLD][COFF] Survive empty and invalid PCH signature
Alexandre Ganea via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 28 12:51:03 PDT 2022
aganea updated this revision to Diff 471621.
aganea retitled this revision from "[LLD][COFF] Survive empty PCH signature" to "[LLD][COFF] Survive empty and invalid PCH signature".
aganea edited the summary of this revision.
aganea added a comment.
Herald added subscribers: MaskRay, hiraditya.
Herald added a reviewer: jhenderson.
I finally found some time to look at this. The issue is more complicated than I thought, and the solution is not the same for GHASH than non-GHASH.
Another issue was that `.PCH.OBJ`s are non-deterministic by default. Example:
>cat precomp.cpp
#include "precomp.h"
>cl /Yc /Z7 /c precomp.cpp /nologo
precomp.cpp
>llvm-pdbutil dump --all precomp.obj > dump.txt
>cl /Yc /Z7 /c precomp.cpp /nologo
precomp.cpp
>llvm-pdbutil dump --all precomp.obj > dump2.txt
>diff dump.txt dump2.txt
17991c17991
< 0x2382 | LF_ENDPRECOMP [size = 8] signature = 0x522700AA
---
> 0x2382 | LF_ENDPRECOMP [size = 8] signature = 0x2E1E4F09
18020c18020
< 0 | S_OBJNAME [size = 40] sig=1378287786, `C:\git\llvm-project\precomp.obj`
---
> 0 | S_OBJNAME [size = 40] sig=773738249, `C:\git\llvm-project\precomp.obj`
There was a situation where our `.PCH.OBJ`s were always recompiled on a clean rebuild, but not the `.OBJ`s (they were cached). MSVC link.exe was able to link without warnings or errors. When I first implemented the PCH support, I initially thought the PCH signature was a hard requirement, but it seems it's just a hint for the runtime. I relaxed that requirement in LLD, but now we'd still fail if the `LF_ENDPRECOMP` index doesn't line up with the data in `LF_PRECOMP`.
Also worth noting that using MSVC's `cl /Yc /experimental:deterministic ..` makes the PCH signature deterministic.
Would you mind taking a second look please?
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D136762/new/
https://reviews.llvm.org/D136762
Files:
lld/COFF/DebugTypes.cpp
lld/COFF/DebugTypes.h
lld/COFF/InputFiles.cpp
lld/test/COFF/precomp-link.test
llvm/include/llvm/DebugInfo/CodeView/TypeStreamMerger.h
llvm/lib/DebugInfo/CodeView/TypeStreamMerger.cpp
llvm/tools/llvm-readobj/COFFDumper.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D136762.471621.patch
Type: text/x-patch
Size: 23244 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221028/494734e0/attachment.bin>
More information about the llvm-commits
mailing list