mirror of
https://github.com/intel/llvm.git
synced 2026-02-08 00:50:03 +08:00
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
55 lines
2.2 KiB
Plaintext
55 lines
2.2 KiB
Plaintext
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
|