This patch adds support to clang, llvm, and lld for fat-lto-objects.
Fat LTO objects contain both LTO compatible IR, as well as generated
object code. This allows users to defer the choice of whether to use LTO
or not to link-time. This is a feature availble in GCC for some time,
and makes the existing -ffat-lto-objects flag functional in the same
way as GCC's.
This patch adds support for that flag in clang, as well as setting the
necessary codegen options for the backend. Within LLVM, we add a new
EmbedBitcodePass that serializes the module to the object file.
Lastly we add a new -fat-lto-objects flag to LLD, and slightly change
how it chooses input files in the driver when the flag is set.
Users are expected to pass -ffat-lto-objects to clang in addition to
one of the -flto variants. Without the -flto flag,
-ffat-lto-objects has no effect.
In LLD, if -ffat-lto-objects are enabled and the input files are fat
object files, then the linker will chose the LTO compatible bitcode
sections embedded within the fat object and link them together using
LTO. Otherwise, standard object file linking is done using the assembly
section in the object files.
Original RFC: https://discourse.llvm.org/t/rfc-ffat-lto-objects-support/63977
Do we just keep going if there's an error? This is only checking if there's not an error, right? or does takeError do more than I remember?