<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Errors when linking multiple times in the same process through the API"
   href="https://bugs.llvm.org/show_bug.cgi?id=52070">52070</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Errors when linking multiple times in the same process through the API
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>lld
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>MachO
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>dpldobrev@protonmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>gkm@fb.com, jezreel@gmail.com, llvm-bugs@lists.llvm.org, smeenai@fb.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=25325" name="attach_25325" title="A tarball created by --reproduce">attachment 25325</a> <a href="attachment.cgi?id=25325&action=edit" title="A tarball created by --reproduce">[details]</a></span>
A tarball created by --reproduce

I use LLD as a library:

lld::macho::link(args, false, outs(), errs());

with these arguments:

-flavor darwin -arch x86_64 -platform_version macos 10.12.0 10.12.0 -dylib
-L/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib -lc++ -lSystem
-rpath .

I call this function multiple times in the same process. The result is that I
get various linking errors for both system and local functions:

-flavor darwin : error : undefined symbol: _memcpy
-flavor darwin : error : undefined symbol:
__ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEaSERKS5_

When I reduce the calls to just one, it passes with no errors.
It's possible that this bug is connected to state: it isn't reset after each
call because it's global.

It's important to know that this only happens in MachO and just the new one.
That is: COFF, MinGW, Linux and the old MachO work just fine.</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>