http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48056
Summary: lto throws out needed symbols when linking QtScript Product: gcc Version: 4.6.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: lto AssignedTo: unassig...@gcc.gnu.org ReportedBy: b...@arklinux.org Trying to build Qt with -flto (after working around bug 48042) results in $ g++ [...] -flto=8 [...] -shared -Wl,-Bsymbolic-functions -Wl,-soname,libQtScript.so.4 -o libQtScript.so.4.7.2 obj/release/pcre_compile.o [...] obj/release/JITStubs.o [...] /tmp/ccKsaUWN.ltrans0.ltrans.o: In function `ctiVMThrowTrampoline': ccKsaUWN.ltrans0.o:(.text+0x4c): undefined reference to `cti_vm_throw' cti_vm_throw is defined in JITStubs.cpp and exists in obj/release/JITStubs.o (as passed to the compiler). $ nm obj/release/JITStubs.o |grep cti_vm_throw 0000000000006ad0 T cti_vm_throw $ objdump -s obj/release/JITStubs.o [...] Contents of section .gnu.lto_cti_vm_throw.1ff1d9c6: 0000 789c9d57 7b705457 19ffbe73 f7ee23bb x..W{pTW...s..#. [...] This is probably caused by the fact that ctiVMThrowTrampoline (the user of cti_vm_throw) uses cti_vm_throw through an asm statement: #define HIDE_SYMBOL(name) ".hidden " #name #define SYMBOL_STRING(name) #name #define SYMBOL_STRING_RELOCATION(name) #name "@plt" asm volatile ( ".globl " SYMBOL_STRING(ctiVMThrowTrampoline) "\n" HIDE_SYMBOL(ctiVMThrowTrampoline) "\n" SYMBOL_STRING(ctiVMThrowTrampoline) ":" "\n" "movq %rsp, %rdi" "\n" "call " SYMBOL_STRING_RELOCATION(cti_vm_throw) "\n" "addq $0x48, %rsp" "\n" "popq %rbx" "\n" "popq %r15" "\n" "popq %r14" "\n" "popq %r13" "\n" "popq %r12" "\n" "popq %rbp" "\n" "ret" "\n" );