precomp-link.test 2.24 KB
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
RUN: llvm-pdbutil dump -types %t.pdb | FileCheck %s

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
RUN: llvm-pdbutil dump -types %t.pdb | FileCheck %s

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

RUN: not 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

FAILURE: warning: Cannot use debug info for '{{.*}}precomp-invalid.obj' [LNK4099]
FAILURE-NEXT: failed to load reference '{{.*}}precomp.obj': No matching precompiled header could be located.

FAILURE-MISSING-PRECOMPOBJ: warning: Cannot use debug info for '{{.*}}precomp-a.obj' [LNK4099]
FAILURE-MISSING-PRECOMPOBJ-NEXT: failed to load reference '{{.*}}precomp.obj': No matching precompiled header could be located.

CHECK: Types (TPI Stream)
CHECK-NOT: LF_PRECOMP
CHECK-NOT: LF_ENDPRECOMP


SUMMARY:                                     Summary
SUMMARY-NEXT: --------------------------------------------------------------------------------
SUMMARY-NEXT:               3 Input OBJ files (expanded from all cmd-line inputs)
SUMMARY-NEXT:               0 PDB type server dependencies
SUMMARY-NEXT:               1 Precomp OBJ dependencies
SUMMARY-NEXT:            1044 Merged TPI records
SUMMARY-NEXT:               5 Output PDB strings
SUMMARY-NEXT:             167 Global symbol records
SUMMARY-NEXT:              20 Module symbol records
SUMMARY-NEXT:               3 Public symbol records

// precomp.h
#pragma once
int Function(char A);

// precomp.cpp
#include "precomp.h"

// a.cpp
#include "precomp.h"
int main(void) {
  Function('a');
  return 0;
}

// b.cpp
#include "precomp.h"
int Function(char a) {
  return (int)a;
}

// cl.exe precomp.cpp /Z7 /Ycprecomp.h /c
// cl.exe a.cpp b.cpp /Z7 /Yuprecomp.h /c