https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63215
Bug ID: 63215 Summary: LTO causes symbols for builtin functions to be omitted from object files Product: gcc Version: 4.9.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: lto Assignee: unassigned at gcc dot gnu.org Reporter: patrick at motec dot com.au -flto causes symbols for builtin functions to be omitted from object files. Specifying -fno-builtin generates the symbols again. This causes problems when these files are combined into an archive and used for later linking as the linker can't resolve the symbols. For example: abs.c: int abs(int j) { return j < 0 ? -j : j; } Normal compile: $ powerpc-eabispe-gcc -c abs.c -o abs.o $ powerpc-eabispe-gcc-nm abs.o 00000000 T abs Compile with lto: $ powerpc-eabispe-gcc -flto -c abs.c -o abs_lto.o $ powerpc-eabispe-gcc-nm abs_lto.o /home/patrick/toolchain/lib/gcc/powerpc-eabispe/4.9.1/../../../../powerpc-eabispe/bin/nm: abs_lto.o: no symbols Compile with lto and no-builtin: $ powerpc-eabispe-gcc -fno-builtin -flto -c abs.c -o abs_lto_nobuiltin.o $ powerpc-eabispe-gcc-nm abs_lto_nobuiltin.o 00000000 T abs Here is the output of gcc -v $ powerpc-eabispe-gcc -v Using built-in specs. COLLECT_GCC=powerpc-eabispe-gcc COLLECT_LTO_WRAPPER=/home/patrick/src/e7/toolchain/stage2/libexec/gcc/powerpc-eabispe/4.9.1/lto-wrapper Target: powerpc-eabispe Configured with: /home/patrick/src/e7/toolchain/src/gcc-4.9.1/configure --prefix=/home/patrick/src/e7/toolchain/stage2 --build=x86_64-unknown-linux-gnu --host=x86_64-unknown-linux-gnu --target=powerpc-eabispe --enable-languages=c,c++ --with-sysroot=/home/patrick/src/e7/toolchain/../prex_sysroot --disable-nls --disable-werror --with-newlib --with-gmp=/home/patrick/src/e7/toolchain/stage2 --with-mpfr=/home/patrick/src/e7/toolchain/stage2 --disable-shared --disable-debug --disable-libssp --with-cpu=8540 Thread model: single gcc version 4.9.1 (GCC)