<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 --- - -nostdlib -rtlib=compiler_rt fails, no mechanism to link libc.so"
   href="https://llvm.org/bugs/show_bug.cgi?id=25185">25185</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>-nostdlib -rtlib=compiler_rt fails, no mechanism to link libc.so
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </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>Driver
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>nsz@port70.net
          </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>-rtlib is ignored after -nostdlib:

$ clang -nostdlib -rtlib=compiler-rt t.c -o t
clang-3.6: warning: argument unused during compilation: '-rtlib=compiler-rt'
$ clang --version
clang version 3.6.2 (tags/RELEASE_362/final)
Target: armv6-alpine-linux-muslgnueabihf

this makes it impossible to link libc.so which must use -nostdlib,
but has to be linked against the right compiler runtime.

there seems to be no way to discover (e.g. in a configure script) how to
link to the right clang compiler runtime (this is most likely necessary
for other freestanding code too, not just the c runtime).

(the problem persists on trunk and target independent.)

on gcc one can use either of

gcc -nostdlib t.c -lgcc
gcc -nostdlib t.c `gcc -print-file-name=libgcc.a`

clang should either accept -rtlib or needs a similar mechanism
to -print-file-name, in fact there are patches proposed along
those lines:

<a href="http://reviews.llvm.org/D10049">http://reviews.llvm.org/D10049</a>
<a href="http://reviews.llvm.org/D10050">http://reviews.llvm.org/D10050</a>
<a href="http://reviews.llvm.org/D10051">http://reviews.llvm.org/D10051</a>
<a href="http://reviews.llvm.org/D10052">http://reviews.llvm.org/D10052</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>