https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69003
Bug ID: 69003 Summary: Undefined reference with gcc -r incremental linking Product: gcc Version: 6.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: lto Assignee: unassigned at gcc dot gnu.org Reporter: sirl at gcc dot gnu.org Target Milestone: --- Created attachment 37096 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=37096&action=edit Testcase, use 'gmake all'. The attached testcase doesn't link with gcc-6 r231874 on x86_64-linux-gnu: gcc-6 -flto -fuse-linker-plugin -O2 -fno-common -Wall -Wextra -c file1.c gcc-6 -flto -fuse-linker-plugin -O2 -fno-common -Wall -Wextra -c file2.c file3.c gcc-6 -flto -fuse-linker-plugin -O2 -fno-common -Wall -Wextra -DSTATICMODE -c file3.c -o file3s.o g++-6 -flto -fuse-linker-plugin -r -nostdlib -o lib1.lib file1.o file3.o g++-6 -flto -fuse-linker-plugin -r -nostdlib -o lib2.lib file2.o file3s.o g++-6 -flto -fuse-linker-plugin -O2 -o testexe lib1.lib lib2.lib lib2.lib: In function `t1': (.text+0x23): undefined reference to `mode.lto_priv.0' collect2: error: ld returned 1 exit status The testcase links fine without LTO.