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

            Bug ID: 32281
           Summary: lld doesn't give error about missing archive symbol
                    table
           Product: lld
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: ELF
          Assignee: unassignedb...@nondot.org
          Reporter: tejohn...@google.com
                CC: llvm-bugs@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
references.

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.

Reproducer:

$ cat main.c
extern void foo();
int main() {
  foo();
  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'

vs

$ 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.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to