http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60622
Bug ID: 60622 Summary: [4.9 Regression] symbol missing when compiled with -flto Product: gcc Version: lto Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: raj.khem at gmail dot com trying to compile systemd with gcc 4.9 snapshot there appears to be a lot of undefined symbols, I traced it down to the fact that system uses -flto option during compilation, and when thats used the symbol table is completely bald. e.g. extern int arg; __attribute__ ((visibility("default"))) extern int foo() { return arg; } $ mips-angstrom-linux-uclibc-gcc test.c -c -flto $ readelf -s test.o Symbol table '.symtab' contains 19 entries: Num: Value Size Type Bind Vis Ndx Name 0: 00000000 0 NOTYPE LOCAL DEFAULT UND 1: 00000000 0 FILE LOCAL DEFAULT ABS test.c 2: 00000000 0 SECTION LOCAL DEFAULT 1 3: 00000000 0 SECTION LOCAL DEFAULT 2 4: 00000000 0 SECTION LOCAL DEFAULT 3 5: 00000000 0 SECTION LOCAL DEFAULT 6 6: 00000000 0 SECTION LOCAL DEFAULT 7 7: 00000000 0 SECTION LOCAL DEFAULT 8 8: 00000000 0 SECTION LOCAL DEFAULT 9 9: 00000000 0 SECTION LOCAL DEFAULT 10 10: 00000000 0 SECTION LOCAL DEFAULT 11 11: 00000000 0 SECTION LOCAL DEFAULT 12 12: 00000000 0 SECTION LOCAL DEFAULT 13 13: 00000000 0 SECTION LOCAL DEFAULT 4 14: 00000000 0 SECTION LOCAL DEFAULT 5 15: 00000000 0 SECTION LOCAL DEFAULT 14 16: 00000000 0 SECTION LOCAL DEFAULT 15 17: 00000001 1 OBJECT GLOBAL DEFAULT COM __gnu_lto_v1 18: 00000001 1 OBJECT GLOBAL DEFAULT COM __gnu_lto_slim $ mips-angstrom-linux-uclibc-gcc test.c -c $ readelf -s test.o Symbol table '.symtab' contains 13 entries: Num: Value Size Type Bind Vis Ndx Name 0: 00000000 0 NOTYPE LOCAL DEFAULT UND 1: 00000000 0 FILE LOCAL DEFAULT ABS test.c 2: 00000000 0 SECTION LOCAL DEFAULT 1 3: 00000000 0 SECTION LOCAL DEFAULT 3 4: 00000000 0 SECTION LOCAL DEFAULT 4 5: 00000000 0 SECTION LOCAL DEFAULT 8 6: 00000000 0 SECTION LOCAL DEFAULT 5 7: 00000000 0 SECTION LOCAL DEFAULT 6 8: 00000000 0 SECTION LOCAL DEFAULT 9 9: 00000000 0 SECTION LOCAL DEFAULT 10 10: 00000000 52 FUNC GLOBAL DEFAULT 1 foo ^^^ symbol is there 11: 00000000 0 NOTYPE GLOBAL DEFAULT UND __gnu_local_gp 12: 00000000 0 NOTYPE GLOBAL DEFAULT UND arg This issue I did not see on arm, only on ppc and mips here gcc configure Target: mips-angstrom-linux-uclibc Configured with: /home/kraj/angstrom/build/tmp-angstrom_next-uclibc/work-shared/gcc-4.9-20140316-r0/gcc-4.9-20140316/configure --build=x86_64-linux --host=x86_64-linux --target=mips-angstrom-linux-uclibc --prefix=/home/kraj/angstrom/build/tmp-angstrom_next-uclibc/sysroots/x86_64-linux/usr --exec_prefix=/home/kraj/angstrom/build/tmp-angstrom_next-uclibc/sysroots/x86_64-linux/usr --bindir=/home/kraj/angstrom/build/tmp-angstrom_next-uclibc/sysroots/x86_64-linux/usr/bin/mips32-angstrom-linux-uclibc --sbindir=/home/kraj/angstrom/build/tmp-angstrom_next-uclibc/sysroots/x86_64-linux/usr/bin/mips32-angstrom-linux-uclibc --libexecdir=/home/kraj/angstrom/build/tmp-angstrom_next-uclibc/sysroots/x86_64-linux/usr/libexec/mips32-angstrom-linux-uclibc --datadir=/home/kraj/angstrom/build/tmp-angstrom_next-uclibc/sysroots/x86_64-linux/usr/share --sysconfdir=/home/kraj/angstrom/build/tmp-angstrom_next-uclibc/sysroots/x86_64-linux/etc --sharedstatedir=/home/kraj/angstrom/build/tmp-angstrom_next-uclibc/sysroots/x86_64-linux/com --localstatedir=/home/kraj/angstrom/build/tmp-angstrom_next-uclibc/sysroots/x86_64-linux/var --libdir=/home/kraj/angstrom/build/tmp-angstrom_next-uclibc/sysroots/x86_64-linux/usr/lib/mips32-angstrom-linux-uclibc --includedir=/home/kraj/angstrom/build/tmp-angstrom_next-uclibc/sysroots/x86_64-linux/usr/include --oldincludedir=/home/kraj/angstrom/build/tmp-angstrom_next-uclibc/sysroots/x86_64-linux/usr/include --infodir=/home/kraj/angstrom/build/tmp-angstrom_next-uclibc/sysroots/x86_64-linux/usr/share/info --mandir=/home/kraj/angstrom/build/tmp-angstrom_next-uclibc/sysroots/x86_64-linux/usr/share/man --disable-silent-rules --disable-dependency-tracking --with-libtool-sysroot=/home/kraj/angstrom/build/tmp-angstrom_next-uclibc/sysroots/x86_64-linux --enable-clocale=generic --with-gnu-ld --enable-shared --enable-languages=c,c++ --enable-threads=posix --disable-multilib --enable-c99 --enable-long-long --enable-symvers=gnu --enable-libstdcxx-pch --program-prefix=mips-angstrom-linux-uclibc- --without-local-prefix --enable-target-optspace --enable-lto --enable-libssp --disable-bootstrap --disable-libmudflap --with-system-zlib --with-linker-hash-style=sysv --enable-linker-build-id --with-ppl=no --with-cloog=no --enable-checking=release --enable-cheaders=c_global --with-gxx-include-dir=/home/kraj/angstrom/build/tmp-angstrom_next-uclibc/sysroots/qemumips/usr/include/c++ --with-sysroot=/home/kraj/angstrom/build/tmp-angstrom_next-uclibc/sysroots/qemumips --with-build-sysroot=/home/kraj/angstrom/build/tmp-angstrom_next-uclibc/sysroots/qemumips --enable-poison-system-directories --disable-libunwind-exceptions --with-mpfr=/home/kraj/angstrom/build/tmp-angstrom_next-uclibc/sysroots/x86_64-linux/usr --with-system-zlib --disable-nls --disable-decimal-float --enable-__cxa_atexit Thread model: posix gcc version 4.9.0 20140316 (experimental) (GCC)