http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58905
Bug ID: 58905
Summary: Undefined symbol not report when compile with -flto
-O1
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: lto
Assignee: unassigned at gcc dot gnu.org
Reporter: npickito at gmail dot com
Test Program:
test.c
char ___undef_func___ ();
char (*f) () = ___undef_func___;
int main ()
{
return f != ___undef_func___;
}
Problem:
$ gcc-trunk test.c # link error because ___undef_func___ is undefined
/tmp/ccvwlcm2.o:test.c:function main: error: undefined reference to
'___undef_func___'
/tmp/ccvwlcm2.o:test.c:function f: error: undefined reference to
'___undef_func___'
collect2: error: ld returned 1 exit status
$ gcc-trunk test.c -flto -O1 # No linker error when -flto -O1!
$ gcc-trunk test.c -flto -O0 # But linker error with -flto -O0
/tmp/ccPm2VXa.ltrans0.ltrans.o:ccPm2VXa.ltrans0.o:function main: error:
undefined reference to '___undef_func___'
/tmp/ccPm2VXa.ltrans0.ltrans.o:ccPm2VXa.ltrans0.o:function f: error: undefined
reference to '___undef_func___'
collect2: error: ld returned 1 exit status
GCC version:
gcc trunk r204123
gcc 4.8.1 20130603 (Red Hat 4.8.1-1) (GCC)
GCC configure:
$ gcc-trunk -v
Using built-in specs.
COLLECT_GCC=gcc-trunk
COLLECT_LTO_WRAPPER=/home/kito/libexec/gcc/x86_64-unknown-linux-gnu/4.9.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: /home/kito/gcc/configure --prefix=/home/kito
--with-arch_32=i686 --enable-languages=c,c++,go,lto --program-suffix=-trunk
--disable-bootstrap --disable-shared CFLAGS='-g0 -O3 -flto' CXXFLAGS='-g0 -O3
-flto' LDFLAGS='-flto -fuse-linker-plugin'
Thread model: posix
gcc version 4.9.0 20131028 (experimental) (GCC)