http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47181
Summary: memops-asm testcase fails with -flto -fuse-linker-plugin Product: gcc Version: 4.6.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: lto AssignedTo: unassig...@gcc.gnu.org ReportedBy: hubi...@gcc.gnu.org memops-asm testcase fails with -flto -fuse-linker-plugin. We produce undefined call to my_memcpy: evans:/abuild/jh/trunk-3/build-inst2/gcc/:[0]# ./xgcc -B ./ -O2 memops-asm*.c /abuild/jh/trunk-3/gcc/testsuite/gcc.c-torture/execute/builtins/lib/main.c -g -O0 -flto --save-temps -fdump-ipa-all-details -save-temps memops-asm.c: In function ?main_test?: memops-asm.c:37:3: warning: incompatible implicit declaration of built-in function ?printf? [enabled by default] [Leaving LTRANS /tmp/ccrBB4II.args] [Leaving LTRANS /tmp/ccc7Rjx0.ltrans.out] [Leaving LTRANS /tmp/ccOzcZ98.args] [Leaving LTRANS /tmp/ccc7Rjx0.ltrans0.o] evans:/abuild/jh/trunk-3/build-inst2/gcc/:[0]# grep memcpy *.s ccc7Rjx0.ltrans0.s: .globl memcpy ccc7Rjx0.ltrans0.s: .type memcpy, @function ccc7Rjx0.ltrans0.s:memcpy: ccc7Rjx0.ltrans0.s: call my_memcpy.2055 ccc7Rjx0.ltrans0.s: .size memcpy, .-memcpy ccc7Rjx0.ltrans0.s: .type my_memcpy.2055, @function ccc7Rjx0.ltrans0.s:my_memcpy.2055: ccc7Rjx0.ltrans0.s: .size my_memcpy.2055, .-my_memcpy.2055 ccc7Rjx0.ltrans0.s: call my_memcpy ccc7Rjx0.ltrans0.s: call my_memcpy ccc7Rjx0.ltrans0.s: .string "memcpy" ccc7Rjx0.ltrans0.s: .string "my_memcpy" the issue is that my_memcpy is declared once as: extern void *memcpy (void *, const void *, size_t) __asm (ASMNAME ("my_memcpy")); and in the other unit as void * my_memcpy (void *d, const void *s, size_t n) we fail to merge the declarations in lto-symtab since builtins are streamed in special way. This leads to linker bug and wrong code: http://sourceware.org/bugzilla/show_bug.cgi?id=12365