Skip to content

Commit cf76b19

Browse files
authored
Add doc for thinlto corpus extraction (#111)
1 parent 7e122fb commit cf76b19

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

docs/thinlto.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Extracting Corpora for ThinLTO-enabled Projects
2+
3+
These steps use inlining for size as an example.
4+
5+
## Generate the corpus
6+
7+
Pass `-thinlto-emit-index-files -save-temps=import` to lld, this will output `.3.import.bc`
8+
and `.thinlto.bc` files in your source directory.
9+
10+
## Consolidate the corpus
11+
12+
Run `tools/extract_ir.py` with `--thinlto_build=local` and set `--obj_base_dir`, `--output_dir`
13+
accordingly.
14+
15+
## Modify corpus_description.json
16+
17+
Modification of `corpus_description.json` which is written to `output_dir` is necessary. An error will
18+
be thrown if this is not done. \
19+
The `global_command_override` field in the json needs to be filled with the options to run
20+
**clang** with on each module. These options should be inferred from the lld command that generated the
21+
corpus. Most importantly, it should include "-c", some "-O" flag, relevant mllvm flags, and target/arch
22+
flags. \
23+
\
24+
Here's an example based on Chrome:
25+
```json
26+
{
27+
"global_command_override": [
28+
"-fPIC",
29+
"-mllvm",
30+
"-instcombine-lower-dbg-declare=0",
31+
"-mllvm",
32+
"-import-instr-limit=5",
33+
"-march=armv7-a",
34+
"--target=arm-linux-androideabi23",
35+
"-no-canonical-prefixes",
36+
"-O2",
37+
"-nostdlib++",
38+
"--sysroot=/path/to/linux-x86_64/sysroot",
39+
"-c"
40+
]
41+
}
42+
```

0 commit comments

Comments
 (0)