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

Yunzhong Gao 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.

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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D2343.3.patch
Type: text/x-patch
Size: 9540 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20131220/c9f011ba/attachment.bin>


More information about the llvm-commits mailing list