The clang -ftime-trace feature is useful for analysing build time in compiles. I've been experimenting with adding time-trace support to LLD for analysing link times.
Adding the option -time-trace produces a .json file alongside the output ELF file (just ELF so far). This works for LTO and ThinLTO, picking up the relevant markers from LLVM. Example ThinLTO build:
This is still work in progress so shouldn't be submitted in its present state. There are a few things that still need doing:
- Improve how events are collected. (The current method combines multiple threads (ThinLTO) in one stack with a mutex which won't scale well. Making this thread local would probably be better.)
- Adding test(s)
- Re-enable the assertion for monotonically increasing times which I don't have working yet.
Do people think that this will be useful/worth pursuing?
Could you possibly move this block (and the init block above) into a new file in lld/Common/ so we can use it in the COFF driver as well?