<div dir="ltr">I'm still getting the same error even though I removed -dead_strip from the command line. Hmm, what's wrong...? Does it work for you?</div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Dec 8, 2014 at 10:33 PM, Jean-Daniel Dupas <span dir="ltr"><<a href="mailto:dev@xenonium.com" target="_blank">dev@xenonium.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word">AFAIK, this is a bug that occurs when dead_strip is enabled. Try to remove the -dead_strip argument and try again.<div><br></div><div><div><br><div><blockquote type="cite"><div>Le 8 déc. 2014 à 08:15, Rui Ueyama <<a href="mailto:ruiu@google.com" target="_blank">ruiu@google.com</a>> a écrit :</div><div><div class="h5"><br><div><div dir="ltr">I'm having trouble to link LLD using LLD on Darwin. Could you help me figure out what's wrong?<div><br></div><div>LLD aborts with the following error message</div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><p><span>warning: ignoring unknown argument: -search_paths_first<br></span>warning: ignoring unknown argument: -headerpad_max_install_names<br>Failed to write file 'bin/lld': Exec format error</p></div></blockquote><div>







<div>when I try to link LLD with the following command (../ld is stage 1 LLD executable)</div></div><div><br></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><div>$ ../ld "-demangle" "-dynamic" "-arch" "x86_64" "-macosx_version_min" "10.10.0" "-o" bin/lld "-search_paths_first" "-headerpad_max_install_names" "-dead_strip" "tools/lld/tools/lld/CMakeFiles/lld.dir/lld.cpp.o" "lib/liblldDriver.a" "lib/liblldPECOFF.a" "lib/liblldDriver.a" "lib/liblldPECOFF.a" "lib/liblldConfig.a" "lib/liblldMachO.a" "lib/liblldELF.a" "lib/liblldHexagonELFTarget.a" "lib/liblldMipsELFTarget.a" "lib/liblldPPCELFTarget.a" "lib/liblldX86ELFTarget.a" "lib/liblldX86_64ELFTarget.a" "lib/liblldAArch64ELFTarget.a" "lib/libLLVMOption.a" "lib/liblldPasses.a" "lib/liblldCore.a" "lib/liblldNative.a" "lib/liblldReaderWriter.a" "lib/liblldYAML.a" "lib/liblldPasses.a" "lib/liblldCore.a" "lib/liblldNative.a" "lib/liblldReaderWriter.a" "lib/liblldYAML.a" "lib/libLLVMObject.a" "lib/libLLVMBitReader.a" "lib/libLLVMCore.a" "lib/libLLVMMCParser.a" "lib/libLLVMMC.a" "lib/libLLVMSupport.a" "-lcurses" "-lpthread" "-lz" "-lm" "-lc++" "-lSystem" "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/6.0/lib/darwin/libclang_rt.osx.a"</div></div></blockquote><br><div>I got this command line by passing -### to Clang. I'm using the latest version of Xcode. LLVM/LLD is at head with no local patch (including this one).</div><div><br></div><div>Nick said that the LLD is now able to self-host it on Darwin. Is it still working?</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Dec 5, 2014 at 12:11 AM, Jean-Daniel Dupas <span dir="ltr"><<a href="mailto:dev@xenonium.com" target="_blank">dev@xenonium.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I think that change broke the Darwin linker.<br>
<br>
When trying to link executable using lld, I know have a lot of ‘undefined symbol’ error for symbols provided by (static) libraries.<br>
<br>
> Le 4 déc. 2014 à 02:09, Rui Ueyama <<a href="mailto:ruiu@google.com" target="_blank">ruiu@google.com</a>> a écrit :<br>
<div><div>><br>
> Author: ruiu<br>
> Date: Wed Dec  3 19:09:06 2014<br>
> New Revision: 223330<br>
><br>
> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=223330&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=223330&view=rev</a><br>
> Log:<br>
> Rewrite InputGraph's Group<br>
><br>
> The aim of this patch is to reduce the excessive abstraction from<br>
> the InputGraph. We found that even a simple thing, such as sorting<br>
> input files (Mach-O) or adding a new file to the input file list<br>
> (PE/COFF), is nearly impossible with the InputGraph abstraction,<br>
> because it hides too much information behind it. As a result,<br>
> we invented complex interactions between components (e.g.<br>
> notifyProgress() mechanism) and tricky code to work around that<br>
> limitation. There were many occasions that we needed to write<br>
> awkward code.<br>
><br>
> This patch is a first step to make it cleaner. As a first step,<br>
> this removes Group class from the InputGraph. The grouping feature<br>
> is now directly handled by the Resolver. notifyProgress is removed<br>
> since we no longer need that. I could have cleaned it up even more,<br>
> but in order to keep the patch minimum, I focused on Group.<br>
><br>
> SimpleFileNode class, a container of File objects, is now limited<br>
> to have only one File. We shold have done this earlier.<br>
> We used to allow putting multiple File objects to FileNode.<br>
> Although SimpleFileNode usually has only one file, the Driver class<br>
> actually used that capability. I modified the Driver class a bit,<br>
> so that one FileNode is created for each input File.<br>
><br>
> We should now probably remove SimpleFileNode and directly store<br>
> File objects to the InputGraph in some way, because a container<br>
> that can contain only one object is useless. This is a TODO.<br>
><br>
> Mach-O input files are now sorted before they are passe to the<br>
> Resolver. DarwinInputGraph class is no longer needed, so removed.<br>
><br>
> PECOFF still has hacky code to add a new file to the input file list.<br>
> This will be cleaned up in another patch.<br>
><br>
> Modified:<br>
>    lld/trunk/include/lld/Core/InputGraph.h<br>
>    lld/trunk/include/lld/Core/LinkingContext.h<br>
>    lld/trunk/include/lld/Core/Resolver.h<br>
>    lld/trunk/include/lld/Driver/DarwinInputGraph.h<br>
>    lld/trunk/include/lld/Driver/WinLinkInputGraph.h<br>
>    lld/trunk/include/lld/ReaderWriter/MachOLinkingContext.h<br>
>    lld/trunk/include/lld/ReaderWriter/PECOFFLinkingContext.h<br>
>    lld/trunk/lib/Core/InputGraph.cpp<br>
>    lld/trunk/lib/Core/Resolver.cpp<br>
>    lld/trunk/lib/Driver/DarwinInputGraph.cpp<br>
>    lld/trunk/lib/Driver/DarwinLdDriver.cpp<br>
>    lld/trunk/lib/Driver/Driver.cpp<br>
>    lld/trunk/lib/Driver/GnuLdDriver.cpp<br>
>    lld/trunk/lib/Driver/GnuLdInputGraph.cpp<br>
>    lld/trunk/lib/Driver/WinLinkDriver.cpp<br>
>    lld/trunk/lib/ReaderWriter/MachO/MachOLinkingContext.cpp<br>
>    lld/trunk/lib/ReaderWriter/PECOFF/PECOFFLinkingContext.cpp<br>
>    lld/trunk/unittests/DriverTests/DriverTest.h<br>
>    lld/trunk/unittests/DriverTests/InputGraphTest.cpp<br>
>    lld/trunk/unittests/DriverTests/WinLinkDriverTest.cpp<br>
><br>
> Modified: lld/trunk/include/lld/Core/InputGraph.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Core/InputGraph.h?rev=223330&r1=223329&r2=223330&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Core/InputGraph.h?rev=223330&r1=223329&r2=223330&view=diff</a><br>
> ==============================================================================<br>
> --- lld/trunk/include/lld/Core/InputGraph.h (original)<br>
> +++ lld/trunk/include/lld/Core/InputGraph.h Wed Dec  3 19:09:06 2014<br>
> @@ -59,12 +59,6 @@ public:<br>
>   /// assigned in the way files are resolved.<br>
>   virtual ErrorOr<File &> getNextFile();<br>
><br>
> -  /// Notifies the current input element of Resolver made some progress on<br>
> -  /// resolving undefined symbols using the current file. Group (representing<br>
> -  /// --start-group and --end-group) uses that notification to make a decision<br>
> -  /// whether it should iterate over again or terminate or not.<br>
> -  virtual void notifyProgress();<br>
> -<br>
>   /// Adds an observer of getNextFile(). Each time a new file is about to be<br>
>   /// returned from getNextFile(), registered observers are called with the file<br>
>   /// being returned.<br>
> @@ -76,14 +70,18 @@ public:<br>
>   /// \brief Adds a node at the beginning of the InputGraph<br>
>   void addInputElementFront(std::unique_ptr<InputElement>);<br>
><br>
> -  /// Normalize the InputGraph. It calls expand() on each node and then replace<br>
> -  /// it with getReplacements() results.<br>
> +  /// Normalize the InputGraph. It calls getReplacements() on each element.<br>
>   void normalize();<br>
><br>
> -  range<InputElementIterT> inputElements() {<br>
> -    return make_range(_inputArgs.begin(), _inputArgs.end());<br>
> +  InputElementVectorT &inputElements() {<br>
> +    return _inputArgs;<br>
>   }<br>
><br>
> +  // Returns the current group size if we are at an --end-group.<br>
> +  // Otherwise returns 0.<br>
> +  int getGroupSize();<br>
> +  void skipGroup();<br>
> +<br>
>   // \brief Returns the number of input files.<br>
>   size_t size() const { return _inputArgs.size(); }<br>
><br>
> @@ -108,8 +106,8 @@ class InputElement {<br>
> public:<br>
>   /// Each input element in the graph can be a File or a control<br>
>   enum class Kind : uint8_t {<br>
> -    Group,      // Represents a type associated with Group<br>
> -    File        // Represents a type associated with File Nodes<br>
> +    File,       // Represents a type associated with File Nodes<br>
> +    GroupEnd,<br>
>   };<br>
><br>
>   InputElement(Kind type) : _kind(type) {}<br>
> @@ -129,16 +127,9 @@ public:<br>
>   /// Get the next file to be processed by the resolver<br>
>   virtual ErrorOr<File &> getNextFile() = 0;<br>
><br>
> -  /// Refer InputGraph::notifyProgress(). By default, it does nothing. Only<br>
> -  /// Group is interested in this message.<br>
> -  virtual void notifyProgress() {};<br>
> -<br>
>   /// \brief Reset the next index<br>
>   virtual void resetNextIndex() = 0;<br>
><br>
> -  /// Returns true if we want to replace this node with children.<br>
> -  virtual void expand() {}<br>
> -<br>
>   /// Get the elements that we want to expand with.<br>
>   virtual bool getReplacements(InputGraph::InputElementVectorT &) {<br>
>     return false;<br>
> @@ -148,73 +139,31 @@ protected:<br>
>   Kind _kind; // The type of the Element<br>
> };<br>
><br>
> -/// \brief A Control node which contains a group of InputElements<br>
> -/// This affects the resolver so that it resolves undefined symbols<br>
> -/// in the group completely before looking at other input files that<br>
> -/// follow the group<br>
> -class Group : public InputElement {<br>
> +// This is a marker for --end-group. getSize() returns the number of<br>
> +// files between the corresponding --start-group and this marker.<br>
> +class GroupEnd : public InputElement {<br>
> public:<br>
> -  Group()<br>
> -      : InputElement(InputElement::Kind::Group), _currentElementIndex(0),<br>
> -        _nextElementIndex(0), _madeProgress(false) {}<br>
> +  GroupEnd(int size) : InputElement(Kind::GroupEnd), _size(size) {}<br>
><br>
> -  static inline bool classof(const InputElement *a) {<br>
> -    return a->kind() == InputElement::Kind::Group;<br>
> -  }<br>
> -<br>
> -  /// \brief Process input element and add it to the group<br>
> -  bool addFile(std::unique_ptr<InputElement> element) {<br>
> -    _elements.push_back(std::move(element));<br>
> -    return true;<br>
> -  }<br>
> +  int getSize() const { return _size; }<br>
><br>
> -  range<InputGraph::InputElementIterT> elements() {<br>
> -    return make_range(_elements.begin(), _elements.end());<br>
> -  }<br>
> -<br>
> -  void resetNextIndex() override {<br>
> -    _madeProgress = false;<br>
> -    _currentElementIndex = 0;<br>
> -    _nextElementIndex = 0;<br>
> -    for (std::unique_ptr<InputElement> &elem : _elements)<br>
> -      elem->resetNextIndex();<br>
> +  static inline bool classof(const InputElement *a) {<br>
> +    return a->kind() == Kind::GroupEnd;<br>
>   }<br>
><br>
>   /// \brief Parse the group members.<br>
>   std::error_code parse(const LinkingContext &ctx, raw_ostream &diag) override {<br>
> -    for (std::unique_ptr<InputElement> &ei : _elements)<br>
> -      if (std::error_code ec = ei->parse(ctx, diag))<br>
> -        return ec;<br>
>     return std::error_code();<br>
>   }<br>
><br>
> -  /// If Resolver made a progress using the current file, it's ok to revisit<br>
> -  /// files in this group in future.<br>
> -  void notifyProgress() override {<br>
> -    for (std::unique_ptr<InputElement> &elem : _elements)<br>
> -      elem->notifyProgress();<br>
> -    _madeProgress = true;<br>
> -  }<br>
> -<br>
> -  ErrorOr<File &> getNextFile() override;<br>
> -<br>
> -  void expand() override {<br>
> -    for (std::unique_ptr<InputElement> &elt : _elements)<br>
> -      elt->expand();<br>
> -    std::vector<std::unique_ptr<InputElement>> result;<br>
> -    for (std::unique_ptr<InputElement> &elt : _elements) {<br>
> -      if (elt->getReplacements(result))<br>
> -        continue;<br>
> -      result.push_back(std::move(elt));<br>
> -    }<br>
> -    _elements.swap(result);<br>
> +  ErrorOr<File &> getNextFile() override {<br>
> +    llvm_unreachable("shouldn't be here.");<br>
>   }<br>
><br>
> -protected:<br>
> -  InputGraph::InputElementVectorT _elements;<br>
> -  uint32_t _currentElementIndex;<br>
> -  uint32_t _nextElementIndex;<br>
> -  bool _madeProgress;<br>
> +  void resetNextIndex() override {}<br>
> +<br>
> +private:<br>
> +  int _size;<br>
> };<br>
><br>
> /// \brief Represents an Input file in the graph<br>
> @@ -252,6 +201,8 @@ public:<br>
><br>
>   /// \brief add a file to the list of files<br>
>   virtual void addFiles(InputGraph::FileVectorT files) {<br>
> +    assert(files.size() == 1);<br>
> +    assert(_files.empty());<br>
>     for (std::unique_ptr<File> &ai : files)<br>
>       _files.push_back(std::move(ai));<br>
>   }<br>
> @@ -260,6 +211,8 @@ public:<br>
>   /// the node again.<br>
>   void resetNextIndex() override { _nextFileIndex = 0; }<br>
><br>
> +  bool getReplacements(InputGraph::InputElementVectorT &result) override;<br>
> +<br>
> protected:<br>
>   /// \brief Read the file into _buffer.<br>
>   std::error_code getBuffer(StringRef filePath);<br>
> @@ -276,6 +229,10 @@ protected:<br>
> class SimpleFileNode : public FileNode {<br>
> public:<br>
>   SimpleFileNode(StringRef path) : FileNode(path) {}<br>
> +  SimpleFileNode(StringRef path, std::unique_ptr<File> f)<br>
> +      : FileNode(path) {<br>
> +    _files.push_back(std::move(f));<br>
> +  }<br>
><br>
>   virtual ~SimpleFileNode() {}<br>
><br>
><br>
> Modified: lld/trunk/include/lld/Core/LinkingContext.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Core/LinkingContext.h?rev=223330&r1=223329&r2=223330&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Core/LinkingContext.h?rev=223330&r1=223329&r2=223330&view=diff</a><br>
> ==============================================================================<br>
> --- lld/trunk/include/lld/Core/LinkingContext.h (original)<br>
> +++ lld/trunk/include/lld/Core/LinkingContext.h Wed Dec  3 19:09:06 2014<br>
> @@ -322,6 +322,10 @@ public:<br>
>   bool runRoundTripPass() const { return _runRoundTripPasses; }<br>
> #endif<br>
><br>
> +  // This function is called just before the Resolver kicks in.<br>
> +  // Derived classes may use that chance to rearrange the input files.<br>
> +  virtual void maybeSortInputFiles() {}<br>
> +<br>
>   /// @}<br>
> protected:<br>
>   LinkingContext(); // Must be subclassed<br>
><br>
> Modified: lld/trunk/include/lld/Core/Resolver.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Core/Resolver.h?rev=223330&r1=223329&r2=223330&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Core/Resolver.h?rev=223330&r1=223329&r2=223330&view=diff</a><br>
> ==============================================================================<br>
> --- lld/trunk/include/lld/Core/Resolver.h (original)<br>
> +++ lld/trunk/include/lld/Core/Resolver.h Wed Dec  3 19:09:06 2014<br>
> @@ -28,7 +28,8 @@ class LinkingContext;<br>
> class Resolver {<br>
> public:<br>
>   Resolver(LinkingContext &context)<br>
> -      : _context(context), _symbolTable(context), _result(new MergedFile()) {}<br>
> +      : _context(context), _symbolTable(context), _result(new MergedFile()),<br>
> +        _fileIndex(0) {}<br>
><br>
>   // InputFiles::Handler methods<br>
>   void doDefinedAtom(const DefinedAtom&);<br>
> @@ -38,10 +39,10 @@ public:<br>
><br>
>   // Handle files, this adds atoms from the current file thats<br>
>   // being processed by the resolver<br>
> -  void handleFile(const File &);<br>
> +  bool handleFile(const File &);<br>
><br>
>   // Handle an archive library file.<br>
> -  void handleArchiveFile(const File &);<br>
> +  bool handleArchiveFile(const File &);<br>
><br>
>   // Handle a shared library file.<br>
>   void handleSharedLibrary(const File &);<br>
> @@ -54,6 +55,9 @@ public:<br>
> private:<br>
>   typedef std::function<void(StringRef, bool)> UndefCallback;<br>
><br>
> +  bool undefinesAdded(int count);<br>
> +  ErrorOr<File &> nextFile(bool &inGroup);<br>
> +<br>
>   /// \brief Add section group/.gnu.linkonce if it does not exist previously.<br>
>   void maybeAddSectionGroupOrGnuLinkOnce(const DefinedAtom &atom);<br>
><br>
> @@ -110,6 +114,11 @@ private:<br>
>   llvm::DenseSet<const Atom *>  _deadAtoms;<br>
>   std::unique_ptr<MergedFile>   _result;<br>
>   llvm::DenseMap<const Atom *, llvm::DenseSet<const Atom *>> _reverseRef;<br>
> +<br>
> +  // --start-group and --end-group<br>
> +  std::vector<File *> _files;<br>
> +  std::map<File *, bool> _newUndefinesAdded;<br>
> +  size_t _fileIndex;<br>
> };<br>
><br>
> } // namespace lld<br>
><br>
> Modified: lld/trunk/include/lld/Driver/DarwinInputGraph.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Driver/DarwinInputGraph.h?rev=223330&r1=223329&r2=223330&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Driver/DarwinInputGraph.h?rev=223330&r1=223329&r2=223330&view=diff</a><br>
> ==============================================================================<br>
> --- lld/trunk/include/lld/Driver/DarwinInputGraph.h (original)<br>
> +++ lld/trunk/include/lld/Driver/DarwinInputGraph.h Wed Dec  3 19:09:06 2014<br>
> @@ -23,18 +23,6 @@<br>
><br>
> namespace lld {<br>
><br>
> -<br>
> -class DarwinInputGraph : public InputGraph {<br>
> -public:<br>
> -  DarwinInputGraph() : _librariesPhase(false), _repeatLibraries(false) { }<br>
> -  ErrorOr<File &> getNextFile() override;<br>
> -  void notifyProgress() override;<br>
> -private:<br>
> -  bool _librariesPhase;<br>
> -  bool _repeatLibraries;<br>
> -};<br>
> -<br>
> -<br>
> /// \brief Represents a MachO File<br>
> class MachOFileNode : public FileNode {<br>
> public:<br>
><br>
> Modified: lld/trunk/include/lld/Driver/WinLinkInputGraph.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Driver/WinLinkInputGraph.h?rev=223330&r1=223329&r2=223330&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Driver/WinLinkInputGraph.h?rev=223330&r1=223329&r2=223330&view=diff</a><br>
> ==============================================================================<br>
> --- lld/trunk/include/lld/Driver/WinLinkInputGraph.h (original)<br>
> +++ lld/trunk/include/lld/Driver/WinLinkInputGraph.h Wed Dec  3 19:09:06 2014<br>
> @@ -55,21 +55,6 @@ public:<br>
>   ErrorOr<StringRef> getPath(const LinkingContext &ctx) const override;<br>
> };<br>
><br>
> -/// \brief Represents a ELF control node<br>
> -class PECOFFGroup : public Group {<br>
> -public:<br>
> -  PECOFFGroup(PECOFFLinkingContext &ctx) : Group(), _ctx(ctx) {}<br>
> -<br>
> -  /// \brief Parse the group members.<br>
> -  std::error_code parse(const LinkingContext &ctx, raw_ostream &diag) override {<br>
> -    std::lock_guard<std::recursive_mutex> lock(_ctx.getMutex());<br>
> -    return Group::parse(ctx, diag);<br>
> -  }<br>
> -<br>
> -private:<br>
> -  PECOFFLinkingContext &_ctx;<br>
> -};<br>
> -<br>
> } // namespace lld<br>
><br>
> #endif<br>
><br>
> Modified: lld/trunk/include/lld/ReaderWriter/MachOLinkingContext.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/ReaderWriter/MachOLinkingContext.h?rev=223330&r1=223329&r2=223330&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/ReaderWriter/MachOLinkingContext.h?rev=223330&r1=223329&r2=223330&view=diff</a><br>
> ==============================================================================<br>
> --- lld/trunk/include/lld/ReaderWriter/MachOLinkingContext.h (original)<br>
> +++ lld/trunk/include/lld/ReaderWriter/MachOLinkingContext.h Wed Dec  3 19:09:06 2014<br>
> @@ -283,6 +283,8 @@ public:<br>
>   /// bits are xxxx.yy.zz.  Largest number is 65535.255.255<br>
>   static bool parsePackedVersion(StringRef str, uint32_t &result);<br>
><br>
> +  void maybeSortInputFiles() override;<br>
> +<br>
> private:<br>
>   Writer &writer() const override;<br>
>   mach_o::MachODylibFile* loadIndirectDylib(StringRef path);<br>
><br>
> Modified: lld/trunk/include/lld/ReaderWriter/PECOFFLinkingContext.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/ReaderWriter/PECOFFLinkingContext.h?rev=223330&r1=223329&r2=223330&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/ReaderWriter/PECOFFLinkingContext.h?rev=223330&r1=223329&r2=223330&view=diff</a><br>
> ==============================================================================<br>
> --- lld/trunk/include/lld/ReaderWriter/PECOFFLinkingContext.h (original)<br>
> +++ lld/trunk/include/lld/ReaderWriter/PECOFFLinkingContext.h Wed Dec  3 19:09:06 2014<br>
> @@ -29,7 +29,6 @@ using llvm::COFF::WindowsSubsystem;<br>
> static const uint8_t DEFAULT_DOS_STUB[128] = {'M', 'Z'};<br>
><br>
> namespace lld {<br>
> -class Group;<br>
><br>
> class PECOFFLinkingContext : public LinkingContext {<br>
> public:<br>
> @@ -315,8 +314,7 @@ public:<br>
>   void setEntryNode(SimpleFileNode *node) { _entryNode = node; }<br>
>   SimpleFileNode *getEntryNode() const { return _entryNode; }<br>
><br>
> -  void setLibraryGroup(Group *group) { _libraryGroup = group; }<br>
> -  Group *getLibraryGroup() const { return _libraryGroup; }<br>
> +  void addLibraryFile(std::unique_ptr<FileNode> file);<br>
><br>
>   void setModuleDefinitionFile(const std::string val) {<br>
>     _moduleDefinitionFile = val;<br>
> @@ -438,9 +436,6 @@ private:<br>
>   // The node containing the entry point file.<br>
>   SimpleFileNode *_entryNode;<br>
><br>
> -  // The PECOFFGroup that contains all the .lib files.<br>
> -  Group *_libraryGroup;<br>
> -<br>
>   // Name of the temporary file for lib.exe subcommand. For debugging<br>
>   // only.<br>
>   std::string _moduleDefinitionFile;<br>
><br>
> Modified: lld/trunk/lib/Core/InputGraph.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Core/InputGraph.cpp?rev=223330&r1=223329&r2=223330&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Core/InputGraph.cpp?rev=223330&r1=223329&r2=223330&view=diff</a><br>
> ==============================================================================<br>
> --- lld/trunk/lib/Core/InputGraph.cpp (original)<br>
> +++ lld/trunk/lib/Core/InputGraph.cpp Wed Dec  3 19:09:06 2014<br>
> @@ -36,8 +36,6 @@ ErrorOr<File &> InputGraph::getNextFile(<br>
>   }<br>
> }<br>
><br>
> -void InputGraph::notifyProgress() { _currentInputElement->notifyProgress(); }<br>
> -<br>
> void InputGraph::registerObserver(std::function<void(File *)> fn) {<br>
>   _observers.push_back(fn);<br>
> }<br>
> @@ -61,12 +59,13 @@ bool InputGraph::dump(raw_ostream &diagn<br>
> ErrorOr<InputElement *> InputGraph::getNextInputElement() {<br>
>   if (_nextElementIndex >= _inputArgs.size())<br>
>     return make_error_code(InputGraphError::no_more_elements);<br>
> -  return _inputArgs[_nextElementIndex++].get();<br>
> +  InputElement *elem = _inputArgs[_nextElementIndex++].get();<br>
> +  if (isa<GroupEnd>(elem))<br>
> +    return getNextInputElement();<br>
> +  return elem;<br>
> }<br>
><br>
> void InputGraph::normalize() {<br>
> -  for (std::unique_ptr<InputElement> &elt : _inputArgs)<br>
> -    elt->expand();<br>
>   std::vector<std::unique_ptr<InputElement>> vec;<br>
>   for (std::unique_ptr<InputElement> &elt : _inputArgs) {<br>
>     if (elt->getReplacements(vec))<br>
> @@ -76,6 +75,25 @@ void InputGraph::normalize() {<br>
>   _inputArgs = std::move(vec);<br>
> }<br>
><br>
> +// If we are at the end of a group, return its size (which indicates<br>
> +// how many files we need to go back in the command line).<br>
> +// Returns 0 if we are not at the end of a group.<br>
> +int InputGraph::getGroupSize() {<br>
> +  if (_nextElementIndex >= _inputArgs.size())<br>
> +    return 0;<br>
> +  InputElement *elem = _inputArgs[_nextElementIndex].get();<br>
> +  if (const GroupEnd *group = dyn_cast<GroupEnd>(elem))<br>
> +    return group->getSize();<br>
> +  return 0;<br>
> +}<br>
> +<br>
> +void InputGraph::skipGroup() {<br>
> +  if (_nextElementIndex >= _inputArgs.size())<br>
> +    return;<br>
> +  if (isa<GroupEnd>(_inputArgs[_nextElementIndex].get()))<br>
> +    _nextElementIndex++;<br>
> +}<br>
> +<br>
> /// \brief Read the file into _buffer.<br>
> std::error_code FileNode::getBuffer(StringRef filePath) {<br>
>   // Create a memory buffer<br>
> @@ -87,32 +105,10 @@ std::error_code FileNode::getBuffer(Stri<br>
>   return std::error_code();<br>
> }<br>
><br>
> -/// \brief Return the next file that need to be processed by the resolver.<br>
> -/// This also processes input elements depending on the resolve status<br>
> -/// of the input elements contained in the group.<br>
> -ErrorOr<File &> Group::getNextFile() {<br>
> -  // If there are no elements, move on to the next input element<br>
> -  if (_elements.empty())<br>
> -    return make_error_code(InputGraphError::no_more_files);<br>
> -<br>
> -  for (;;) {<br>
> -    // If we have processed all the elements, and have made no progress on<br>
> -    // linking, we cannot resolve any symbol from this group. Continue to the<br>
> -    // next one by returning no_more_files.<br>
> -    if (_nextElementIndex == _elements.size()) {<br>
> -      if (!_madeProgress)<br>
> -        return make_error_code(InputGraphError::no_more_files);<br>
> -      resetNextIndex();<br>
> -    }<br>
> -<br>
> -    _currentElementIndex = _nextElementIndex;<br>
> -    auto file = _elements[_nextElementIndex]->getNextFile();<br>
> -    // Move on to the next element if we have finished processing all<br>
> -    // the files in the input element<br>
> -    if (file.getError() == InputGraphError::no_more_files) {<br>
> -      _nextElementIndex++;<br>
> -      continue;<br>
> -    }<br>
> -    return *file;<br>
> -  }<br>
> +bool FileNode::getReplacements(InputGraph::InputElementVectorT &result) {<br>
> +  if (_files.size() < 2)<br>
> +    return false;<br>
> +  for (std::unique_ptr<File> &file : _files)<br>
> +    result.push_back(llvm::make_unique<SimpleFileNode>(_path, std::move(file)));<br>
> +  return true;<br>
> }<br>
><br>
> Modified: lld/trunk/lib/Core/Resolver.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Core/Resolver.cpp?rev=223330&r1=223329&r2=223330&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Core/Resolver.cpp?rev=223330&r1=223329&r2=223330&view=diff</a><br>
> ==============================================================================<br>
> --- lld/trunk/lib/Core/Resolver.cpp (original)<br>
> +++ lld/trunk/lib/Core/Resolver.cpp Wed Dec  3 19:09:06 2014<br>
> @@ -27,7 +27,7 @@<br>
><br>
> namespace lld {<br>
><br>
> -void Resolver::handleFile(const File &file) {<br>
> +bool Resolver::handleFile(const File &file) {<br>
>   bool undefAdded = false;<br>
>   for (const DefinedAtom *atom : file.defined())<br>
>     doDefinedAtom(*atom);<br>
> @@ -38,13 +38,7 @@ void Resolver::handleFile(const File &fi<br>
>     doSharedLibraryAtom(*atom);<br>
>   for (const AbsoluteAtom *atom : file.absolute())<br>
>     doAbsoluteAtom(*atom);<br>
> -<br>
> -  // Notify the input file manager of the fact that we have made some progress<br>
> -  // on linking using the current input file. It may want to know the fact for<br>
> -  // --start-group/--end-group.<br>
> -  if (undefAdded) {<br>
> -    _context.getInputGraph().notifyProgress();<br>
> -  }<br>
> +  return undefAdded;<br>
> }<br>
><br>
> void Resolver::forEachUndefines(bool searchForOverrides,<br>
> @@ -76,17 +70,19 @@ void Resolver::forEachUndefines(bool sea<br>
>   } while (undefineGenCount != _symbolTable.size());<br>
> }<br>
><br>
> -void Resolver::handleArchiveFile(const File &file) {<br>
> +bool Resolver::handleArchiveFile(const File &file) {<br>
>   const ArchiveLibraryFile *archiveFile = cast<ArchiveLibraryFile>(&file);<br>
>   bool searchForOverrides =<br>
>       _context.searchArchivesToOverrideTentativeDefinitions();<br>
> +  bool undefAdded = false;<br>
>   forEachUndefines(searchForOverrides,<br>
>                    [&](StringRef undefName, bool dataSymbolOnly) {<br>
>     if (const File *member = archiveFile->find(undefName, dataSymbolOnly)) {<br>
>       member->setOrdinal(_context.getNextOrdinalAndIncrement());<br>
> -      handleFile(*member);<br>
> +      undefAdded = undefAdded || handleFile(*member);<br>
>     }<br>
>   });<br>
> +  return undefAdded;<br>
> }<br>
><br>
> void Resolver::handleSharedLibrary(const File &file) {<br>
> @@ -233,31 +229,66 @@ void Resolver::addAtoms(const std::vecto<br>
>     doDefinedAtom(*newAtom);<br>
> }<br>
><br>
> +// Returns true if at least one of N previous files has created an<br>
> +// undefined symbol.<br>
> +bool Resolver::undefinesAdded(int n) {<br>
> +  for (size_t i = _fileIndex - n; i < _fileIndex; ++i)<br>
> +    if (_newUndefinesAdded[_files[i]])<br>
> +      return true;<br>
> +  return false;<br>
> +}<br>
> +<br>
> +ErrorOr<File &> Resolver::nextFile(bool &inGroup) {<br>
> +  if (size_t groupSize = _context.getInputGraph().getGroupSize()) {<br>
> +    // We are at the end of the current group. If one or more new<br>
> +    // undefined atom has been added in the last groupSize files, we<br>
> +    // reiterate over the files.<br>
> +    if (undefinesAdded(groupSize))<br>
> +      _fileIndex -= groupSize;<br>
> +    _context.getInputGraph().skipGroup();<br>
> +    return nextFile(inGroup);<br>
> +  }<br>
> +  if (_fileIndex < _files.size()) {<br>
> +    // We are still in the current group.<br>
> +    inGroup = true;<br>
> +    return *_files[_fileIndex++];<br>
> +  }<br>
> +  // We are not in a group. Get a new file.<br>
> +  ErrorOr<File &> file = _context.getInputGraph().getNextFile();<br>
> +  if (std::error_code ec = file.getError()) {<br>
> +    if (ec != InputGraphError::no_more_files)<br>
> +      llvm::errs() << "Error occurred in getNextFile: " << ec.message() << "\n";<br>
> +    return ec;<br>
> +  }<br>
> +  _files.push_back(&*file);<br>
> +  ++_fileIndex;<br>
> +  inGroup = false;<br>
> +  return *file;<br>
> +}<br>
> +<br>
> // Keep adding atoms until _context.getNextFile() returns an error. This<br>
> // function is where undefined atoms are resolved.<br>
> bool Resolver::resolveUndefines() {<br>
>   ScopedTask task(getDefaultDomain(), "resolveUndefines");<br>
><br>
>   for (;;) {<br>
> -    ErrorOr<File &> file = _context.getInputGraph().getNextFile();<br>
> -    std::error_code ec = file.getError();<br>
> -    if (ec == InputGraphError::no_more_files)<br>
> -      return true;<br>
> -    if (!file) {<br>
> -      llvm::errs() << "Error occurred in getNextFile: " << ec.message() << "\n";<br>
> -      return false;<br>
> -    }<br>
> -<br>
> +    bool inGroup = false;<br>
> +    bool undefAdded = false;<br>
> +    ErrorOr<File &> file = nextFile(inGroup);<br>
> +    if (std::error_code ec = file.getError())<br>
> +      return ec == InputGraphError::no_more_files;<br>
>     switch (file->kind()) {<br>
>     case File::kindObject:<br>
> +      if (inGroup)<br>
> +        break;<br>
>       assert(!file->hasOrdinal());<br>
>       file->setOrdinal(_context.getNextOrdinalAndIncrement());<br>
> -      handleFile(*file);<br>
> +      undefAdded = handleFile(*file);<br>
>       break;<br>
>     case File::kindArchiveLibrary:<br>
>       if (!file->hasOrdinal())<br>
>         file->setOrdinal(_context.getNextOrdinalAndIncrement());<br>
> -      handleArchiveFile(*file);<br>
> +      undefAdded = handleArchiveFile(*file);<br>
>       break;<br>
>     case File::kindSharedLibrary:<br>
>       if (!file->hasOrdinal())<br>
> @@ -265,6 +296,7 @@ bool Resolver::resolveUndefines() {<br>
>       handleSharedLibrary(*file);<br>
>       break;<br>
>     }<br>
> +    _newUndefinesAdded[&*file] = undefAdded;<br>
>   }<br>
> }<br>
><br>
><br>
> Modified: lld/trunk/lib/Driver/DarwinInputGraph.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/DarwinInputGraph.cpp?rev=223330&r1=223329&r2=223330&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/DarwinInputGraph.cpp?rev=223330&r1=223329&r2=223330&view=diff</a><br>
> ==============================================================================<br>
> --- lld/trunk/lib/Driver/DarwinInputGraph.cpp (original)<br>
> +++ lld/trunk/lib/Driver/DarwinInputGraph.cpp Wed Dec  3 19:09:06 2014<br>
> @@ -18,48 +18,6 @@<br>
> namespace lld {<br>
><br>
><br>
> -ErrorOr<File &> DarwinInputGraph::getNextFile() {<br>
> -  // The darwin linker processes input files in two phases.  The first phase<br>
> -  // links in all object (.o) files in command line order. The second phase<br>
> -  // links in libraries in command line order. If there are still UndefinedAtoms<br>
> -  // the second phase is repeated until notifyProgress() is not called by<br>
> -  // resolver.<br>
> -  for (;;) {<br>
> -    if (_currentInputElement) {<br>
> -      for(;;) {<br>
> -        ErrorOr<File &> next = _currentInputElement->getNextFile();<br>
> -        if (next.getError())<br>
> -          break;<br>
> -        File *file = &next.get();<br>
> -        bool fileIsLibrary = isa<SharedLibraryFile>(file) ||<br>
> -                             isa<ArchiveLibraryFile>(file);<br>
> -        if (fileIsLibrary == _librariesPhase) {<br>
> -          // Return library in library phase and object files in non-lib mode.<br>
> -          return *file;<br>
> -        }<br>
> -      }<br>
> -    }<br>
> -<br>
> -    if (_nextElementIndex >= _inputArgs.size()) {<br>
> -      // If no more elements, done unless we need to repeat library scan.<br>
> -      if (_librariesPhase && !_repeatLibraries)<br>
> -        return make_error_code(InputGraphError::no_more_files);<br>
> -      // Clear iterations and only look for libraries.<br>
> -      _librariesPhase = true;<br>
> -      _repeatLibraries = false;<br>
> -      _nextElementIndex = 0;<br>
> -      for (auto &ie : _inputArgs) {<br>
> -        ie->resetNextIndex();<br>
> -      }<br>
> -    }<br>
> -    _currentInputElement = _inputArgs[_nextElementIndex++].get();<br>
> -  }<br>
> -}<br>
> -<br>
> -void DarwinInputGraph::notifyProgress() {<br>
> -  _repeatLibraries = true;<br>
> -}<br>
> -<br>
> /// \brief Parse the input file to lld::File.<br>
> std::error_code MachOFileNode::parse(const LinkingContext &ctx,<br>
>                                      raw_ostream &diagnostics)  {<br>
><br>
> Modified: lld/trunk/lib/Driver/DarwinLdDriver.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/DarwinLdDriver.cpp?rev=223330&r1=223329&r2=223330&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/DarwinLdDriver.cpp?rev=223330&r1=223329&r2=223330&view=diff</a><br>
> ==============================================================================<br>
> --- lld/trunk/lib/Driver/DarwinLdDriver.cpp (original)<br>
> +++ lld/trunk/lib/Driver/DarwinLdDriver.cpp Wed Dec  3 19:09:06 2014<br>
> @@ -83,7 +83,7 @@ static std::string canonicalizePath(Stri<br>
>   }<br>
> }<br>
><br>
> -static void addFile(StringRef path, std::unique_ptr<DarwinInputGraph> &inputGraph,<br>
> +static void addFile(StringRef path, std::unique_ptr<InputGraph> &inputGraph,<br>
>                     MachOLinkingContext &ctx, bool loadWholeArchive,<br>
>                     bool upwardDylib) {<br>
>   auto node = llvm::make_unique<MachOFileNode>(path, ctx);<br>
> @@ -185,7 +185,7 @@ static std::error_code parseOrderFile(St<br>
> // per line. The <dir> prefix is prepended to each partial path.<br>
> //<br>
> static std::error_code parseFileList(StringRef fileListPath,<br>
> -                                     std::unique_ptr<DarwinInputGraph> &inputGraph,<br>
> +                                     std::unique_ptr<InputGraph> &inputGraph,<br>
>                                      MachOLinkingContext &ctx, bool forceLoad,<br>
>                                      raw_ostream &diagnostics) {<br>
>   // If there is a comma, split off <dir>.<br>
> @@ -521,7 +521,7 @@ bool DarwinLdDriver::parse(int argc, con<br>
>     }<br>
>   }<br>
><br>
> -  std::unique_ptr<DarwinInputGraph> inputGraph(new DarwinInputGraph());<br>
> +  std::unique_ptr<InputGraph> inputGraph(new InputGraph());<br>
><br>
>   // Now construct the set of library search directories, following ld64's<br>
>   // baroque set of accumulated hacks. Mostly, the algorithm constructs<br>
><br>
> Modified: lld/trunk/lib/Driver/Driver.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/Driver.cpp?rev=223330&r1=223329&r2=223330&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/Driver.cpp?rev=223330&r1=223329&r2=223330&view=diff</a><br>
> ==============================================================================<br>
> --- lld/trunk/lib/Driver/Driver.cpp (original)<br>
> +++ lld/trunk/lib/Driver/Driver.cpp Wed Dec  3 19:09:06 2014<br>
> @@ -62,9 +62,6 @@ bool Driver::link(LinkingContext &contex<br>
>       if (std::error_code ec = ie->parse(context, stream)) {<br>
>         if (FileNode *fileNode = dyn_cast<FileNode>(ie.get()))<br>
>           stream << fileNode->errStr(ec) << "\n";<br>
> -        else if (dyn_cast<Group>(ie.get()))<br>
> -          // FIXME: We need a better diagnostics here<br>
> -          stream << "Cannot parse group input element\n";<br>
>         else<br>
>           llvm_unreachable("Unknown type of input element");<br>
>         fail = true;<br>
> @@ -83,21 +80,24 @@ bool Driver::link(LinkingContext &contex<br>
>   if (fail)<br>
>     return false;<br>
><br>
> -  std::unique_ptr<SimpleFileNode> fileNode(<br>
> -      new SimpleFileNode("Internal Files"));<br>
> -<br>
>   InputGraph::FileVectorT internalFiles;<br>
>   context.createInternalFiles(internalFiles);<br>
> -<br>
> -  if (internalFiles.size())<br>
> -    fileNode->addFiles(std::move(internalFiles));<br>
> +  for (auto i = internalFiles.rbegin(), e = internalFiles.rend(); i != e; ++i) {<br>
> +    context.getInputGraph().addInputElementFront(<br>
> +        llvm::make_unique<SimpleFileNode>("internal", std::move(*i)));<br>
> +  }<br>
><br>
>   // Give target a chance to add files.<br>
>   InputGraph::FileVectorT implicitFiles;<br>
>   context.createImplicitFiles(implicitFiles);<br>
> -  if (implicitFiles.size())<br>
> -    fileNode->addFiles(std::move(implicitFiles));<br>
> -  context.getInputGraph().addInputElementFront(std::move(fileNode));<br>
> +  for (auto i = implicitFiles.rbegin(), e = implicitFiles.rend(); i != e; ++i) {<br>
> +    context.getInputGraph().addInputElementFront(<br>
> +        llvm::make_unique<SimpleFileNode>("implicit", std::move(*i)));<br>
> +  }<br>
> +<br>
> +  // Give target a chance to sort the input files.<br>
> +  // Mach-O uses this chance to move all object files before library files.<br>
> +  context.maybeSortInputFiles();<br>
><br>
>   // Do core linking.<br>
>   ScopedTask resolveTask(getDefaultDomain(), "Resolve");<br>
><br>
> Modified: lld/trunk/lib/Driver/GnuLdDriver.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/GnuLdDriver.cpp?rev=223330&r1=223329&r2=223330&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/GnuLdDriver.cpp?rev=223330&r1=223329&r2=223330&view=diff</a><br>
> ==============================================================================<br>
> --- lld/trunk/lib/Driver/GnuLdDriver.cpp (original)<br>
> +++ lld/trunk/lib/Driver/GnuLdDriver.cpp Wed Dec  3 19:09:06 2014<br>
> @@ -295,7 +295,8 @@ bool GnuLdDriver::parse(int argc, const<br>
>   }<br>
><br>
>   std::unique_ptr<InputGraph> inputGraph(new InputGraph());<br>
> -  std::stack<Group *> groupStack;<br>
> +  std::stack<int> groupStack;<br>
> +  int numfiles = 0;<br>
><br>
>   ELFFileNode::Attributes attributes;<br>
><br>
> @@ -468,16 +469,21 @@ bool GnuLdDriver::parse(int argc, const<br>
>       break;<br>
>     }<br>
><br>
> -    case OPT_start_group: {<br>
> -      std::unique_ptr<Group> group(new Group());<br>
> -      groupStack.push(group.get());<br>
> -      inputGraph->addInputElement(std::move(group));<br>
> +    case OPT_start_group:<br>
> +      groupStack.push(numfiles);<br>
>       break;<br>
> -    }<br>
><br>
> -    case OPT_end_group:<br>
> +    case OPT_end_group: {<br>
> +      if (groupStack.empty()) {<br>
> +        diagnostics << "stray --end-group\n";<br>
> +        return false;<br>
> +      }<br>
> +      int startGroupPos = groupStack.top();<br>
> +      inputGraph->addInputElement(<br>
> +          llvm::make_unique<GroupEnd>(numfiles - startGroupPos));<br>
>       groupStack.pop();<br>
>       break;<br>
> +    }<br>
><br>
>     case OPT_z: {<br>
>       StringRef extOpt = inputArg->getValue();<br>
> @@ -552,11 +558,8 @@ bool GnuLdDriver::parse(int argc, const<br>
>         }<br>
>       }<br>
>       std::unique_ptr<InputElement> inputFile(inputNode);<br>
> -      if (groupStack.empty()) {<br>
> -        inputGraph->addInputElement(std::move(inputFile));<br>
> -      } else {<br>
> -        groupStack.top()->addFile(std::move(inputFile));<br>
> -      }<br>
> +      ++numfiles;<br>
> +      inputGraph->addInputElement(std::move(inputFile));<br>
>       break;<br>
>     }<br>
><br>
><br>
> Modified: lld/trunk/lib/Driver/GnuLdInputGraph.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/GnuLdInputGraph.cpp?rev=223330&r1=223329&r2=223330&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/GnuLdInputGraph.cpp?rev=223330&r1=223329&r2=223330&view=diff</a><br>
> ==============================================================================<br>
> --- lld/trunk/lib/Driver/GnuLdInputGraph.cpp (original)<br>
> +++ lld/trunk/lib/Driver/GnuLdInputGraph.cpp Wed Dec  3 19:09:06 2014<br>
> @@ -91,7 +91,7 @@ std::error_code ELFGNULdScript::parse(co<br>
>     auto *group = dyn_cast<script::Group>(c);<br>
>     if (!group)<br>
>       continue;<br>
> -    std::unique_ptr<Group> groupStart(new Group());<br>
> +    size_t numfiles = 0;<br>
>     for (const script::Path &path : group->getPaths()) {<br>
>       // TODO : Propagate Set WholeArchive/dashlPrefix<br>
>       attributes.setAsNeeded(path._asNeeded);<br>
> @@ -100,9 +100,10 @@ std::error_code ELFGNULdScript::parse(co<br>
>           _elfLinkingContext, _elfLinkingContext.allocateString(path._path),<br>
>           attributes);<br>
>       std::unique_ptr<InputElement> inputFile(inputNode);<br>
> -      groupStart.get()->addFile(std::move(inputFile));<br>
> +      _expandElements.push_back(std::move(inputFile));<br>
> +      ++numfiles;<br>
>     }<br>
> -    _expandElements.push_back(std::move(groupStart));<br>
> +    _expandElements.push_back(llvm::make_unique<GroupEnd>(numfiles));<br>
>   }<br>
>   return std::error_code();<br>
> }<br>
><br>
> Modified: lld/trunk/lib/Driver/WinLinkDriver.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/WinLinkDriver.cpp?rev=223330&r1=223329&r2=223330&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/WinLinkDriver.cpp?rev=223330&r1=223329&r2=223330&view=diff</a><br>
> ==============================================================================<br>
> --- lld/trunk/lib/Driver/WinLinkDriver.cpp (original)<br>
> +++ lld/trunk/lib/Driver/WinLinkDriver.cpp Wed Dec  3 19:09:06 2014<br>
> @@ -781,7 +781,7 @@ static bool hasLibrary(const PECOFFLinki<br>
>   ErrorOr<StringRef> path = fileNode->getPath(ctx);<br>
>   if (!path)<br>
>     return false;<br>
> -  for (std::unique_ptr<InputElement> &p : ctx.getLibraryGroup()->elements())<br>
> +  for (std::unique_ptr<InputElement> &p : ctx.getInputGraph().inputElements())<br>
>     if (auto *f = dyn_cast<FileNode>(p.get()))<br>
>       if (*path == *f->getPath(ctx))<br>
>         return true;<br>
> @@ -1397,10 +1397,8 @@ bool WinLinkDriver::parse(int argc, cons<br>
>     ctx.setEntryNode(entry.get());<br>
>     ctx.getInputGraph().addInputElement(std::move(entry));<br>
><br>
> -    // The container for all library files.<br>
> -    std::unique_ptr<Group> group(new PECOFFGroup(ctx));<br>
> -    ctx.setLibraryGroup(group.get());<br>
> -    ctx.getInputGraph().addInputElement(std::move(group));<br>
> +    // Add a group-end marker.<br>
> +    ctx.getInputGraph().addInputElement(llvm::make_unique<GroupEnd>(0));<br>
>   }<br>
><br>
>   // Add the library files to the library group.<br>
> @@ -1409,7 +1407,7 @@ bool WinLinkDriver::parse(int argc, cons<br>
>       if (isReadingDirectiveSection)<br>
>         if (lib->parse(ctx, diag))<br>
>           return false;<br>
> -      ctx.getLibraryGroup()->addFile(std::move(lib));<br>
> +      ctx.addLibraryFile(std::move(lib));<br>
>     }<br>
>   }<br>
><br>
><br>
> Modified: lld/trunk/lib/ReaderWriter/MachO/MachOLinkingContext.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/MachOLinkingContext.cpp?rev=223330&r1=223329&r2=223330&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/MachOLinkingContext.cpp?rev=223330&r1=223329&r2=223330&view=diff</a><br>
> ==============================================================================<br>
> --- lld/trunk/lib/ReaderWriter/MachO/MachOLinkingContext.cpp (original)<br>
> +++ lld/trunk/lib/ReaderWriter/MachO/MachOLinkingContext.cpp Wed Dec  3 19:09:06 2014<br>
> @@ -22,6 +22,7 @@<br>
> #include "llvm/ADT/Triple.h"<br>
> #include "llvm/Config/config.h"<br>
> #include "llvm/Support/Errc.h"<br>
> +#include "llvm/Support/Debug.h"<br>
> #include "llvm/Support/Host.h"<br>
> #include "llvm/Support/MachO.h"<br>
> #include "llvm/Support/Path.h"<br>
> @@ -923,4 +924,35 @@ bool MachOLinkingContext::customAtomOrde<br>
>   return true;<br>
> }<br>
><br>
> +static File *getFirstFile(const std::unique_ptr<InputElement> &elem) {<br>
> +  FileNode *e = dyn_cast<FileNode>(const_cast<InputElement *>(elem.get()));<br>
> +  if (!e || e->files().empty())<br>
> +    return nullptr;<br>
> +  return e->files()[0].get();<br>
> +}<br>
> +<br>
> +static bool isLibrary(const std::unique_ptr<InputElement> &elem) {<br>
> +  File *f = getFirstFile(elem);<br>
> +  return f && (isa<SharedLibraryFile>(f) || isa<ArchiveLibraryFile>(f));<br>
> +}<br>
> +<br>
> +// The darwin linker processes input files in two phases.  The first phase<br>
> +// links in all object (.o) files in command line order. The second phase<br>
> +// links in libraries in command line order.<br>
> +// In this function we reorder the input files so that all the object files<br>
> +// comes before any library file. We also make a group for the library files<br>
> +// so that the Resolver will reiterate over the libraries as long as we find<br>
> +// new undefines from libraries.<br>
> +void MachOLinkingContext::maybeSortInputFiles() {<br>
> +  std::vector<std::unique_ptr<InputElement>> &elements<br>
> +      = getInputGraph().inputElements();<br>
> +  std::stable_sort(elements.begin(), elements.end(),<br>
> +                   [](const std::unique_ptr<InputElement> &a,<br>
> +                      const std::unique_ptr<InputElement> &b) {<br>
> +                     return !isLibrary(a) && isLibrary(b);<br>
> +                   });<br>
> +  size_t numLibs = std::count_if(elements.begin(), elements.end(), isLibrary);<br>
> +  elements.push_back(llvm::make_unique<GroupEnd>(numLibs));<br>
> +}<br>
> +<br>
> } // end namespace lld<br>
><br>
> Modified: lld/trunk/lib/ReaderWriter/PECOFF/PECOFFLinkingContext.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/PECOFF/PECOFFLinkingContext.cpp?rev=223330&r1=223329&r2=223330&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/PECOFF/PECOFFLinkingContext.cpp?rev=223330&r1=223329&r2=223330&view=diff</a><br>
> ==============================================================================<br>
> --- lld/trunk/lib/ReaderWriter/PECOFF/PECOFFLinkingContext.cpp (original)<br>
> +++ lld/trunk/lib/ReaderWriter/PECOFF/PECOFFLinkingContext.cpp Wed Dec  3 19:09:06 2014<br>
> @@ -87,6 +87,23 @@ std::unique_ptr<File> PECOFFLinkingConte<br>
>       "<command line option /include>");<br>
> }<br>
><br>
> +void PECOFFLinkingContext::addLibraryFile(std::unique_ptr<FileNode> file) {<br>
> +  GroupEnd *currentGroupEnd;<br>
> +  int pos = -1;<br>
> +  std::vector<std::unique_ptr<InputElement>> &elements<br>
> +      = getInputGraph().inputElements();<br>
> +  for (int i = 0, e = elements.size(); i < e; ++i) {<br>
> +    if ((currentGroupEnd = dyn_cast<GroupEnd>(elements[i].get()))) {<br>
> +      pos = i;<br>
> +      break;<br>
> +    }<br>
> +  }<br>
> +  assert(pos >= 0);<br>
> +  elements.insert(elements.begin() + pos, std::move(file));<br>
> +  elements[pos + 1] = llvm::make_unique<GroupEnd>(<br>
> +      currentGroupEnd->getSize() + 1);<br>
> +}<br>
> +<br>
> bool PECOFFLinkingContext::createImplicitFiles(<br>
>     std::vector<std::unique_ptr<File>> &) {<br>
>   // Create a file for __ImageBase.<br>
> @@ -109,7 +126,7 @@ bool PECOFFLinkingContext::createImplici<br>
>   auto exportNode = llvm::make_unique<SimpleFileNode>("<export>");<br>
>   exportNode->appendInputFile(<br>
>       llvm::make_unique<pecoff::ExportedSymbolRenameFile>(*this, syms));<br>
> -  getLibraryGroup()->addFile(std::move(exportNode));<br>
> +  addLibraryFile(std::move(exportNode));<br>
><br>
>   // Create a file for the entry point function.<br>
>   getEntryNode()->appendInputFile(<br>
><br>
> Modified: lld/trunk/unittests/DriverTests/DriverTest.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/unittests/DriverTests/DriverTest.h?rev=223330&r1=223329&r2=223330&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/unittests/DriverTests/DriverTest.h?rev=223330&r1=223329&r2=223330&view=diff</a><br>
> ==============================================================================<br>
> --- lld/trunk/unittests/DriverTests/DriverTest.h (original)<br>
> +++ lld/trunk/unittests/DriverTests/DriverTest.h Wed Dec  3 19:09:06 2014<br>
> @@ -37,18 +37,6 @@ protected:<br>
>     llvm_unreachable("not handling other types of input files");<br>
>   }<br>
><br>
> -  // Convenience method for getting i'th input files name.<br>
> -  std::string inputFile(int index1, int index2) {<br>
> -    Group *group = dyn_cast<Group>(<br>
> -        linkingContext()->getInputGraph().inputElements()[index1].get());<br>
> -    if (!group)<br>
> -      llvm_unreachable("not handling other types of input files");<br>
> -    FileNode *file = dyn_cast<FileNode>(group->elements()[index2].get());<br>
> -    if (!file)<br>
> -      llvm_unreachable("not handling other types of input files");<br>
> -    return *file->getPath(*linkingContext());<br>
> -  }<br>
> -<br>
>   // For unit tests to call driver with various command lines.<br>
>   bool parse(const char *args, ...) {<br>
>     // Construct command line options from varargs.<br>
><br>
> Modified: lld/trunk/unittests/DriverTests/InputGraphTest.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/unittests/DriverTests/InputGraphTest.cpp?rev=223330&r1=223329&r2=223330&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/unittests/DriverTests/InputGraphTest.cpp?rev=223330&r1=223329&r2=223330&view=diff</a><br>
> ==============================================================================<br>
> --- lld/trunk/unittests/DriverTests/InputGraphTest.cpp (original)<br>
> +++ lld/trunk/unittests/DriverTests/InputGraphTest.cpp Wed Dec  3 19:09:06 2014<br>
> @@ -77,7 +77,7 @@ protected:<br>
><br>
> } // end anonymous namespace<br>
><br>
> -static std::unique_ptr<TestFileNode> createFile1(StringRef name) {<br>
> +static std::unique_ptr<TestFileNode> createFile(StringRef name) {<br>
>   std::vector<std::unique_ptr<File>> files;<br>
>   files.push_back(std::unique_ptr<SimpleFile>(new SimpleFile(name)));<br>
>   std::unique_ptr<TestFileNode> file(new TestFileNode("filenode"));<br>
> @@ -85,109 +85,30 @@ static std::unique_ptr<TestFileNode> cre<br>
>   return file;<br>
> }<br>
><br>
> -static std::unique_ptr<TestFileNode> createFile2(StringRef name1,<br>
> -                                                 StringRef name2) {<br>
> -  std::vector<std::unique_ptr<File>> files;<br>
> -  files.push_back(std::unique_ptr<SimpleFile>(new SimpleFile(name1)));<br>
> -  files.push_back(std::unique_ptr<SimpleFile>(new SimpleFile(name2)));<br>
> -  std::unique_ptr<TestFileNode> file(new TestFileNode("filenode"));<br>
> -  file->addFiles(std::move(files));<br>
> -  return file;<br>
> -}<br>
> -<br>
> TEST_F(InputGraphTest, Empty) {<br>
>   expectEnd();<br>
> }<br>
><br>
> TEST_F(InputGraphTest, File) {<br>
> -  _graph->addInputElement(createFile1("file1"));<br>
> -  EXPECT_EQ("file1", getNext());<br>
> -  expectEnd();<br>
> -}<br>
> -<br>
> -TEST_F(InputGraphTest, Files) {<br>
> -  _graph->addInputElement(createFile2("file1", "file2"));<br>
> -  EXPECT_EQ("file1", getNext());<br>
> -  EXPECT_EQ("file2", getNext());<br>
> -  expectEnd();<br>
> -}<br>
> -<br>
> -TEST_F(InputGraphTest, Group) {<br>
> -  _graph->addInputElement(createFile2("file1", "file2"));<br>
> -<br>
> -  std::unique_ptr<Group> group(new Group());<br>
> -  group->addFile(createFile2("file3", "file4"));<br>
> -  group->addFile(createFile1("file5"));<br>
> -  group->addFile(createFile1("file6"));<br>
> -  _graph->addInputElement(std::move(group));<br>
> -<br>
> +  _graph->addInputElement(createFile("file1"));<br>
>   EXPECT_EQ("file1", getNext());<br>
> -  EXPECT_EQ("file2", getNext());<br>
> -  EXPECT_EQ("file3", getNext());<br>
> -  EXPECT_EQ("file4", getNext());<br>
> -  EXPECT_EQ("file5", getNext());<br>
> -  EXPECT_EQ("file6", getNext());<br>
> -  expectEnd();<br>
> -}<br>
> -<br>
> -// Iterate through the group<br>
> -TEST_F(InputGraphTest, GroupIteration) {<br>
> -  _graph->addInputElement(createFile2("file1", "file2"));<br>
> -<br>
> -  std::unique_ptr<Group> group(new Group());<br>
> -  group->addFile(createFile2("file3", "file4"));<br>
> -  group->addFile(createFile1("file5"));<br>
> -  group->addFile(createFile1("file6"));<br>
> -  _graph->addInputElement(std::move(group));<br>
> -<br>
> -  EXPECT_EQ("file1", getNext());<br>
> -  EXPECT_EQ("file2", getNext());<br>
> -<br>
> -  EXPECT_EQ("file3", getNext());<br>
> -  EXPECT_EQ("file4", getNext());<br>
> -  EXPECT_EQ("file5", getNext());<br>
> -  EXPECT_EQ("file6", getNext());<br>
> -  _graph->notifyProgress();<br>
> -<br>
> -  EXPECT_EQ("file3", getNext());<br>
> -  EXPECT_EQ("file4", getNext());<br>
> -  _graph->notifyProgress();<br>
> -  EXPECT_EQ("file5", getNext());<br>
> -  EXPECT_EQ("file6", getNext());<br>
> -<br>
> -  EXPECT_EQ("file3", getNext());<br>
> -  EXPECT_EQ("file4", getNext());<br>
> -  EXPECT_EQ("file5", getNext());<br>
> -  EXPECT_EQ("file6", getNext());<br>
>   expectEnd();<br>
> }<br>
><br>
> // Node expansion tests<br>
> TEST_F(InputGraphTest, Normalize) {<br>
> -  _graph->addInputElement(createFile2("file1", "file2"));<br>
> +  _graph->addInputElement(createFile("file1"));<br>
><br>
>   std::unique_ptr<TestExpandFileNode> expandFile(<br>
>       new TestExpandFileNode("node"));<br>
> -  expandFile->addElement(createFile1("file3"));<br>
> -  expandFile->addElement(createFile1("file4"));<br>
> +  expandFile->addElement(createFile("file2"));<br>
> +  expandFile->addElement(createFile("file3"));<br>
>   _graph->addInputElement(std::move(expandFile));<br>
> -<br>
> -  std::unique_ptr<Group> group(new Group());<br>
> -  std::unique_ptr<TestExpandFileNode> expandFile2(<br>
> -      new TestExpandFileNode("node"));<br>
> -  expandFile2->addElement(createFile1("file5"));<br>
> -  group->addFile(std::move(expandFile2));<br>
> -  _graph->addInputElement(std::move(group));<br>
> -<br>
> -  _graph->addInputElement(createFile1("file6"));<br>
>   _graph->normalize();<br>
><br>
>   EXPECT_EQ("file1", getNext());<br>
>   EXPECT_EQ("file2", getNext());<br>
>   EXPECT_EQ("file3", getNext());<br>
> -  EXPECT_EQ("file4", getNext());<br>
> -  EXPECT_EQ("file5", getNext());<br>
> -  EXPECT_EQ("file6", getNext());<br>
>   expectEnd();<br>
> }<br>
><br>
> @@ -195,8 +116,8 @@ TEST_F(InputGraphTest, Observer) {<br>
>   std::vector<std::string> files;<br>
>   _graph->registerObserver([&](File *file) { files.push_back(file->path()); });<br>
><br>
> -  _graph->addInputElement(createFile1("file1"));<br>
> -  _graph->addInputElement(createFile1("file2"));<br>
> +  _graph->addInputElement(createFile("file1"));<br>
> +  _graph->addInputElement(createFile("file2"));<br>
>   EXPECT_EQ("file1", getNext());<br>
>   EXPECT_EQ("file2", getNext());<br>
>   expectEnd();<br>
><br>
> Modified: lld/trunk/unittests/DriverTests/WinLinkDriverTest.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/unittests/DriverTests/WinLinkDriverTest.cpp?rev=223330&r1=223329&r2=223330&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/unittests/DriverTests/WinLinkDriverTest.cpp?rev=223330&r1=223329&r2=223330&view=diff</a><br>
> ==============================================================================<br>
> --- lld/trunk/unittests/DriverTests/WinLinkDriverTest.cpp (original)<br>
> +++ lld/trunk/unittests/DriverTests/WinLinkDriverTest.cpp Wed Dec  3 19:09:06 2014<br>
> @@ -137,11 +137,11 @@ TEST_F(WinLinkParserTest, Libpath) {<br>
> TEST_F(WinLinkParserTest, InputOrder) {<br>
>   EXPECT_TRUE(parse("link.exe", "a.lib", "b.obj", "c.obj", "a.lib", "d.obj",<br>
>                     nullptr));<br>
> -  EXPECT_EQ(5, inputFileCount());<br>
> +  EXPECT_EQ(6, inputFileCount());<br>
>   EXPECT_EQ("b.obj", inputFile(0));<br>
>   EXPECT_EQ("c.obj", inputFile(1));<br>
>   EXPECT_EQ("d.obj", inputFile(2));<br>
> -  EXPECT_EQ("a.lib", inputFile(4, 0));<br>
> +  EXPECT_EQ("a.lib", inputFile(4));<br>
> }<br>
><br>
> //<br>
> @@ -393,36 +393,36 @@ TEST_F(WinLinkParserTest, SectionMultipl<br>
> TEST_F(WinLinkParserTest, DefaultLib) {<br>
>   EXPECT_TRUE(parse("link.exe", "/defaultlib:user32.lib",<br>
>                     "/defaultlib:kernel32", "a.obj", nullptr));<br>
> -  EXPECT_EQ(3, inputFileCount());<br>
> +  EXPECT_EQ(5, inputFileCount());<br>
>   EXPECT_EQ("a.obj", inputFile(0));<br>
> -  EXPECT_EQ("user32.lib", inputFile(2, 0));<br>
> -  EXPECT_EQ("kernel32.lib", inputFile(2, 1));<br>
> +  EXPECT_EQ("user32.lib", inputFile(2));<br>
> +  EXPECT_EQ("kernel32.lib", inputFile(3));<br>
> }<br>
><br>
> TEST_F(WinLinkParserTest, DefaultLibDuplicates) {<br>
>   EXPECT_TRUE(parse("link.exe", "/defaultlib:user32.lib",<br>
>                     "/defaultlib:user32.lib", "a.obj", nullptr));<br>
> -  EXPECT_EQ(3, inputFileCount());<br>
> +  EXPECT_EQ(4, inputFileCount());<br>
>   EXPECT_EQ("a.obj", inputFile(0));<br>
> -  EXPECT_EQ("user32.lib", inputFile(2, 0));<br>
> +  EXPECT_EQ("user32.lib", inputFile(2));<br>
> }<br>
><br>
> TEST_F(WinLinkParserTest, NoDefaultLib) {<br>
>   EXPECT_TRUE(parse("link.exe", "/defaultlib:user32.lib",<br>
>                     "/defaultlib:kernel32", "/nodefaultlib:user32.lib", "a.obj",<br>
>                     nullptr));<br>
> -  EXPECT_EQ(3, inputFileCount());<br>
> +  EXPECT_EQ(4, inputFileCount());<br>
>   EXPECT_EQ("a.obj", inputFile(0));<br>
> -  EXPECT_EQ("kernel32.lib", inputFile(2, 0));<br>
> +  EXPECT_EQ("kernel32.lib", inputFile(2));<br>
> }<br>
><br>
> TEST_F(WinLinkParserTest, NoDefaultLibCase) {<br>
>   EXPECT_TRUE(parse("link.exe", "/defaultlib:user32",<br>
>                     "/defaultlib:kernel32", "/nodefaultlib:USER32.LIB", "a.obj",<br>
>                     nullptr));<br>
> -  EXPECT_EQ(3, inputFileCount());<br>
> +  EXPECT_EQ(4, inputFileCount());<br>
>   EXPECT_EQ("a.obj", inputFile(0));<br>
> -  EXPECT_EQ("kernel32.lib", inputFile(2, 0));<br>
> +  EXPECT_EQ("kernel32.lib", inputFile(2));<br>
> }<br>
><br>
> TEST_F(WinLinkParserTest, NoDefaultLibAll) {<br>
> @@ -436,9 +436,9 @@ TEST_F(WinLinkParserTest, DisallowLib) {<br>
>   EXPECT_TRUE(parse("link.exe", "/defaultlib:user32.lib",<br>
>                     "/defaultlib:kernel32", "/disallowlib:user32.lib", "a.obj",<br>
>                     nullptr));<br>
> -  EXPECT_EQ(3, inputFileCount());<br>
> +  EXPECT_EQ(4, inputFileCount());<br>
>   EXPECT_EQ("a.obj", inputFile(0));<br>
> -  EXPECT_EQ("kernel32.lib", inputFile(2, 0));<br>
> +  EXPECT_EQ("kernel32.lib", inputFile(2));<br>
> }<br>
><br>
> //<br>
><br>
><br>
> _______________________________________________<br>
> llvm-commits mailing list<br>
> <a href="mailto:llvm-commits@cs.uiuc.edu" target="_blank">llvm-commits@cs.uiuc.edu</a><br>
> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
<br>
</div></div></blockquote></div><br></div>
_______________________________________________<br>llvm-commits mailing list<br><a href="mailto:llvm-commits@cs.uiuc.edu" target="_blank">llvm-commits@cs.uiuc.edu</a><br><a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br></div></div></div></blockquote></div><br></div></div></div></blockquote></div><br></div>