1Test the linker line tables on roughly the following example: 2 3==> foo.h <== 4void bar(void); 5inline void foo(void) { 6 bar(); 7} 8==> pdb_lines_1.c <== 9#include "foo.h" 10int main(void) { 11 foo(); 12 return 42; 13} 14==> pdb_lines_2.c <== 15void bar(void) { 16} 17 18$ clang-cl -Xclang -fdebug-compilation-dir -Xclang . -c -Z7 pdb_lines*.c 19 20/pdbsourcepath: only sets the directory that relative paths are considered 21relative to, so this test needs to pass relative paths to lld-link for: 221. The input obj files 232. The /pdb: switch 243. The lld-link invocation itself 25To achieve this, put all inputs of the lld-link invocation (including lld-link 26itself) in a temp directory that's cwd and then make sure to only use relative 27arguments when calling ./lld-link below. 28RUN: rm -rf %t 29RUN: mkdir %t 30RUN: cp lld-link %t/lld-link 31RUN: cd %t 32 33RUN: yaml2obj %S/Inputs/pdb_lines_1_relative.yaml -o %t/pdb_lines_1_relative.obj 34RUN: yaml2obj %S/Inputs/pdb_lines_2_relative.yaml -o %t/pdb_lines_2_relative.obj 35RUN: ./lld-link -debug "-pdbsourcepath:c:\src" -entry:main -nodefaultlib -out:out.exe -pdb:out.pdb pdb_lines_1_relative.obj pdb_lines_2_relative.obj 36RUN: llvm-pdbutil pdb2yaml -modules -module-files -module-syms -subsections=lines,fc %t/out.pdb | FileCheck %s 37RUN: ./lld-link -debug "-pdbsourcepath:/usr/src" -entry:main -nodefaultlib -out:out.exe -pdb:out.pdb pdb_lines_1_relative.obj pdb_lines_2_relative.obj 38RUN: llvm-pdbutil pdb2yaml -modules -module-files -module-syms -subsections=lines,fc %t/out.pdb | FileCheck --check-prefix=POSIX %s 39 40CHECK-LABEL: - Module: 'c:\src\pdb_lines_1_relative.obj' 41CHECK-NEXT: ObjFile: 'c:\src\pdb_lines_1_relative.obj' 42CHECK: SourceFiles: 43CHECK-NEXT: - 'c:\src\pdb_lines_1.c' 44CHECK-NEXT: - 'c:\src\foo.h' 45CHECK: Subsections: 46CHECK: - FileName: 'c:\src\pdb_lines_1.c' 47CHECK: - FileName: 'c:\src\foo.h' 48CHECK: - !FileChecksums 49CHECK: - FileName: 'c:\src\pdb_lines_1.c' 50CHECK: - FileName: 'c:\src\foo.h' 51 52CHECK-LABEL: - Module: 'c:\src\pdb_lines_2_relative.obj' 53CHECK-NEXT: ObjFile: 'c:\src\pdb_lines_2_relative.obj' 54CHECK: SourceFiles: 55CHECK-NEXT: - 'c:\src\pdb_lines_2.c' 56CHECK: Subsections: 57CHECK: - FileName: 'c:\src\pdb_lines_2.c' 58CHECK: - !FileChecksums 59CHECK: - FileName: 'c:\src\pdb_lines_2.c' 60 61CHECK-LABEL: - Kind: S_ENVBLOCK 62CHECK-NEXT: EnvBlockSym: 63CHECK-NEXT: Entries: 64CHECK-NEXT: - cwd 65CHECK-NEXT: - 'c:\src' 66CHECK-NEXT: - exe 67CHECK-NEXT: - 'c:\src\lld-link' 68CHECK-NEXT: - pdb 69CHECK-NEXT: - 'c:\src\out.pdb' 70CHECK-NEXT: - cmd 71CHECK-NEXT: - '-debug -pdbsourcepath:c:\src -entry:main -nodefaultlib -out:out.exe -pdb:out.pdb pdb_lines_1_relative.obj pdb_lines_2_relative.obj' 72 73 74POSIX-LABEL: - Module: '/usr/src/pdb_lines_1_relative.obj' 75POSIX-NEXT: ObjFile: '/usr/src/pdb_lines_1_relative.obj' 76POSIX: SourceFiles: 77POSIX-NEXT: - '/usr/src/pdb_lines_1.c' 78POSIX-NEXT: - '/usr/src/foo.h' 79POSIX: Subsections: 80POSIX: - FileName: '/usr/src/pdb_lines_1.c' 81POSIX: - FileName: '/usr/src/foo.h' 82POSIX: - !FileChecksums 83POSIX: - FileName: '/usr/src/pdb_lines_1.c' 84POSIX: - FileName: '/usr/src/foo.h' 85 86POSIX-LABEL: - Module: '/usr/src/pdb_lines_2_relative.obj' 87POSIX-NEXT: ObjFile: '/usr/src/pdb_lines_2_relative.obj' 88POSIX: SourceFiles: 89POSIX-NEXT: - '/usr/src/pdb_lines_2.c' 90POSIX: Subsections: 91POSIX: - FileName: '/usr/src/pdb_lines_2.c' 92POSIX: - !FileChecksums 93POSIX: - FileName: '/usr/src/pdb_lines_2.c' 94 95POSIX-LABEL: - Kind: S_ENVBLOCK 96POSIX-NEXT: EnvBlockSym: 97POSIX-NEXT: Entries: 98POSIX-NEXT: - cwd 99POSIX-NEXT: - '/usr/src' 100POSIX-NEXT: - exe 101POSIX-NEXT: - '/usr/src/lld-link' 102POSIX-NEXT: - pdb 103POSIX-NEXT: - '/usr/src/out.pdb' 104POSIX-NEXT: - cmd 105POSIX-NEXT: - '-debug -pdbsourcepath:/usr/src -entry:main -nodefaultlib -out:out.exe -pdb:out.pdb pdb_lines_1_relative.obj pdb_lines_2_relative.obj' 106