1 RUN: lld-link %S/Inputs/precomp-a.obj %S/Inputs/precomp-b.obj %S/Inputs/precomp.obj /nodefaultlib /entry:main /debug:noghash /pdb:%t.pdb /out:%t.exe /opt:ref /opt:icf /summary | FileCheck %s -check-prefix SUMMARY
2 RUN: llvm-pdbutil dump -types %t.pdb | FileCheck %s
3 RUN: lld-link %S/Inputs/precomp-a.obj %S/Inputs/precomp-b.obj %S/Inputs/precomp.obj /nodefaultlib /entry:main /debug:ghash /pdb:%t.pdb /out:%t.exe /opt:ref /opt:icf /summary | FileCheck %s -check-prefix SUMMARY
4 RUN: llvm-pdbutil dump -types %t.pdb | FileCheck %s
6 RUN: lld-link %S/Inputs/precomp.obj %S/Inputs/precomp-a.obj %S/Inputs/precomp-b.obj /nodefaultlib /entry:main /debug /pdb:%t.pdb /out:%t.exe /opt:ref /opt:icf
7 RUN: llvm-pdbutil dump -types %t.pdb | FileCheck %s
9 RUN: lld-link %S/Inputs/precomp-a.obj %S/Inputs/precomp-invalid.obj %S/Inputs/precomp.obj /nodefaultlib /entry:main /debug:noghash /pdb:%t.pdb /out:%t.exe /opt:ref /opt:icf 2>&1
10 RUN: lld-link %S/Inputs/precomp-a.obj %S/Inputs/precomp-invalid.obj %S/Inputs/precomp.obj /nodefaultlib /entry:main /debug:ghash /pdb:%t.pdb /out:%t.exe /opt:ref /opt:icf 2>&1
12 FIXME: The following RUN line should fail, regardless of whether debug info is
13 enabled or not. Normally this would result in an error due to missing _PchSym_
14 references, but SymbolTable.cpp suppresses such errors. MSVC seems to have a
15 special case for those symbols and it emits the LNK2011 error.
17 RUN: lld-link %S/Inputs/precomp-a.obj %S/Inputs/precomp-b.obj /nodefaultlib /entry:main /debug /pdb:%t.pdb /out:%t.exe /opt:ref /opt:icf 2>&1 | FileCheck %s -check-prefix FAILURE-MISSING-PRECOMPOBJ
19 FAILURE-MISSING-PRECOMPOBJ: warning: Cannot use debug info for '{{.*}}precomp-a.obj' [LNK4099]
20 FAILURE-MISSING-PRECOMPOBJ-NEXT: failed to load reference '{{.*}}precomp.obj': No matching precompiled header could be located.
22 Check that a PCH object file with an empty S_OBJNAME record works fine.
23 Edit out this record from the yaml-ified object:
27 ObjectName: 'F:\svn\lld\test\COFF\precomp\precomp.obj'
29 RUN: obj2yaml %S/Inputs/precomp.obj | grep -v 'SectionData: *04000000' > %t.precomp.yaml
30 RUN: sed '/S_OBJNAME/,/ObjectName:/d' < %t.precomp.yaml > precomp-no-objname.yaml
31 RUN: sed '16,19s/Signature: *545589255/Signature: 0/' < %t.precomp.yaml > precomp-zero-sig.yaml
32 RUN: yaml2obj precomp-no-objname.yaml -o %t.precomp-no-objname.obj
33 RUN: yaml2obj precomp-zero-sig.yaml -o %t.precomp-zero-sig.obj
34 RUN: env LLD_IN_TEST=1 lld-link %t.precomp-no-objname.obj %S/Inputs/precomp-a.obj %S/Inputs/precomp-b.obj /nodefaultlib /entry:main /debug:noghash /pdb:%t.pdb /out:%t.exe 2>&1 | FileCheck %s -check-prefix WARNING --allow-empty
35 RUN: env LLD_IN_TEST=1 lld-link %t.precomp-no-objname.obj %S/Inputs/precomp-a.obj %S/Inputs/precomp-b.obj /nodefaultlib /entry:main /debug:ghash /pdb:%t.pdb /out:%t.exe 2>&1 | FileCheck %s -check-prefix WARNING --allow-empty
36 RUN: env LLD_IN_TEST=1 lld-link %t.precomp-zero-sig.obj %S/Inputs/precomp-a.obj %S/Inputs/precomp-b.obj /nodefaultlib /entry:main /debug:noghash /pdb:%t.pdb /out:%t.exe 2>&1 | FileCheck %s -check-prefix WARNING --allow-empty
37 RUN: env LLD_IN_TEST=1 lld-link %t.precomp-zero-sig.obj %S/Inputs/precomp-a.obj %S/Inputs/precomp-b.obj /nodefaultlib /entry:main /debug:ghash /pdb:%t.pdb /out:%t.exe 2>&1 | FileCheck %s -check-prefix WARNING --allow-empty
41 Check that a PCH with wrong signature, but with right LF_PRECOMP records count, works.
43 RUN: sed '16,19s/Signature: *545589255/Signature: 123456789/' < %t.precomp.yaml > precomp-wrong-sig.yaml
44 RUN: yaml2obj precomp-wrong-sig.yaml -o %T/precomp.obj
45 RUN: env LLD_IN_TEST=1 lld-link %T/precomp.obj %S/Inputs/precomp-a.obj %S/Inputs/precomp-b.obj /nodefaultlib /entry:main /debug:noghash /pdb:%t.pdb /out:%t.exe 2>&1 | FileCheck %s -check-prefix WARNING --allow-empty
46 RUN: env LLD_IN_TEST=1 lld-link %T/precomp.obj %S/Inputs/precomp-a.obj %S/Inputs/precomp-b.obj /nodefaultlib /entry:main /debug:ghash /pdb:%t.pdb /out:%t.exe 2>&1 | FileCheck %s -check-prefix WARNING --allow-empty
48 Check that two PCH objs with duplicate signatures are an error.
50 RUN: cp %S/Inputs/precomp.obj %t.precomp-dup.obj
51 RUN: env LLD_IN_TEST=1 not lld-link %S/Inputs/precomp.obj %t.precomp-dup.obj %S/Inputs/precomp-a.obj %S/Inputs/precomp-b.obj /nodefaultlib /entry:main /debug /pdb:%t.pdb /out:%t.exe 2>&1 | FileCheck %s -check-prefix FAILURE-DUP-SIGNATURE
52 FAILURE-DUP-SIGNATURE: error: a PCH object with the same signature has already been provided ({{.*precomp.obj and .*precomp-dup.obj.*}})
55 CHECK: Types (TPI Stream)
57 CHECK-NOT: LF_ENDPRECOMP
60 SUMMARY-NEXT: --------------------------------------------------------------------------------
61 SUMMARY-NEXT: 3 Input OBJ files (expanded from all cmd-line inputs)
62 SUMMARY-NEXT: 0 PDB type server dependencies
63 SUMMARY-NEXT: 1 Precomp OBJ dependencies
64 SUMMARY-NEXT: 1066 Input type records
65 SUMMARY-NEXT: 55968 Input type records bytes
66 SUMMARY-NEXT: 874 Merged TPI records
67 SUMMARY-NEXT: 170 Merged IPI records
68 SUMMARY-NEXT: 5 Output PDB strings
69 SUMMARY-NEXT: 167 Global symbol records
70 SUMMARY-NEXT: 20 Module symbol records
71 SUMMARY-NEXT: 3 Public symbol records
89 int Function(char a) {
93 // cl.exe precomp.cpp /Z7 /Ycprecomp.h /c
94 // cl.exe a.cpp b.cpp /Z7 /Yuprecomp.h /c