http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60461
Bug ID: 60461 Summary: LTO linking error at -Os (and above) on x86_64-linux-gnu Product: gcc Version: 4.9.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: lto Assignee: unassigned at gcc dot gnu.org Reporter: su at cs dot ucdavis.edu The following code triggers a linker error when it is compiled by the current gcc trunk using LTO at -Os on x86_64-linux-gnu (in both 32-bit and 64-bit modes). It also triggers the error at -O2 and -O3 in 32-bit mode. This is a regression from 4.8.x. $ gcc-trunk -v Using built-in specs. COLLECT_GCC=gcc-trunk COLLECT_LTO_WRAPPER=/usr/local/gcc-trunk/libexec/gcc/x86_64-unknown-linux-gnu/4.9.0/lto-wrapper Target: x86_64-unknown-linux-gnu Configured with: ../gcc-trunk/configure --prefix=/usr/local/gcc-trunk --enable-languages=c,c++ --disable-werror --enable-multilib Thread model: posix gcc version 4.9.0 20140307 (experimental) [trunk revision 208393] (GCC) $ $ gcc-trunk -Os small.c; a.out $ gcc-trunk -flto -O1 small.c; a.out $ gcc-4.8.2 -flto -Os small.c; a.out $ $ gcc-trunk -flto -Os small.c /tmp/ccv33rju.ltrans0.ltrans.o:ccv33rju.ltrans0.o:function fn2: error: undefined reference to 'a' collect2: error: ld returned 1 exit status $ ------------------------------ struct S { int f1; int f2; } a[1] = { {0, 0} }; int b, c; static unsigned short fn1 (struct S); void fn2 () { for (; c;) ; b = 0; fn1 (a[0]); } unsigned short fn1 (struct S p) { if (p.f1) fn2 (); return 0; } int main () { fn2 (); return 0; }