[llvm-bugs] [Bug 26674] New: --start-lib/--end-lib broken with LTO

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Feb 19 15:30:44 PST 2016


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

            Bug ID: 26674
           Summary: --start-lib/--end-lib broken with LTO
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Linker
          Assignee: unassignedbugs at nondot.org
          Reporter: eugeni.stepanov at gmail.com
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

$ cat bin.cc 
int main() {}

$ cat 1.cc
__attribute__((constructor(0))) void ctor() {}

$ ./bin/clang++ -flto bin.cc -c
$ ./bin/clang++ -flto 1.cc -c
$ ./bin/clang++ -fuse-ld=gold -flto  bin.o -Wl,--start-lib 1.o -Wl,--end-lib
/tmp/lto-llvm-2af7ce.o(.init_array.0+0x0): error: undefined reference to
'ctor()'
clang-3.9: error: linker command failed with exit code 1 (use -v to see
invocation)

With -Wl,-plugin-opt,save-temps the merged IR (before link time optimizations)
looks like this:

[...]
@llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void
()*, i8* } { i32 0, void ()* @_Z4ctorv, i8* null }]

; Function Attrs: norecurse nounwind uwtable
define i32 @main() #0 {
entry:
  ret i32 0
}

; Function Attrs: nounwind uwtable
declare void @_Z4ctorv() #1
[...]


$ /usr/bin/ld.gold --version
GNU gold (GNU Binutils for Ubuntu 2.24) 1.11

-- 
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/20160219/71da3a7b/attachment.html>


More information about the llvm-bugs mailing list