<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 --- - Linking complicated static libraries causes an *internal linker error*"
   href="http://llvm.org/bugs/show_bug.cgi?id=21439">21439</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Linking complicated static libraries causes an *internal linker error*
          </td>
        </tr>

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

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

        <tr>
          <th>Hardware</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>MacOS X
          </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>alexchandel@gmail.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>I was attempting to link a Rust program with LLD when an assertion failure
occurred. Rust programs are linked with the C standard library and the Rust
standard libraries, which are just static libraries.

The contents of an RLIB archive are the same as a normal static library, plus
two metadata files:
```
% ar -t $RLIB/libstd-4e7c5e5c.rlib
__.SYMDEF SORTED
std-4e7c5e5c.o
r-rust_builtin-rust_android_dummy.o
r-rust_builtin-rust_builtin.o
rust.metadata.bin
std-4e7c5e5c.0.bytecode.deflate
```

Compare this with a typical static archive:
```
% ar -t libmorestack.a
__.SYMDEF SORTED
morestack.o
```

Both the OS X and GNU binutils linker can handle this. However, when I call LLD
with an RLIB argument, it crashes with the following assertion failure:

```
% $LLVM/lld -flavor darwin test.o $RLIB/libnative-4e7c5e5c.rlib
$RLIB/libstd-4e7c5e5c.rlib $RLIB/librand-4e7c5e5c.rlib
$RLIB/libsync-4e7c5e5c.rlib $RLIB/librustrt-4e7c5e5c.rlib
$RLIB/libcollections-4e7c5e5c.rlib $RLIB/libunicode-4e7c5e5c.rlib
$RLIB/liballoc-4e7c5e5c.rlib $RLIB/liblibc-4e7c5e5c.rlib
$RLIB/libcore-4e7c5e5c.rlib $RLIB/libmorestack.a $RLIB/libcompiler-rt.a
-lSystem -o test
Assertion failed: (files.size() == 1), function instantiateMember, file
FileArchive.cpp, line 146.
0  libLLVM-3.6svn.dylib     0x0000000106349dab
llvm::sys::PrintStackTrace(__sFILE*) + 43
1  libLLVM-3.6svn.dylib     0x000000010634a2b3 SignalHandler(int) + 217
2  libsystem_platform.dylib 0x00007fff8e612f1a _sigtramp + 26
3  libsystem_platform.dylib 0x00007fff66b25764 _sigtramp + 3629197412
4  libLLVM-3.6svn.dylib     0x000000010634a139 abort + 22
5  libLLVM-3.6svn.dylib     0x000000010634a123 abort + 0
6  lld                      0x000000010569e157
7  lld                      0x000000010569dcc1
8  lld                      0x00000001056a5b6a
9  lld                      0x00000001056a4547
10 lld                      0x00000001056a4674
11 lld                      0x00000001056a4b16
12 lld                      0x00000001056a56e4
13 lld                      0x000000010561f644
14 lld                      0x000000010561c048
15 lld                      0x0000000105626481
16 lld                      0x000000010561aaf0
17 libdyld.dylib            0x00007fff8d6885c9 start + 1
Stack dump:
0.    Program arguments: /usr/local/opt/llvm/bin/lld test.o
/usr/local/lib/rustlib/x86_64-apple-darwin/lib/libnative-4e7c5e5c.rlib
/usr/local/lib/rustlib/x86_64-apple-darwin/lib/libstd-4e7c5e5c.rlib
/usr/local/lib/rustlib/x86_64-apple-darwin/lib/librand-4e7c5e5c.rlib
/usr/local/lib/rustlib/x86_64-apple-darwin/lib/libsync-4e7c5e5c.rlib
/usr/local/lib/rustlib/x86_64-apple-darwin/lib/librustrt-4e7c5e5c.rlib
/usr/local/lib/rustlib/x86_64-apple-darwin/lib/libcollections-4e7c5e5c.rlib
/usr/local/lib/rustlib/x86_64-apple-darwin/lib/libunicode-4e7c5e5c.rlib
/usr/local/lib/rustlib/x86_64-apple-darwin/lib/liballoc-4e7c5e5c.rlib
/usr/local/lib/rustlib/x86_64-apple-darwin/lib/liblibc-4e7c5e5c.rlib
/usr/local/lib/rustlib/x86_64-apple-darwin/lib/libcore-4e7c5e5c.rlib
/usr/local/lib/rustlib/x86_64-apple-darwin/lib/libmorestack.a
/usr/local/lib/rustlib/x86_64-apple-darwin/lib/libcompiler-rt.a -lSystem -o
test -flavor darwin
```

It could be failing due to the unusual filename extension of the archive
("*.rlib" versus "*.a"), due to the multiple object files in the archive, or
due to the additional metadata files in the archive ("rust.metadata.bin" and
"std-4e7c5e5c.0.bytecode.deflate").</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>