Currently, precompiled headers OBJs are only produced on Windows with cl.exe so any embedded paths are Windows-specific. Obviously manipulating these paths on Linux won't work.
Additionally, Microsoft link.exe requires a precompiled headers OBJ to be provided on the command-line (even if precomp.obj is there at the proper location, as specified internally by precomp-a.obj).
This fails:
link.exe precomp-a.obj /OUT:a.exe
This works:
link.exe precomp-a.obj precomp.obj /OUT:a.exe
I've consequently only kept the filename-based search. I'm not sure searching with the full embedded path makes sense.
The build break is here:
FAIL: lld :: COFF/precomp-link.test (171 of 1917) ******************** TEST 'lld :: COFF/precomp-link.test' FAILED ******************** Script: -- : 'RUN: at line 1'; /b/sanitizer-x86_64-linux-fast/build/llvm_build_ubsan/bin/lld-link /b/sanitizer-x86_64-linux-fast/build/llvm/tools/lld/test/COFF/Inputs/precomp-a.obj /b/sanitizer-x86_64-linux-fast/build/llvm/tools/lld/test/COFF/Inputs/precomp-b.obj /b/sanitizer-x86_64-linux-fast/build/llvm/tools/lld/test/COFF/Inputs/precomp.obj /nodefaultlib /entry:main /debug /pdb:/b/sanitizer-x86_64-linux-fast/build/llvm_build_ubsan/tools/lld/test/COFF/Output/precomp-link.test.tmp.pdb /out:/b/sanitizer-x86_64-linux-fast/build/llvm_build_ubsan/tools/lld/test/COFF/Output/precomp-link.test.tmp.exe /opt:ref /opt:icf : 'RUN: at line 2'; /b/sanitizer-x86_64-linux-fast/build/llvm_build_ubsan/bin/llvm-pdbutil dump -types /b/sanitizer-x86_64-linux-fast/build/llvm_build_ubsan/tools/lld/test/COFF/Output/precomp-link.test.tmp.pdb | /b/sanitizer-x86_64-linux-fast/build/llvm_build_ubsan/bin/FileCheck /b/sanitizer-x86_64-linux-fast/build/llvm/tools/lld/test/COFF/precomp-link.test : 'RUN: at line 4'; /b/sanitizer-x86_64-linux-fast/build/llvm_build_ubsan/bin/lld-link /b/sanitizer-x86_64-linux-fast/build/llvm/tools/lld/test/COFF/Inputs/precomp.obj /b/sanitizer-x86_64-linux-fast/build/llvm/tools/lld/test/COFF/Inputs/precomp-a.obj /b/sanitizer-x86_64-linux-fast/build/llvm/tools/lld/test/COFF/Inputs/precomp-b.obj /nodefaultlib /entry:main /debug /pdb:/b/sanitizer-x86_64-linux-fast/build/llvm_build_ubsan/tools/lld/test/COFF/Output/precomp-link.test.tmp.pdb /out:/b/sanitizer-x86_64-linux-fast/build/llvm_build_ubsan/tools/lld/test/COFF/Output/precomp-link.test.tmp.exe /opt:ref /opt:icf : 'RUN: at line 5'; /b/sanitizer-x86_64-linux-fast/build/llvm_build_ubsan/bin/llvm-pdbutil dump -types /b/sanitizer-x86_64-linux-fast/build/llvm_build_ubsan/tools/lld/test/COFF/Output/precomp-link.test.tmp.pdb | /b/sanitizer-x86_64-linux-fast/build/llvm_build_ubsan/bin/FileCheck /b/sanitizer-x86_64-linux-fast/build/llvm/tools/lld/test/COFF/precomp-link.test : 'RUN: at line 7'; /b/sanitizer-x86_64-linux-fast/build/llvm_build_ubsan/bin/lld-link /b/sanitizer-x86_64-linux-fast/build/llvm/tools/lld/test/COFF/Inputs/precomp-a.obj /b/sanitizer-x86_64-linux-fast/build/llvm/tools/lld/test/COFF/Inputs/precomp-invalid.obj /b/sanitizer-x86_64-linux-fast/build/llvm/tools/lld/test/COFF/Inputs/precomp.obj /nodefaultlib /entry:main /debug /pdb:/b/sanitizer-x86_64-linux-fast/build/llvm_build_ubsan/tools/lld/test/COFF/Output/precomp-link.test.tmp.pdb /out:/b/sanitizer-x86_64-linux-fast/build/llvm_build_ubsan/tools/lld/test/COFF/Output/precomp-link.test.tmp.exe /opt:ref /opt:icf 2>&1 | /b/sanitizer-x86_64-linux-fast/build/llvm_build_ubsan/bin/FileCheck /b/sanitizer-x86_64-linux-fast/build/llvm/tools/lld/test/COFF/precomp-link.test -check-prefix FAILURE -- Exit Code: 1 Command Output (stderr): -- lld-link: warning: Cannot use debug info for 'precomp-a.obj' >>> failed to load reference 'f:\svn\lld\test\coff\precomp\precomp.obj': No such file or directory lld-link: error: codeview::mergeTypeAndIdRecords failed: The CodeView record is corrupted.
@neerajksingh: Out of curiosity, could you please explain how _PchSym_ symbols are mangled? If I don't add this check, I get:
I find this confusing for users, I've consequently removed pch symbols, in order to emit a better message a bit later on.