Currently llvm-link composes a target module by concatenation of all its input files. This change adds an option -l and ability to link in unresolved symbols only. If a module is specified without -l flag (as before) it will be linked in as a whole (as before).
Details
Diff Detail
Event Timeline
Why do you need this?
llvm-link is a developer tool *only*. In general I am very much
opposed to adding features to it unless you need them to write tests.
Changes to llvm-link are really small, most of the code is in the ResolveLinker.cpp. In fact our compiler uses this code for library linking with llvm-link being a secondary tool. Probably other llvm users can use it as well.
The "smart linking" is not a completely new concept for native linkers, even if library is organized in an archive. A big translation unit may have many symbols with just a few really needed. Even if we change our own libraries we could not stop developers from building large modules. Probably adding this as a mode for core linker would be not a best idea, but having this as a separate tool seems to be a good idea at least for me, especially if we already have this code.
Stas
Discarding the diff due to general issue of the approach - initializers of eliminated globals may have side effects.