Bug 48056 - lto throws out needed symbols when linking QtScript
Summary: lto throws out needed symbols when linking QtScript
Status: RESOLVED INVALID
Alias: None
Product: gcc
Classification: Unclassified
Component: lto (show other bugs)
Version: 4.6.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-03-10 10:19 UTC by bero
Modified: 2022-11-17 19:55 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description bero 2011-03-10 10:19:15 UTC
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"
);
Comment 1 Andrew Pinski 2011-03-10 10:23:21 UTC
I think you need to use the attribute used on cti_vm_throw when using LTO as the symbol usage is hidden from the compiler.
Comment 2 Richard Biener 2011-03-10 11:10:55 UTC
Yep.  Mark it with attribute((used)).
Comment 3 bero 2011-03-10 11:48:47 UTC
Thanks, works.
Re-filed as WebKit bug
https://bugs.webkit.org/show_bug.cgi?id=56088