<html>
    <head>
      <base href="https://llvm.org/bugs/" />
    </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 --- - LLD doesn't like it if LLVM_LINK_LLVM_DYLIB is turned on"
   href="https://llvm.org/bugs/show_bug.cgi?id=27685">27685</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>LLD doesn't like it if LLVM_LINK_LLVM_DYLIB is turned on
          </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>Linux
          </td>
        </tr>

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

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>All Bugs
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>ed@80386.nl
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Sylvestre Ledru and I are currently working on extending the Debian packages
for LLVM (<a href="http://llvm.org/apt/">http://llvm.org/apt/</a>) to also contain LLD. Sylvestre observed that
his copy of LLD crashes on startup with the following message:

$ lld-3.9
: CommandLine Error: Option 'asm-instrumentation' registered more than once!
LLVM ERROR: inconsistency in registered CommandLine options
*** Error in `lld-3.9': free(): invalid pointer: 0x00007fbcc967ab78 ***
======= Backtrace: =========
...

Looking into this in more detail, it seems like his copy of LLD is both
statically and dynamically linked against LLVM libraries, which happens because
he's building LLD with LLVM_LINK_LLVM_DYLIB set.

Taking a quick glance at the LLD CMakeLists, I can imagine why this is
happening. The add_lld_library() calls explicitly list the LLVM libraries we
are interested in using. This is different from how this is done in the LLVM
source tree, where we set LLVM_LINK_COMPONENTS to a list of libraries we want
to use. These libraries are ignored if LLVM_LINK_LLVM_DYLIB is set (see
cmake/modules/AddLLVM.cmake).

I have to confess I know too little of CMake to fix this myself. Otherwise I
would have sent out a code review for this. Just filing this bug to make sure
it won't get lost.</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>