-
Notifications
You must be signed in to change notification settings - Fork 11.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[PDB] Fix bug when using multiple PCH header objects with the same name.
A common pattern in Windows is to have all your precompiled headers use an object named stdafx.obj. If you've got a project with many different static libs, you might use a separate PCH for each one of these. During the final link step, a file from A might reference the PCH object from A, but it will have the same name (stdafx.obj) as any other PCH from another project. The only difference will be the path. For example, A might be A/stdafx.obj while B is B/stdafx.obj. The existing algorithm checks only the filename that was passed on the command line (or stored in archive), but this is insufficient in the case where relative paths are used, because depending on the command line object file / library order, it might find the wrong PCH object first resulting in a signature mismatch. The fix here is to simply check whether the absolute path of the PCH object (which is stored in the input obj file for the file that references the PCH) *ends with* the full relative path of whatever is specified on the command line (or is in the archive). Differential Revision: https://reviews.llvm.org/D66431 llvm-svn: 374442
- Loading branch information
Zachary Turner
committed
Oct 10, 2019
1 parent
3620e8f
commit 02c5386
Showing
9 changed files
with
50 additions
and
22 deletions.
There are no files selected for viewing
This file contains 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
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
RUN: lld-link %S/Inputs/precompb/useprecomp.obj %S/Inputs/precompa/precomp.obj %S/Inputs/precompb/precomp.obj \ | ||
RUN: %S/Inputs/precompa/useprecomp.obj /nodefaultlib /entry:main /debug /pdb:%t.pdb /out:%t.exe \ | ||
RUN: /summary | FileCheck %s -check-prefix SUMMARY | ||
|
||
RUN: llvm-pdbutil dump -types %t.pdb | FileCheck %s | ||
|
||
|
||
CHECK: Types (TPI Stream) | ||
CHECK-NOT: LF_PRECOMP | ||
CHECK-NOT: LF_ENDPRECOMP | ||
|
||
|
||
SUMMARY: Summary | ||
SUMMARY-NEXT: -------------------------------------------------------------------------------- | ||
SUMMARY-NEXT: 4 Input OBJ files (expanded from all cmd-line inputs) | ||
SUMMARY-NEXT: 0 PDB type server dependencies | ||
SUMMARY-NEXT: 2 Precomp OBJ dependencies | ||
|
||
// precompa/precomp.cpp | ||
#include "precomp.h" | ||
|
||
// precompa/useprecomp.cpp | ||
#include "precomp.h" | ||
int main(int argc, char **argv) { return 0; } | ||
|
||
// precompa/precomp.h | ||
int precompa_symbol = 42; | ||
|
||
// precompb/precomp.cpp | ||
#include "precomp.h" | ||
|
||
// precompb/useprecomp.cpp | ||
#include "precomp.h" | ||
|
||
// precompb/precomp.h | ||
int precompb_symbol = 142; |
This file contains 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
This file contains 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
This file contains 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