<html>
    <head>
      <base href="http://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 --- - OCaml bindings don't link to libLLVM-3.x.so with -Wl,--as-needed"
   href="http://llvm.org/bugs/show_bug.cgi?id=22014">22014</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>OCaml bindings don't link to libLLVM-3.x.so with -Wl,--as-needed
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>Build scripts
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </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>Makefiles
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>evangelos@foutrelis.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=13587" name="attach_13587" title="Fix OCaml bindings linking with -Wl,--as-needed">attachment 13587</a> <a href="attachment.cgi?id=13587&action=edit" title="Fix OCaml bindings linking with -Wl,--as-needed">[details]</a></span>
Fix OCaml bindings linking with -Wl,--as-needed

When building LLVM with "-Wl,--as-needed" in LDFLAGS (as it's been the default
in Arch Linux for several years now), the OCaml bindings' .so libs won't get
linked to libLLVM-3.x.so and thus result in undefined symbols when they are
used:

<span class="quote">> /usr/lib/ocaml/dllllvm.so: undefined symbol: LLVMGetFirstUse</span >

I believe this is caused by the object files appearing after the libraries
during the linking stage. [1]

I've attached a patch for Makefile.ocaml which fixes the issue for me.

(I only tested with LLVM 3.5 but this issue should affect /trunk as well.)

[1]
<a href="https://wiki.mageia.org/en/Overlinking_issues_in_packaging#Wrong_linking_order">https://wiki.mageia.org/en/Overlinking_issues_in_packaging#Wrong_linking_order</a></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>