1 Test the linker line tables on roughly the following example:
5 inline void foo(void) {
18 $ clang-cl -fdebug-compilation-dir . -no-canonical-prefixes -c -Z7 pdb_lines*.c
19 $ obj2yaml pdb_lines_1.obj > pdb_lines_1_relative.yaml
20 $ obj2yaml pdb_lines_2.obj > pdb_lines_2_relative.yaml
22 /pdbsourcepath: only sets the directory that relative paths are considered
23 relative to, so this test needs to pass relative paths to lld-link for:
24 1. The input obj files
26 3. The lld-link invocation itself
27 To achieve this, put all inputs of the lld-link invocation (including lld-link
28 itself) in a temp directory that's cwd and then make sure to only use relative
29 arguments when calling ./lld-link below.
32 RUN: cp lld-link %t/lld-link
35 RUN: yaml2obj %S/Inputs/pdb_lines_1_relative.yaml -o %t/pdb_lines_1_relative.obj
36 RUN: yaml2obj %S/Inputs/pdb_lines_2_relative.yaml -o %t/pdb_lines_2_relative.obj
37 RUN: ./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
38 RUN: llvm-pdbutil pdb2yaml -ipi-stream -modules -module-files -module-syms -subsections=lines,fc %t/out.pdb | FileCheck %s
39 RUN: ./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
40 RUN: llvm-pdbutil pdb2yaml -ipi-stream -modules -module-files -module-syms -subsections=lines,fc %t/out.pdb | FileCheck --check-prefix=POSIX %s
42 Also check without -pdbsourcepath
43 RUN: ./lld-link -debug -entry:main -nodefaultlib -out:out.exe -pdb:out.pdb pdb_lines_1_relative.obj pdb_lines_2_relative.obj
44 RUN: llvm-pdbutil pdb2yaml -modules -module-files -module-syms -subsections=lines,fc %t/out.pdb | FileCheck --check-prefix=ABSOLUTE %s
46 Clean up copy of large binary copied into temp directory to avoid bloat.
47 RUN: rm -f ./lld-link || true
49 CHECK-LABEL: - Module: 'c:\src\pdb_lines_1_relative.obj'
50 CHECK-NEXT: ObjFile: 'c:\src\pdb_lines_1_relative.obj'
52 CHECK-NEXT: - 'c:\src\pdb_lines_1.c'
53 CHECK-NEXT: - 'c:\src\foo.h'
55 CHECK: - FileName: 'c:\src\pdb_lines_1.c'
56 CHECK: - FileName: 'c:\src\foo.h'
57 CHECK: - !FileChecksums
58 CHECK: - FileName: 'c:\src\pdb_lines_1.c'
59 CHECK: - FileName: 'c:\src\foo.h'
61 CHECK-LABEL: - Module: 'c:\src\pdb_lines_2_relative.obj'
62 CHECK-NEXT: ObjFile: 'c:\src\pdb_lines_2_relative.obj'
64 CHECK-NEXT: - 'c:\src\pdb_lines_2.c'
66 CHECK: - FileName: 'c:\src\pdb_lines_2.c'
67 CHECK: - !FileChecksums
68 CHECK: - FileName: 'c:\src\pdb_lines_2.c'
70 CHECK-LABEL: - Kind: S_ENVBLOCK
71 CHECK-NEXT: EnvBlockSym:
74 CHECK-NEXT: - 'c:\src'
76 CHECK-NEXT: - 'c:\src\lld-link'
78 CHECK-NEXT: - 'c:\src\out.pdb'
80 CHECK-NEXT: - '-debug -pdbsourcepath:c:\src -entry:main -nodefaultlib -out:out.exe -pdb:out.pdb'
82 CHECK-LABEL: IpiStream:
84 CHECK: - Kind: LF_STRING_ID
88 CHECK-NEXT: - Kind: LF_STRING_ID
91 CHECK-NEXT: String: pdb_lines_1.c
92 CHECK-NEXT: - Kind: LF_STRING_ID
95 CHECK-NEXT: String: 'buildninjaRel\bin\clang-cl.exe'
97 POSIX-LABEL: - Module: '/usr/src/pdb_lines_1_relative.obj'
98 POSIX-NEXT: ObjFile: '/usr/src/pdb_lines_1_relative.obj'
100 POSIX-NEXT: - '/usr/src/pdb_lines_1.c'
101 POSIX-NEXT: - '/usr/src/foo.h'
103 POSIX: - FileName: '/usr/src/pdb_lines_1.c'
104 POSIX: - FileName: '/usr/src/foo.h'
105 POSIX: - !FileChecksums
106 POSIX: - FileName: '/usr/src/pdb_lines_1.c'
107 POSIX: - FileName: '/usr/src/foo.h'
109 POSIX-LABEL: - Module: '/usr/src/pdb_lines_2_relative.obj'
110 POSIX-NEXT: ObjFile: '/usr/src/pdb_lines_2_relative.obj'
112 POSIX-NEXT: - '/usr/src/pdb_lines_2.c'
114 POSIX: - FileName: '/usr/src/pdb_lines_2.c'
115 POSIX: - !FileChecksums
116 POSIX: - FileName: '/usr/src/pdb_lines_2.c'
118 POSIX-LABEL: - Kind: S_ENVBLOCK
119 POSIX-NEXT: EnvBlockSym:
122 POSIX-NEXT: - '/usr/src'
124 POSIX-NEXT: - '/usr/src/lld-link'
126 POSIX-NEXT: - '/usr/src/out.pdb'
128 POSIX-NEXT: - '-debug -pdbsourcepath:/usr/src -entry:main -nodefaultlib -out:out.exe -pdb:out.pdb'
130 ABSOLUTE-LABEL: StringTable:
131 ABSOLUTE-NOT: {{/|\\}}.{{/|\\}}pdb_lines_1.c
133 POSIX-LABEL: IpiStream:
134 POSIX: - Kind: LF_STRING_ID
135 POSIX-NEXT: StringId:
137 POSIX-NEXT: String: .
138 POSIX-NEXT: - Kind: LF_STRING_ID
139 POSIX-NEXT: StringId:
141 POSIX-NEXT: String: pdb_lines_1.c
142 POSIX-NEXT: - Kind: LF_STRING_ID
143 POSIX-NEXT: StringId:
145 POSIX-NEXT: String: 'buildninjaRel\bin\clang-cl.exe'