[PATCH] Add an LTO interface to parse metadata and extract linker options

Duncan P. N. Exon Smith dexonsmith at apple.com
Sun Jan 5 16:08:08 PST 2014


Thanks for the explanation; I understand the use case now.

LGTM, once you’ve satisfied Reid’s comments about string lifetime.

Duncan

P.S. Sorry for the long delay!

On 2013 Dec 20, at 19:07, Yunzhong Gao <Yunzhong_Gao at playstation.sony.com> wrote:

>  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.
> 
> http://llvm-reviews.chandlerc.com/D2343
> 
> CHANGE SINCE LAST DIFF
>  http://llvm-reviews.chandlerc.com/D2343?vs=5938&id=6220#toc
> 
> Files:
>  lib/LTO/LTOModule.cpp
>  lib/CodeGen/TargetLoweringObjectFileImpl.cpp
>  include/llvm/LTO/LTOModule.h
>  include/llvm/CodeGen/TargetLoweringObjectFileImpl.h
>  include/llvm/Target/TargetLoweringObjectFile.h
>  include/llvm-c/lto.h
>  tools/lto/lto.cpp
>  tools/lto/lto.exports
> <D2343.3.patch>_______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits





More information about the llvm-commits mailing list