[LLVMbugs] [Bug 21439] New: Linking complicated static libraries causes an *internal linker error*

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Fri Oct 31 21:39:40 PDT 2014


http://llvm.org/bugs/show_bug.cgi?id=21439

            Bug ID: 21439
           Summary: Linking complicated static libraries causes an
                    *internal linker error*
           Product: lld
           Version: unspecified
          Hardware: All
                OS: MacOS X
            Status: NEW
          Severity: normal
          Priority: P
         Component: All Bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: alexchandel at gmail.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

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").

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20141101/99cad690/attachment.html>


More information about the llvm-bugs mailing list