2018-07-19 12:56:22 +08:00
|
|
|
Test the linker line tables on roughly the following example:
|
|
|
|
|
|
|
|
==> foo.h <==
|
|
|
|
void bar(void);
|
|
|
|
inline void foo(void) {
|
|
|
|
bar();
|
|
|
|
}
|
|
|
|
==> pdb_lines_1.c <==
|
|
|
|
#include "foo.h"
|
|
|
|
int main(void) {
|
|
|
|
foo();
|
|
|
|
return 42;
|
|
|
|
}
|
|
|
|
==> pdb_lines_2.c <==
|
|
|
|
void bar(void) {
|
|
|
|
}
|
|
|
|
|
2020-08-18 02:23:46 +08:00
|
|
|
$ clang-cl -Xclang -fdebug-compilation-dir -Xclang . -c -Z7 pdb_lines*.c
|
2018-07-19 12:56:22 +08:00
|
|
|
|
lld-link: Use /pdbsourcepath: for more places when present.
/pdbsourcepath: was added in https://reviews.llvm.org/D48882 to make it
possible to have relative paths in the debug info that clang-cl writes.
lld-link then makes the paths absolute at link time, which debuggers require.
This way, clang-cl's output is independent of the absolute path of the build
directory, which is useful for cacheability in distcc-like systems.
This patch extends /pdbsourcepath: (if passed) to also be used for:
1. The "cwd" stored in the env block in the pdb is /pdbsourcepath: if present
2. The "exe" stored in the env block in the pdb is made absolute relative
to /pdbsourcepath: instead of the cwd
3. The "pdb" stored in the env block in the pdb is made absolute relative
to /pdbsourcepath: instead of the cwd
4. For making absolute paths to .obj files referenced from the pdb
/pdbsourcepath: is now useful in three scenarios (the first one already working
before this change):
1. When building with full debug info, passing the real build dir to
/pdbsourcepath: allows having clang-cl's output to be independent
of the build directory path. This patch effectively doesn't change
behavior for this use case (assuming the cwd is the build dir).
2. When building without compile-time debug info but linking with /debug,
a fake fixed /pdbsourcepath: can be passed to get symbolized stacks
while making the pdb and exe independent of the current build dir.
For this two work, lld-link needs to be invoked with relative paths for
the lld-link invocation itself (for "exe"), for the pdb output name, the exe
output name (for "pdb"), and the obj input files, and no absolute path
must appear on the link command (for "cmd" in the pdb's env block).
Since no full debug info is present, it doesn't matter that the absolute
path doesn't exist on disk -- we only get symbols in stacks.
3. When building production builds with full debug info that don't have
local changes, and that get source indexed and their pdbs get uploaded
to a symbol server. /pdbsourcepath: again makes the build output independent
of the current directory, and the fixed path passed to /pdbsourcepath: can
be given the source indexing transform so that it gets mapped to a
repository path. This has the same requirements as 2.
This patch also makes it possible to create PDB files containing Windows-style
absolute paths when cross-compiling on a POSIX system.
Differential Revision: https://reviews.llvm.org/D53021
llvm-svn: 344061
2018-10-10 01:52:25 +08:00
|
|
|
/pdbsourcepath: only sets the directory that relative paths are considered
|
|
|
|
relative to, so this test needs to pass relative paths to lld-link for:
|
|
|
|
1. The input obj files
|
|
|
|
2. The /pdb: switch
|
|
|
|
3. The lld-link invocation itself
|
|
|
|
To achieve this, put all inputs of the lld-link invocation (including lld-link
|
|
|
|
itself) in a temp directory that's cwd and then make sure to only use relative
|
|
|
|
arguments when calling ./lld-link below.
|
|
|
|
RUN: rm -rf %t
|
|
|
|
RUN: mkdir %t
|
|
|
|
RUN: cp lld-link %t/lld-link
|
|
|
|
RUN: cd %t
|
2018-07-19 12:56:22 +08:00
|
|
|
|
lld-link: Use /pdbsourcepath: for more places when present.
/pdbsourcepath: was added in https://reviews.llvm.org/D48882 to make it
possible to have relative paths in the debug info that clang-cl writes.
lld-link then makes the paths absolute at link time, which debuggers require.
This way, clang-cl's output is independent of the absolute path of the build
directory, which is useful for cacheability in distcc-like systems.
This patch extends /pdbsourcepath: (if passed) to also be used for:
1. The "cwd" stored in the env block in the pdb is /pdbsourcepath: if present
2. The "exe" stored in the env block in the pdb is made absolute relative
to /pdbsourcepath: instead of the cwd
3. The "pdb" stored in the env block in the pdb is made absolute relative
to /pdbsourcepath: instead of the cwd
4. For making absolute paths to .obj files referenced from the pdb
/pdbsourcepath: is now useful in three scenarios (the first one already working
before this change):
1. When building with full debug info, passing the real build dir to
/pdbsourcepath: allows having clang-cl's output to be independent
of the build directory path. This patch effectively doesn't change
behavior for this use case (assuming the cwd is the build dir).
2. When building without compile-time debug info but linking with /debug,
a fake fixed /pdbsourcepath: can be passed to get symbolized stacks
while making the pdb and exe independent of the current build dir.
For this two work, lld-link needs to be invoked with relative paths for
the lld-link invocation itself (for "exe"), for the pdb output name, the exe
output name (for "pdb"), and the obj input files, and no absolute path
must appear on the link command (for "cmd" in the pdb's env block).
Since no full debug info is present, it doesn't matter that the absolute
path doesn't exist on disk -- we only get symbols in stacks.
3. When building production builds with full debug info that don't have
local changes, and that get source indexed and their pdbs get uploaded
to a symbol server. /pdbsourcepath: again makes the build output independent
of the current directory, and the fixed path passed to /pdbsourcepath: can
be given the source indexing transform so that it gets mapped to a
repository path. This has the same requirements as 2.
This patch also makes it possible to create PDB files containing Windows-style
absolute paths when cross-compiling on a POSIX system.
Differential Revision: https://reviews.llvm.org/D53021
llvm-svn: 344061
2018-10-10 01:52:25 +08:00
|
|
|
RUN: yaml2obj %S/Inputs/pdb_lines_1_relative.yaml -o %t/pdb_lines_1_relative.obj
|
|
|
|
RUN: yaml2obj %S/Inputs/pdb_lines_2_relative.yaml -o %t/pdb_lines_2_relative.obj
|
2018-10-10 02:19:09 +08:00
|
|
|
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
|
2020-08-18 02:23:46 +08:00
|
|
|
RUN: llvm-pdbutil pdb2yaml -modules -module-files -module-syms -subsections=lines,fc %t/out.pdb | FileCheck %s
|
2018-10-13 01:26:19 +08:00
|
|
|
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
|
2020-08-18 02:23:46 +08:00
|
|
|
RUN: llvm-pdbutil pdb2yaml -modules -module-files -module-syms -subsections=lines,fc %t/out.pdb | FileCheck --check-prefix=POSIX %s
|
lld-link: Use /pdbsourcepath: for more places when present.
/pdbsourcepath: was added in https://reviews.llvm.org/D48882 to make it
possible to have relative paths in the debug info that clang-cl writes.
lld-link then makes the paths absolute at link time, which debuggers require.
This way, clang-cl's output is independent of the absolute path of the build
directory, which is useful for cacheability in distcc-like systems.
This patch extends /pdbsourcepath: (if passed) to also be used for:
1. The "cwd" stored in the env block in the pdb is /pdbsourcepath: if present
2. The "exe" stored in the env block in the pdb is made absolute relative
to /pdbsourcepath: instead of the cwd
3. The "pdb" stored in the env block in the pdb is made absolute relative
to /pdbsourcepath: instead of the cwd
4. For making absolute paths to .obj files referenced from the pdb
/pdbsourcepath: is now useful in three scenarios (the first one already working
before this change):
1. When building with full debug info, passing the real build dir to
/pdbsourcepath: allows having clang-cl's output to be independent
of the build directory path. This patch effectively doesn't change
behavior for this use case (assuming the cwd is the build dir).
2. When building without compile-time debug info but linking with /debug,
a fake fixed /pdbsourcepath: can be passed to get symbolized stacks
while making the pdb and exe independent of the current build dir.
For this two work, lld-link needs to be invoked with relative paths for
the lld-link invocation itself (for "exe"), for the pdb output name, the exe
output name (for "pdb"), and the obj input files, and no absolute path
must appear on the link command (for "cmd" in the pdb's env block).
Since no full debug info is present, it doesn't matter that the absolute
path doesn't exist on disk -- we only get symbols in stacks.
3. When building production builds with full debug info that don't have
local changes, and that get source indexed and their pdbs get uploaded
to a symbol server. /pdbsourcepath: again makes the build output independent
of the current directory, and the fixed path passed to /pdbsourcepath: can
be given the source indexing transform so that it gets mapped to a
repository path. This has the same requirements as 2.
This patch also makes it possible to create PDB files containing Windows-style
absolute paths when cross-compiling on a POSIX system.
Differential Revision: https://reviews.llvm.org/D53021
llvm-svn: 344061
2018-10-10 01:52:25 +08:00
|
|
|
|
2019-02-06 08:50:35 +08:00
|
|
|
CHECK-LABEL: - Module: 'c:\src\pdb_lines_1_relative.obj'
|
|
|
|
CHECK-NEXT: ObjFile: 'c:\src\pdb_lines_1_relative.obj'
|
2018-07-19 12:56:22 +08:00
|
|
|
CHECK: SourceFiles:
|
2019-02-06 08:50:35 +08:00
|
|
|
CHECK-NEXT: - 'c:\src\pdb_lines_1.c'
|
|
|
|
CHECK-NEXT: - 'c:\src\foo.h'
|
2018-07-19 12:56:22 +08:00
|
|
|
CHECK: Subsections:
|
2019-02-06 08:50:35 +08:00
|
|
|
CHECK: - FileName: 'c:\src\pdb_lines_1.c'
|
|
|
|
CHECK: - FileName: 'c:\src\foo.h'
|
2018-07-19 12:56:22 +08:00
|
|
|
CHECK: - !FileChecksums
|
2019-02-06 08:50:35 +08:00
|
|
|
CHECK: - FileName: 'c:\src\pdb_lines_1.c'
|
|
|
|
CHECK: - FileName: 'c:\src\foo.h'
|
2018-07-19 12:56:22 +08:00
|
|
|
|
2019-02-06 08:50:35 +08:00
|
|
|
CHECK-LABEL: - Module: 'c:\src\pdb_lines_2_relative.obj'
|
|
|
|
CHECK-NEXT: ObjFile: 'c:\src\pdb_lines_2_relative.obj'
|
2018-07-19 12:56:22 +08:00
|
|
|
CHECK: SourceFiles:
|
2019-02-06 08:50:35 +08:00
|
|
|
CHECK-NEXT: - 'c:\src\pdb_lines_2.c'
|
2018-07-19 12:56:22 +08:00
|
|
|
CHECK: Subsections:
|
2019-02-06 08:50:35 +08:00
|
|
|
CHECK: - FileName: 'c:\src\pdb_lines_2.c'
|
2018-07-19 12:56:22 +08:00
|
|
|
CHECK: - !FileChecksums
|
2019-02-06 08:50:35 +08:00
|
|
|
CHECK: - FileName: 'c:\src\pdb_lines_2.c'
|
lld-link: Use /pdbsourcepath: for more places when present.
/pdbsourcepath: was added in https://reviews.llvm.org/D48882 to make it
possible to have relative paths in the debug info that clang-cl writes.
lld-link then makes the paths absolute at link time, which debuggers require.
This way, clang-cl's output is independent of the absolute path of the build
directory, which is useful for cacheability in distcc-like systems.
This patch extends /pdbsourcepath: (if passed) to also be used for:
1. The "cwd" stored in the env block in the pdb is /pdbsourcepath: if present
2. The "exe" stored in the env block in the pdb is made absolute relative
to /pdbsourcepath: instead of the cwd
3. The "pdb" stored in the env block in the pdb is made absolute relative
to /pdbsourcepath: instead of the cwd
4. For making absolute paths to .obj files referenced from the pdb
/pdbsourcepath: is now useful in three scenarios (the first one already working
before this change):
1. When building with full debug info, passing the real build dir to
/pdbsourcepath: allows having clang-cl's output to be independent
of the build directory path. This patch effectively doesn't change
behavior for this use case (assuming the cwd is the build dir).
2. When building without compile-time debug info but linking with /debug,
a fake fixed /pdbsourcepath: can be passed to get symbolized stacks
while making the pdb and exe independent of the current build dir.
For this two work, lld-link needs to be invoked with relative paths for
the lld-link invocation itself (for "exe"), for the pdb output name, the exe
output name (for "pdb"), and the obj input files, and no absolute path
must appear on the link command (for "cmd" in the pdb's env block).
Since no full debug info is present, it doesn't matter that the absolute
path doesn't exist on disk -- we only get symbols in stacks.
3. When building production builds with full debug info that don't have
local changes, and that get source indexed and their pdbs get uploaded
to a symbol server. /pdbsourcepath: again makes the build output independent
of the current directory, and the fixed path passed to /pdbsourcepath: can
be given the source indexing transform so that it gets mapped to a
repository path. This has the same requirements as 2.
This patch also makes it possible to create PDB files containing Windows-style
absolute paths when cross-compiling on a POSIX system.
Differential Revision: https://reviews.llvm.org/D53021
llvm-svn: 344061
2018-10-10 01:52:25 +08:00
|
|
|
|
|
|
|
CHECK-LABEL: - Kind: S_ENVBLOCK
|
|
|
|
CHECK-NEXT: EnvBlockSym:
|
|
|
|
CHECK-NEXT: Entries:
|
|
|
|
CHECK-NEXT: - cwd
|
|
|
|
CHECK-NEXT: - 'c:\src'
|
|
|
|
CHECK-NEXT: - exe
|
2019-02-06 08:50:35 +08:00
|
|
|
CHECK-NEXT: - 'c:\src\lld-link'
|
lld-link: Use /pdbsourcepath: for more places when present.
/pdbsourcepath: was added in https://reviews.llvm.org/D48882 to make it
possible to have relative paths in the debug info that clang-cl writes.
lld-link then makes the paths absolute at link time, which debuggers require.
This way, clang-cl's output is independent of the absolute path of the build
directory, which is useful for cacheability in distcc-like systems.
This patch extends /pdbsourcepath: (if passed) to also be used for:
1. The "cwd" stored in the env block in the pdb is /pdbsourcepath: if present
2. The "exe" stored in the env block in the pdb is made absolute relative
to /pdbsourcepath: instead of the cwd
3. The "pdb" stored in the env block in the pdb is made absolute relative
to /pdbsourcepath: instead of the cwd
4. For making absolute paths to .obj files referenced from the pdb
/pdbsourcepath: is now useful in three scenarios (the first one already working
before this change):
1. When building with full debug info, passing the real build dir to
/pdbsourcepath: allows having clang-cl's output to be independent
of the build directory path. This patch effectively doesn't change
behavior for this use case (assuming the cwd is the build dir).
2. When building without compile-time debug info but linking with /debug,
a fake fixed /pdbsourcepath: can be passed to get symbolized stacks
while making the pdb and exe independent of the current build dir.
For this two work, lld-link needs to be invoked with relative paths for
the lld-link invocation itself (for "exe"), for the pdb output name, the exe
output name (for "pdb"), and the obj input files, and no absolute path
must appear on the link command (for "cmd" in the pdb's env block).
Since no full debug info is present, it doesn't matter that the absolute
path doesn't exist on disk -- we only get symbols in stacks.
3. When building production builds with full debug info that don't have
local changes, and that get source indexed and their pdbs get uploaded
to a symbol server. /pdbsourcepath: again makes the build output independent
of the current directory, and the fixed path passed to /pdbsourcepath: can
be given the source indexing transform so that it gets mapped to a
repository path. This has the same requirements as 2.
This patch also makes it possible to create PDB files containing Windows-style
absolute paths when cross-compiling on a POSIX system.
Differential Revision: https://reviews.llvm.org/D53021
llvm-svn: 344061
2018-10-10 01:52:25 +08:00
|
|
|
CHECK-NEXT: - pdb
|
2019-02-06 08:50:35 +08:00
|
|
|
CHECK-NEXT: - 'c:\src\out.pdb'
|
lld-link: Use /pdbsourcepath: for more places when present.
/pdbsourcepath: was added in https://reviews.llvm.org/D48882 to make it
possible to have relative paths in the debug info that clang-cl writes.
lld-link then makes the paths absolute at link time, which debuggers require.
This way, clang-cl's output is independent of the absolute path of the build
directory, which is useful for cacheability in distcc-like systems.
This patch extends /pdbsourcepath: (if passed) to also be used for:
1. The "cwd" stored in the env block in the pdb is /pdbsourcepath: if present
2. The "exe" stored in the env block in the pdb is made absolute relative
to /pdbsourcepath: instead of the cwd
3. The "pdb" stored in the env block in the pdb is made absolute relative
to /pdbsourcepath: instead of the cwd
4. For making absolute paths to .obj files referenced from the pdb
/pdbsourcepath: is now useful in three scenarios (the first one already working
before this change):
1. When building with full debug info, passing the real build dir to
/pdbsourcepath: allows having clang-cl's output to be independent
of the build directory path. This patch effectively doesn't change
behavior for this use case (assuming the cwd is the build dir).
2. When building without compile-time debug info but linking with /debug,
a fake fixed /pdbsourcepath: can be passed to get symbolized stacks
while making the pdb and exe independent of the current build dir.
For this two work, lld-link needs to be invoked with relative paths for
the lld-link invocation itself (for "exe"), for the pdb output name, the exe
output name (for "pdb"), and the obj input files, and no absolute path
must appear on the link command (for "cmd" in the pdb's env block).
Since no full debug info is present, it doesn't matter that the absolute
path doesn't exist on disk -- we only get symbols in stacks.
3. When building production builds with full debug info that don't have
local changes, and that get source indexed and their pdbs get uploaded
to a symbol server. /pdbsourcepath: again makes the build output independent
of the current directory, and the fixed path passed to /pdbsourcepath: can
be given the source indexing transform so that it gets mapped to a
repository path. This has the same requirements as 2.
This patch also makes it possible to create PDB files containing Windows-style
absolute paths when cross-compiling on a POSIX system.
Differential Revision: https://reviews.llvm.org/D53021
llvm-svn: 344061
2018-10-10 01:52:25 +08:00
|
|
|
CHECK-NEXT: - cmd
|
|
|
|
CHECK-NEXT: - '-debug -pdbsourcepath:c:\src -entry:main -nodefaultlib -out:out.exe -pdb:out.pdb pdb_lines_1_relative.obj pdb_lines_2_relative.obj'
|
2018-10-13 01:26:19 +08:00
|
|
|
|
|
|
|
|
2019-02-06 08:50:35 +08:00
|
|
|
POSIX-LABEL: - Module: '/usr/src/pdb_lines_1_relative.obj'
|
|
|
|
POSIX-NEXT: ObjFile: '/usr/src/pdb_lines_1_relative.obj'
|
2018-10-13 01:26:19 +08:00
|
|
|
POSIX: SourceFiles:
|
2019-02-06 08:50:35 +08:00
|
|
|
POSIX-NEXT: - '/usr/src/pdb_lines_1.c'
|
|
|
|
POSIX-NEXT: - '/usr/src/foo.h'
|
2018-10-13 01:26:19 +08:00
|
|
|
POSIX: Subsections:
|
2019-02-06 08:50:35 +08:00
|
|
|
POSIX: - FileName: '/usr/src/pdb_lines_1.c'
|
|
|
|
POSIX: - FileName: '/usr/src/foo.h'
|
2018-10-13 01:26:19 +08:00
|
|
|
POSIX: - !FileChecksums
|
2019-02-06 08:50:35 +08:00
|
|
|
POSIX: - FileName: '/usr/src/pdb_lines_1.c'
|
|
|
|
POSIX: - FileName: '/usr/src/foo.h'
|
2018-10-13 01:26:19 +08:00
|
|
|
|
2019-02-06 08:50:35 +08:00
|
|
|
POSIX-LABEL: - Module: '/usr/src/pdb_lines_2_relative.obj'
|
|
|
|
POSIX-NEXT: ObjFile: '/usr/src/pdb_lines_2_relative.obj'
|
2018-10-13 01:26:19 +08:00
|
|
|
POSIX: SourceFiles:
|
2019-02-06 08:50:35 +08:00
|
|
|
POSIX-NEXT: - '/usr/src/pdb_lines_2.c'
|
2018-10-13 01:26:19 +08:00
|
|
|
POSIX: Subsections:
|
2019-02-06 08:50:35 +08:00
|
|
|
POSIX: - FileName: '/usr/src/pdb_lines_2.c'
|
2018-10-13 01:26:19 +08:00
|
|
|
POSIX: - !FileChecksums
|
2019-02-06 08:50:35 +08:00
|
|
|
POSIX: - FileName: '/usr/src/pdb_lines_2.c'
|
2018-10-13 01:26:19 +08:00
|
|
|
|
|
|
|
POSIX-LABEL: - Kind: S_ENVBLOCK
|
|
|
|
POSIX-NEXT: EnvBlockSym:
|
|
|
|
POSIX-NEXT: Entries:
|
|
|
|
POSIX-NEXT: - cwd
|
|
|
|
POSIX-NEXT: - '/usr/src'
|
|
|
|
POSIX-NEXT: - exe
|
2019-02-06 08:50:35 +08:00
|
|
|
POSIX-NEXT: - '/usr/src/lld-link'
|
2018-10-13 01:26:19 +08:00
|
|
|
POSIX-NEXT: - pdb
|
2019-02-06 08:50:35 +08:00
|
|
|
POSIX-NEXT: - '/usr/src/out.pdb'
|
2018-10-13 01:26:19 +08:00
|
|
|
POSIX-NEXT: - cmd
|
|
|
|
POSIX-NEXT: - '-debug -pdbsourcepath:/usr/src -entry:main -nodefaultlib -out:out.exe -pdb:out.pdb pdb_lines_1_relative.obj pdb_lines_2_relative.obj'
|