[llvm-bugs] [Bug 32281] New: lld doesn't give error about missing archive symbol table

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Mar 15 07:50:12 PDT 2017


            Bug ID: 32281
           Summary: lld doesn't give error about missing archive symbol
           Product: lld
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: ELF
          Assignee: unassignedbugs at nondot.org
          Reporter: tejohnson at google.com
                CC: llvm-bugs at lists.llvm.org

When bootstrapping clang with ThinLTO or LTO, ranlib must know how to create an
archive symbol table in the archives of bitcode files. This requires either
setting up the system ranlib to know where to find the LLVM gold plugin, or
just use llvm-ranlib via -DCMAKE_RANLIB=$BUILD_COMPILER/bin/llvm-ranlib.
Otherwise the link step can't read the symbols and there are many undefined

When gold is used, it immediately emits a meaningful error:
ld.gold: error: lib/libLLVMSupport.a: no archive symbol table (run ranlib)
ld.gold: error: lib/libLLVMDemangle.a: no archive symbol table (run ranlib)

However, when lld is used, no such error is emitted and the user just gets
undefined references, making it harder to identify the issue.


$ cat main.c
extern void foo();
int main() {
  return 1;
$ cat foo.c
void foo() {
$ clang -c main.c
$ clang -c foo.c -flto  <- produce bitcode
$ ar qc foo.a foo.o

(skip running ranlib, which would be the same as using a system ranlib without
the LLVM gold plugin)

$ ld.gold -o a.out main.o foo.a
ld.gold: error: foo.a: no archive symbol table (run ranlib)
main.o:main.c:function main: error: undefined reference to 'foo'


$ ld.lld  -o a.out main.o foo.a
ld.lld: error: main.c:(function main): undefined symbol 'foo'

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/20170315/7cf70c4c/attachment.html>

More information about the llvm-bugs mailing list