Repository navigation
Description
Today we are generating native object .o files (x86/arm/etc) that we then pass out to the linker (lld/ld/link) - that means we need to be able to generate those native object files with the IREE binary and as such have to bring in all target backends (ARM/x86/wasm/etc) we want to support to our binary. Instead, using LTO lets us write LLVM bitcode files (the .o files we emit would just be .bc with a different extension) and then have the linker perform the actual code generation. Especially in cases where we will be statically linking our generated files together with other files (potentially other IREE outputs or user code) using LTO will give us critical benefits (deduping across all models compiled into the same binary, etc) but also mean that we can drop our iree-opt/iree-translate binary sizes/compile time by a significant amount.
LTO is compatible with lld and gold (with a plugin) on both linux and mac and I believe lld-link on Windows. We could keep the non-LTO path available as a CMake option for incompatible linkers (MSVC link, weird vendor linkers, etc) but strip it all out in most of our builds.
This post has good info: http://johanengelen.github.io/ldc/2016/11/10/Link-Time-Optimization-LDC.html (including how to work on linux/mac with gold and lld), and their linked PR has a lot of the LLVM object file manipulation we'd need: https://github.com/ldc-developers/ldc/pull/1840/files
This would entail:
- manually verify by tweaking LLVMAOTTarget.cpp which targets support it
- add an LTO cmake option and do not link in/include x86/arm/etc backends when enabled
- make LLVMAOTTarget.cpp use the cmake option (by way of a define) to choose how it emits object files (as writing LLVM bitcode and naming it a .o or by actually writing native object files)
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsNo status
Activity
benvanik commentedon Nov 5, 2020
Basically, I want these to be an order of magnitude smaller :)

benvanik commentedon Nov 20, 2020
Note that we need full LTO, not thin LTO. Thin LTO is useful if linking thousands of compilation units (and is akin to Microsoft's incremental linking (those .ilk files in the above screenshot); we are linking one file and want it to be as small/fast/etc as possible :)
relevant: rust-lang/rust#47745
good watch: https://www.youtube.com/watch?v=p9nH2vZ2mNo