[PATCH] Add DarwinInputGraph

kledzik at apple.com kledzik at apple.com
Mon Oct 20 19:39:57 PDT 2014


Hi shankarke, ruiu, t.p.northover,

The darwin linker operates differently than the gnu linker with respect to libraries.  The darwin linker first links in all object files from the command line, then to resolve any remaining undefines, it repeatedly iterates over libraries on the command line until either all undefines are resolved or no undefines were resolved in the last pass.

When Shankar made the InputGraph model, the plan for darwin was for the darwin driver to place all libraries in a group at the end of the InputGraph. Thus making the darwin model a subset of the gnu model.  But it turns out that does not work because the driver cannot tell if a file is an object or library until it has been loaded, which happens later.  

My next thought was to "sort" the graph after all input files had been opened.  The problem with that is that a yaml file can contain a mix of object files and library files and there is no way to sort out the sub files of an InputElement.

This solution is to subclass InputGraph for darwin and just iterate the graph the way darwin linker needs.

BTW, I was hoping to also rework the graph walk to be more C++11 styled and use a separate iterator with begin/end.  But the notifyProgess() model does not fit in because it would need to be a method on the iterator object and C++11 hides that.

http://reviews.llvm.org/D5876

Files:
  include/lld/Core/InputGraph.h
  include/lld/Driver/DarwinInputGraph.h
  lib/Core/InputGraph.cpp
  lib/Driver/DarwinInputGraph.cpp
  lib/Driver/DarwinLdDriver.cpp
  test/mach-o/lib-search-paths.yaml
  test/mach-o/library-order.yaml
  test/mach-o/library-rescan.yaml
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D5876.15162.patch
Type: text/x-patch
Size: 10079 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20141021/05258414/attachment.bin>


More information about the llvm-commits mailing list