I created /home/amos/ld.lld-wrapper
with:
#!/bin/bash
ld.lld --time-trace --time-trace-file=/tmp/lld.time-trace.json "$@"
Then chmod +x ~/ld.lld-wrapper
, then in .cargo/config.toml
:
[target.x86_64-unknown-linux-gnu]
rustflags = [
"-C", "linker=clang",
"-C", "link-arg=-fuse-ld=/home/amos/ld.lld-wrapper",
]
Then modified one file in the main bin crate, then ran cargo b
.
Totals:
$ cat /tmp/lld.time-trace.json | jq -r '.traceEvents[] | select(.name|contains("Total")) | "\(.dur/1000000) \(.name)"'
1.027773 Total ExecuteLinker
1.022185 Total Link
0.384353 Total Write output file
0.218486 Total Parse input files
0.100983 Total Split sections
0.078876 Total Merge/finalize input sections
0.061676 Total Scan relocations
0.060593 Total markLive
0.032312 Total Assign sections
0.014814 Total Add symbols to symtabs
0.01353 Total Finalize synthetic sections
0.012774 Total Add local symbols
0.009789 Total Finalize .eh_frame
0.009781 Total Finalize address dependent content
0.008872 Total LTO
0.008632 Total Process symbol versions
0.005283 Total Load input files
0.004198 Total Aggregate sections
0.003046 Total Redirect symbols
0.002632 Total Combine EH sections
0.001508 Total Strip sections
0.001111 Total Sort sections
0.000756 Total Demote shared symbols
0.000754 Total Replace common symbols
0.000487 Total Locate library
0.000134 Total Create output files
7.4e-05 Total Read linker script
0 Total Resolve SHF_LINK_ORDER
0 Total Diagnose orphan sections
Write:
$ cat /tmp/lld.time-trace.json | jq -r '.traceEvents[] | select(.name|contains("Write")) | "\(.dur/1000000) \(.name) \(.args)"'
0.384354 Write output file null
0.384353 Total Write output file {"count":1,"avg ms":384}