<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Tue, Jan 20, 2015 at 6:10 PM, Chandler Carruth <span dir="ltr"><<a href="mailto:chandlerc@google.com" target="_blank">chandlerc@google.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote"><span>On Tue, Jan 20, 2015 at 6:06 PM, Rui Ueyama <span dir="ltr"><<a href="mailto:ruiu@google.com" target="_blank">ruiu@google.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span>On Tue, Jan 20, 2015 at 5:42 PM, Chandler Carruth <span dir="ltr"><<a href="mailto:chandlerc@google.com" target="_blank">chandlerc@google.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote"><span>On Tue, Jan 20, 2015 at 5:35 PM, Nick Kledzik <span dir="ltr"><<a href="mailto:kledzik@apple.com" target="_blank">kledzik@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span>On Jan 19, 2015, at 6:33 PM, Chandler Carruth <<a href="mailto:chandlerc@google.com" target="_blank">chandlerc@google.com</a>> wrote:<br>
<br>
> I wanted to go through and map out the layering of LLD's libraries today and found that it's essentially impossible. I think some serious cleanup is needed here.<br>
><br>
> Let's start with the purely link-level dependencies encoded in the CMake build:<br>
><br>
> Curently the Core library depends on the ReaderWriter/Native library, which links against the ReaderWriter library, which links against the Core library. This clearly cannot work. The same cycle exists with Core -> YAML -> ReaderWrite -> Core.<br>
</span>How are you determining these cycles? How is Core dependent on YAML? (cause that seems wrong).<br></blockquote><div><br></div></span><div>This is in the CMake build system today. You can see it with CMakeLists.txt. Also you can look at Greg's patch for some of the issues here.</div></div></div></div></blockquote><div><br></div></span><div>It seems the dependency to lldYAML can be removed from CMakeList.txt now. Core doesn't actually depends on YAML.</div><div><br></div><div>lldPasses depends on libNative, and that dependency is currently resolved through lldCore transitively. We should be able to remove the dependency to libNative from Core by fixing Pass's CMake file.</div></blockquote><div><br></div></span><div>Cool, this makes lots of sense to me as well. We can probably fix these minor issues quickly.</div><div><br></div><div>Still, it would be good to get a firm big picture that everyone agrees to in place.</div><span><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><br></div><div>If my understanding is correct, the dependencies dependencies between components in LLD should be like this:</div><div><br></div><div>Config: (nothing)</div><div>Core: Config</div><div>Driver: Core Passes ReaderWriter</div><div>Passes: Core ReaderWriter</div><div>ReaderWriter: Core (and Driver?)</div><div><br></div><div>I don't want ReaderWriter to depend on Driver, but it may be unavoidable because of .drectve section in PE/COFF which contains command line options.</div></blockquote><div><br></div></span><div>Well, it *can't* depend on Driver if Driver depends on ReaderWriter.</div><span><div></div></span></div></div></div></blockquote><div><br></div><div>Oh that's true. Then the only thing we can do is to combine Driver and ReaderWriter to make it one library? It's far from ideal and feels wrong though.</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><span><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><br></div><div>ReaderWriter should be able to be split into smaller libraries because there's no cross-arch dependency between sub-directories in ReaderWriter.</div></blockquote></span></div><br>That would be nice. Can you sketch out what this would look like?</div></div></blockquote><div><br></div><div>Basically each sub-directory in lib/ReaderWriter should be able to become a separate library.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><br></div><div class="gmail_extra"><br></div><div class="gmail_extra">The other issue is that while the above makes sense to me, if you look at the #include lines in these libraries, it is *very* far from the truth. How do we fix this? In particular, the LinkingContext seems to establish a lot of circular dependencies.</div></div>
</blockquote></div></div><div class="gmail_extra"><br></div><div class="gmail_extra">Well that's not easy to answer without taking a closer look at the code, but I agree that the currently #include dependencies are nasty.</div><div class="gmail_extra"><br></div><div class="gmail_extra">One idea would be to move LinkingContext.h to Core while keeping all arch-specific LinkingContexts in ReaderWriter. I believe Core and Passes depends only on (generic) LinkingContext so we can remove dependency from Core/Passes to ReaderWriter by doing that.</div></div>