[PATCH] Add an LTO interface to parse metadata and extract linker options
Yunzhong_Gao at playstation.sony.com
Fri Dec 20 19:07:57 PST 2013
Rebased the patch to trunk r197851.
After discussing with the linker team, I believe we have two important use
cases that need to be solved by extending the LTO plugin APIs.
First, we have game codes that use bitcode archives as argument to pragma
comment libs. In order to have knowledge of all symbol references, the linker
needs to add bitcode files included in the dependent libraries to its input
queue. And these bitcode files could in turn refer to more dependent libraries.
So there is an iterative process of scanning bitcode files for dependencies.
To be able to support bitcode archives simplifies the process of adding LTO to
existing build system. For example, say, there is a Makefile that generates an
intermediate library libfoo.a that is compiled out of source files liba.cpp and
libb.cpp and is referenced in a source file a.cpp with
#pragma comment(lib, "foo").
Without LTO, running "make all" will put native object files liba.o and libb.o
into libfoo.a. With LTO, running "make all CFLAGS=-flto" will put bitcode files
liba.o and libb.o into libfoo.a; there would be no need to change the Makefile.
Secondly, the libraries referenced in pragma comment lib need to be added to
the input queue to be scanned immediately after the current file. So, for
example, the link order would be different if the library dependencies are
extracted from a merged, post-LTO, object.
CHANGE SINCE LAST DIFF
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 9540 bytes
Desc: not available
More information about the llvm-commits