This is an archive of the discontinued LLVM Phabricator instance.

Add DarwinInputGraph
ClosedPublic

Authored by kledzik on Oct 20 2014, 7:39 PM.

Details

Summary

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.

Diff Detail

Event Timeline

kledzik updated this revision to Diff 15162.Oct 20 2014, 7:39 PM
kledzik retitled this revision from to Add DarwinInputGraph .
kledzik updated this object.
kledzik edited the test plan for this revision. (Show Details)
kledzik added reviewers: shankarke, ruiu, t.p.northover.
kledzik added a subscriber: Unknown Object (MLST).
shankarke accepted this revision.Oct 20 2014, 7:58 PM
shankarke edited edge metadata.

LGTM.

This revision is now accepted and ready to land.Oct 20 2014, 7:58 PM
ruiu edited edge metadata.Oct 20 2014, 9:20 PM

I'm not still sure whether or not "InputGraph" thing was after all the right way to abstract the input file list. That often makes easy things hard. In this case, sorting a list of input files became that hard. When I proposed the idea I was thinking that would make this kind of things easier to handle. I don't think the current shape of the API is not desirable at least. Or the fundamental idea was not very good.

One thing we probably should consider is, in my opinion, we are pushing too hard to separate all ports. We are trying to write any architecture-dependent code into architecture-specific file. But the natural border of API doesn't always fit to the architecture dependent/independent border. We should probably relax that constraint a bit where that makes sense and write code that's short and easier to understand.

That being said, the InputGraph already exists there, and if I use that I'd do that way. This patch doesn't make things worse, so LGTM.

kledzik closed this revision.Oct 21 2014, 2:38 PM

committed in r220330