Hi, I've been experimenting with link time optimization with GCC, and have run into an issue with some existing code: == Test scenario == - foo.c: int foo ( void ) { return 3; } - bar.c: #include <stdio.h> int foo( void ); int main ( void ) { printf("Foo returns: %d\n", foo()); return 0; } == Compilation == gcc -flto -O2 -c foo.c ar rcs libfoo.a foo.o gcc -flto -O2 -L. bar.c -lfoo -o myprog /tmp/ccGcDjka.ltrans0.ltrans.o: In function `main': ccGcDjka.ltrans0.o:(.text+0x5): undefined reference to `foo' collect2: error: ld returned 1 exit status However, if I directly include the foo object file: gcc -flto -O2 bar.c foo.o -o myprog The program links correctly. == GCC version == $ gcc -v Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.0/lto-wrapper Target: x86_64-unknown-linux-gnu Configured with: /build/gcc/src/gcc-4.9-20140507/configure --prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=https://bugs.archlinux.org/ --enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++ --enable-shared --enable-threads=posix --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-clocale=gnu --disable-libstdcxx-pch --disable-libssp --enable-gnu-unique-object --enable-linker-build-id --enable-cloog-backend=isl --disable-cloog-version-check --enable-lto --enable-plugin --enable-install-libiberty --with-linker-hash-style=gnu --disable-multilib --disable-werror --enable-checking=release Thread model: posix gcc version 4.9.0 20140507 (prerelease) (GCC) == Am I missing something? or is this a bug? I've tried to enable different verbosity settings in compiler and linker, but have been unable to find any clear reason for the error. Regards Henrik LIAB ApS