1 RUN: lld-link %S/Inputs/precomp-a.obj %S/Inputs/precomp-b.obj %S/Inputs/precomp.obj /nodefaultlib /entry:main /debug /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
4 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
5 RUN: llvm-pdbutil dump -types %t.pdb | FileCheck %s
7 RUN: lld-link %S/Inputs/precomp-a.obj %S/Inputs/precomp-invalid.obj %S/Inputs/precomp.obj /nodefaultlib /entry:main /debug /pdb:%t.pdb /out:%t.exe /opt:ref /opt:icf 2>&1 | FileCheck %s -check-prefix FAILURE
8 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 | FileCheck %s -check-prefix FAILURE
10 FIXME: The following RUN line should fail, regardless of whether debug info is
11 enabled or not. Normally this would result in an error due to missing _PchSym_
12 references, but SymbolTable.cpp suppresses such errors. MSVC seems to have a
13 special case for those symbols and it emits the LNK2011 error.
15 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
17 FAILURE: warning: Cannot use debug info for '{{.*}}precomp-invalid.obj' [LNK4099]
18 FAILURE-NEXT: failed to load reference '{{.*}}precomp.obj': No matching precompiled header could be located.
20 FAILURE-MISSING-PRECOMPOBJ: warning: Cannot use debug info for '{{.*}}precomp-a.obj' [LNK4099]
21 FAILURE-MISSING-PRECOMPOBJ-NEXT: failed to load reference '{{.*}}precomp.obj': No matching precompiled header could be located.
23 Check that a PCH object file with a missing S_OBJNAME record results in an
24 error. Edit out this record from the yaml-ified object:
28 ObjectName: 'F:\svn\lld\test\COFF\precomp\precomp.obj'
30 RUN: obj2yaml %S/Inputs/precomp.obj | grep -v 'SectionData: *04000000' > %t.precomp.yaml
31 RUN: sed '/S_OBJNAME/,/ObjectName:/d' < %t.precomp.yaml > precomp-no-objname.yaml
32 RUN: sed 's/Signature: *545589255/Signature: 0/' < %t.precomp.yaml > precomp-zero-sig.yaml
33 RUN: yaml2obj precomp-no-objname.yaml -o %t.precomp-no-objname.obj
34 RUN: yaml2obj precomp-zero-sig.yaml -o %t.precomp-zero-sig.obj
36 RUN: env LLD_IN_TEST=1 not lld-link %t.precomp-no-objname.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-NO-SIGNATURE
38 RUN: env LLD_IN_TEST=1 not lld-link %t.precomp-zero-sig.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-NO-SIGNATURE
40 FAILURE-NO-SIGNATURE: error: {{.*}}.obj claims to be a PCH object, but does not have a valid signature
42 Check that two PCH objs with duplicate signatures are an error.
44 RUN: cp %S/Inputs/precomp.obj %t.precomp-dup.obj
46 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
48 FAILURE-DUP-SIGNATURE: error: a PCH object with the same signature has already been provided ({{.*precomp.obj and .*precomp-dup.obj.*}})
51 CHECK: Types (TPI Stream)
53 CHECK-NOT: LF_ENDPRECOMP
56 Re-run with ghash. Eventually, perhaps this will be the default.
58 RUN: lld-link %S/Inputs/precomp-a.obj %S/Inputs/precomp-b.obj %S/Inputs/precomp.obj /nodefaultlib /entry:main /debug /debug:ghash /pdb:%t.pdb /out:%t.exe /opt:ref /opt:icf /summary | FileCheck %s -check-prefix SUMMARY
59 RUN: llvm-pdbutil dump -types %t.pdb | FileCheck %s
63 SUMMARY-NEXT: --------------------------------------------------------------------------------
64 SUMMARY-NEXT: 3 Input OBJ files (expanded from all cmd-line inputs)
65 SUMMARY-NEXT: 0 PDB type server dependencies
66 SUMMARY-NEXT: 1 Precomp OBJ dependencies
67 SUMMARY-NEXT: 1066 Input type records
68 SUMMARY-NEXT: 55968 Input type records bytes
69 SUMMARY-NEXT: 874 Merged TPI records
70 SUMMARY-NEXT: 170 Merged IPI records
71 SUMMARY-NEXT: 5 Output PDB strings
72 SUMMARY-NEXT: 167 Global symbol records
73 SUMMARY-NEXT: 20 Module symbol records
74 SUMMARY-NEXT: 3 Public symbol records
92 int Function(char a) {
96 // cl.exe precomp.cpp /Z7 /Ycprecomp.h /c
97 // cl.exe a.cpp b.cpp /Z7 /Yuprecomp.h /c