LLD, the LLVM linker, is a mature and fast linker supporting multiple binary formats (ELF, Mach-O, PE/COFF, WebAssembly). Designed as a standalone program, the code base relies heavily on global state, making it less than ideal for library integration. As outlined in RFC: Revisiting LLD-as-a-library design, two main hurdles exist:
I understand that calling a linker API could be convenient, especially when you want to avoid shipping another executable (which can be large when you linking against LLVM statically). However, I believe that invoking LLD as a separate process remains the recommended approach. There are several advantages:
While spawning a new process offers build system benefits, the issue of global state usage within LLD remains a concern. This is a factor to consider, especially for advanced use cases. Here are global variables in the LLD 15 code base.
LLD has been undergoing a transformation to reduce its reliance on global variables. This improves its suitability for library integration.