[llvm-bugs] [Bug 30665] New: lld confuses object files with the same name, but from different archive files in lto mode

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Oct 11 16:57:05 PDT 2016


https://llvm.org/bugs/show_bug.cgi?id=30665

            Bug ID: 30665
           Summary: lld confuses object files with the same name, but from
                    different archive files in lto mode
           Product: lld
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: ELF
          Assignee: unassignedbugs at nondot.org
          Reporter: krasin at google.com
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

Created attachment 17426
  --> https://llvm.org/bugs/attachment.cgi?id=17426&action=edit
the reproducer

Consider the following program (the full reproducer is attached):

main.cc uses symbols from two other files: one/timezone.cc and two/timezone.cc
(the "timezone" is irrelevant; the meaningful part is that the name are the
same, though that paths and contents are different).

The object files are linked through archives: libone.a and libtwo.a:

clang++ -o one/timezone.o -c one/timezone.cc -flto=thin
llvm-ar rcsD libone.a one/timezone.o
clang++ -o two/timezone.o -c two/timezone.cc -flto=thin
llvm-ar rcsD libtwo.a two/timezone.o

clang++ -c main.cc -flto=thin
clang++ -o main main.o libone.a libtwo.a -flto=thin -fuse-ld=lld

On top of that, it's ThinLTO, and full (not thin) archives.

This fails with:

$ ./build.sh                                                                    
undefined symbol: base::CountryCodeForCurrentTimezone()
clang-3.9: error: linker command failed with exit code 1 (use -v to see
invocation)

Gold links correctly (so, it's not an LTO bug per se)
Full LTO (-flto) instead of -flto=thin links correctly
Regular (non-lto) build works correctly
Thin archives (rcsDT) work correctly.

So, it's a combination of lld + ThinLTO + regular archives + the object name
collision.

-- 
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/20161011/df68d832/attachment.html>


More information about the llvm-bugs mailing list