Investigate emitting less CodeView with -gline-tables-only for smaller PDBs
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
Consider:
`$ cat /tmp/a.cc`
```c++
struct S {
S(int x) : x(x) {}
int x;
};
S s() {
return S(42);
}
```
`$ build/bin/clang-cl /tmp/a.cc -gline-tables-only -fuse-ld=lld /LD /link /nodefaultlib /noentry`
With `-gline-tables-only` the PDB should only contain line numbers and symbol names (enough for back traces with line numbers basically), but it seems to include more type info and symbols than is strictly necessary(?). Could we strip it down further to reduce the size of such PDBs?
```console
$ build/bin/llvm-pdbutil dump --all a.pdb
...
Types (TPI Stream)
============================================================
Showing 6 records
0x1000 | LF_STRUCTURE [size = 24, hash = 0x1C6EB] `S`
vtable: , base list: , field list:
options: forward ref (= 0x1000), sizeof 0
0x1001 | LF_ARGLIST [size = 8, hash = 0x32484]
0x1002 | LF_PROCEDURE [size = 16, hash = 0x3481E]
return type = 0x1000, # args = 0, param list = 0x1001
calling conv = cdecl, options = returns cxx udt
0x1003 | LF_POINTER [size = 12, hash = 0xDD0C]
referent = 0x1000, mode = pointer, opts = const, kind = ptr64
0x1004 | LF_ARGLIST [size = 12, hash = 0x10ACA]
0x0074 (int): `int`
0x1005 | LF_MFUNCTION [size = 28, hash = 0xB970]
return type = 0x0003 (void), # args = 1, param list = 0x1004
class type = 0x1000, this type = 0x1003, this adjust = 0
calling conv = cdecl, options = constructor
...
Symbols
============================================================
Mod 0000 | `/tmp/a-237074.obj`:
4 | S_OBJNAME [size = 28] sig=0, `/tmp/a-237074.obj`
32 | S_COMPILE3 [size = 136]
machine = intel x86-x64, Ver = clang version 24.0.0git (https://github.com/llvm/llvm-project.git 54bc8999d9b533251e2464b5c0bb1f5925268041), language = c
++
frontend = 24.0.0.0, backend = 24000.0.0.0
flags = none
168 | S_GPROC32 [size = 44] `s`
parent = 0, end = 244, addr = 0001:0000, code size = 37
type = `0x1002 (S ())`, debug start = 0, debug end = 0, flags = noinline | opt debuginfo
212 | S_FRAMEPROC [size = 32]
size = 56, padding size = 0, offset to padding = 0
bytes of callee saved registers = 0, exception handler addr = 0000:0000
local fp reg = RSP, param fp reg = RSP
flags =
244 | S_END [size = 4]
248 | S_BUILDINFO [size = 8] BuildId = `0x1007`
256 | S_GPROC32 [size = 44] `S::S`
parent = 0, end = 332, addr = 0001:0048, code size = 27
type = `0x1005 (void S::(int))`, debug start = 0, debug end = 0, flags = noinline | opt debuginfo
300 | S_FRAMEPROC [size = 32]
size = 16, padding size = 0, offset to padding = 0
bytes of callee saved registers = 0, exception handler addr = 0000:0000
local fp reg = RSP, param fp reg = RSP
flags =
332 | S_END [size = 4]
```
Contributor guide
Research direction
Reproduce the example with clang-cl using -gline-tables-only, then inspect a.pdb with llvm-pdbutil dump --all. Trace how the shown CodeView type records and procedure symbols are emitted, and define done as a smaller PDB retaining the line numbers and symbol names needed for backtraces without unnecessary type information.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100