Page MenuHomePhabricator

Add -l option to llvm-link and allow linking by resolving symbols

Authored by rampitec on Apr 22 2014, 3:23 PM.



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).

Diff Detail

Event Timeline

rampitec updated this revision to Diff 8748.Apr 22 2014, 3:23 PM
rampitec retitled this revision from to Add -l option to llvm-link and allow linking by resolving symbols.
rampitec updated this object.
rampitec edited the test plan for this revision. (Show Details)
rampitec added a reviewer: arsenm.
rampitec added a subscriber: Unknown Object (MLST).
rampitec updated this revision to Diff 8808.Apr 24 2014, 9:24 AM

Added lit test, not other changes.

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.


rampitec abandoned this revision.May 11 2014, 8:27 PM

Discarding the diff due to general issue of the approach - initializers of eliminated globals may have side effects.