http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47241
Summary: lto not work on mingw32, reporting 'ld.exe: could not unlink output file' Product: gcc Version: 4.6.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: lto AssignedTo: unassig...@gcc.gnu.org ReportedBy: cool...@qq.com gcc 4.6.0 snapshot 20110108 compile following code with 'gcc-4 -v -flto test.c' #include <stdio.h> int main() { printf("Test\n"); return 0; } and get the following error message: Using built-in specs. COLLECT_GCC=D:\MinGW\bin\gcc-4.exe COLLECT_LTO_WRAPPER=d:/mingw/bin/../libexec/gcc/i686-pc-mingw32/4.6.0/lto-wrapper.exe Target: i686-pc-mingw32 Configured with: ../gcc-4.6-20110108/configure --prefix=/gcc4 --program-suffix=-4 --with-gnu-as --with-gnu-ld --enable-threads --disable-shared --disable-win32-registry --disable-werror --disable-nls --disable-libquadmath --disable-bootstrap Thread model: win32 gcc version 4.6.0 20110108 (experimental) (GCC) COLLECT_GCC_OPTIONS='-v' '-flto' '-mtune=generic' '-march=pentiumpro' d:/mingw/bin/../libexec/gcc/i686-pc-mingw32/4.6.0/cc1.exe -quiet -v -iprefix d:\mingw\bin\../lib/gcc/i686-pc-mingw32/4.6.0/ test.c -quiet -dumpbase test.c -mtune=generic -march=pentiumpro -auxbase test -version -flto -o C:\Users\coolypf\AppData\Local\Temp\ccZ46Rlb.s GNU C (GCC) version 4.6.0 20110108 (experimental) (i686-pc-mingw32) compiled by GNU C version 4.6.0 20110101 (experimental), GMP version 5.0.1, MPFR version 3.0.0, MPC version 0.8.2 GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096 ignoring nonexistent directory "d:\mingw\bin\../lib/gcc/i686-pc-mingw32/4.6.0/../../../../i686-pc-mingw32/include" ignoring duplicate directory "d:/mingw/lib/gcc/../../lib/gcc/i686-pc-mingw32/4.6.0/include" ignoring nonexistent directory "D:/MinGW/gcc4/include" ignoring nonexistent directory "/gcc4/include" ignoring duplicate directory "d:/mingw/lib/gcc/../../lib/gcc/i686-pc-mingw32/4.6.0/include-fixed" ignoring nonexistent directory "d:/mingw/lib/gcc/../../lib/gcc/i686-pc-mingw32/4.6.0/../../../../i686-pc-mingw32/include" ignoring duplicate directory "/mingw/include" #include "..." search starts here: #include <...> search starts here: d:\mingw\bin\../lib/gcc/i686-pc-mingw32/4.6.0/include d:\mingw\bin\../lib/gcc/i686-pc-mingw32/4.6.0/../../../../include d:\mingw\bin\../lib/gcc/i686-pc-mingw32/4.6.0/include-fixed End of search list. GNU C (GCC) version 4.6.0 20110108 (experimental) (i686-pc-mingw32) compiled by GNU C version 4.6.0 20110101 (experimental), GMP version 5.0.1, MPFR version 3.0.0, MPC version 0.8.2 GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096 Compiler executable checksum: c752079cf4e558b53a88eee0a5828d49 COLLECT_GCC_OPTIONS='-v' '-flto' '-mtune=generic' '-march=pentiumpro' as -v -o C:\Users\coolypf\AppData\Local\Temp\cc0lkcdl.o C:\Users\coolypf\AppData\Local\Temp\ccZ46Rlb.s GNU assembler version 2.21.51 (i686-pc-mingw32) using BFD version (GNU Binutils) 2.21.51.20110109 COMPILER_PATH=d:/mingw/bin/../libexec/gcc/i686-pc-mingw32/4.6.0/;d:/mingw/bin/../libexec/gcc/ LIBRARY_PATH=d:/mingw/bin/../lib/gcc/i686-pc-mingw32/4.6.0/;d:/mingw/bin/../lib/gcc/;d:/mingw/bin/../lib/gcc/i686-pc-mingw32/4.6.0/../../../;/mingw/lib/ COLLECT_GCC_OPTIONS='-v' '-flto' '-mtune=generic' '-march=pentiumpro' d:/mingw/bin/../libexec/gcc/i686-pc-mingw32/4.6.0/collect2.exe -plugin d:/mingw/bin/../libexec/gcc/i686-pc-mingw32/4.6.0/liblto_plugin-0.dll -plugin-opt=d:/mingw/bin/../libexec/gcc/i686-pc-mingw32/4.6.0/lto-wrapper.exe -plugin-opt=-fresolution=C:\Users\coolypf\AppData\Local\Temp\ccAKIfIl.res -plugin-opt=-pass-through=-lmingw32 -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lmoldname -plugin-opt=-pass-through=-lmingwex -plugin-opt=-pass-through=-lmsvcrt -plugin-opt=-pass-through=-ladvapi32 -plugin-opt=-pass-through=-lshell32 -plugin-opt=-pass-through=-luser32 -plugin-opt=-pass-through=-lkernel32 -plugin-opt=-pass-through=-lmingw32 -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lmoldname -plugin-opt=-pass-through=-lmingwex -plugin-opt=-pass-through=-lmsvcrt -flto -Bdynamic d:/mingw/bin/../lib/gcc/i686-pc-mingw32/4.6.0/../../../crt2.o d:/mingw/bin/../lib/gcc/i686-pc-mingw32/4.6.0/crtbegin.o -Ld:/mingw/bin/../lib/gcc/i686-pc-mingw32/4.6.0 -Ld:/mingw/bin/../lib/gcc -Ld:/mingw/bin/../lib/gcc/i686-pc-mingw32/4.6.0/../../.. -L/mingw/lib C:\Users\coolypf\AppData\Local\Temp\cc0lkcdl.o -lmingw32 -lgcc -lmoldname -lmingwex -lmsvcrt -ladvapi32 -lshell32 -luser32 -lkernel32 -lmingw32 -lgcc -lmoldname -lmingwex -lmsvcrt d:/mingw/bin/../lib/gcc/i686-pc-mingw32/4.6.0/crtend.o D:\MinGW\bin\gcc-4.exe @C:\Users\coolypf\AppData\Local\Temp\ccOgvLTl.args Using built-in specs. COLLECT_GCC=D:\MinGW\bin\gcc-4.exe COLLECT_LTO_WRAPPER=d:/mingw/lib/gcc/../../libexec/gcc/i686-pc-mingw32/4.6.0/lto-wrapper.exe Target: i686-pc-mingw32 Configured with: ../gcc-4.6-20110108/configure --prefix=/gcc4 --program-suffix=-4 --with-gnu-as --with-gnu-ld --enable-threads --disable-shared --disable-win32-registry --disable-werror --disable-nls --disable-libquadmath --disable-bootstrap Thread model: win32 gcc version 4.6.0 20110108 (experimental) (GCC) COLLECT_GCC_OPTIONS='-c' '-v' '-mtune=generic' '-march=pentiumpro' '-fltrans-output-list=C:\Users\coolypf\AppData\Local\Temp\ccuIPX1f.ltrans.out' '-fwpa' '-fresolution=C:\Users\coolypf\AppData\Local\Temp\ccAKIfIl.res' d:/mingw/lib/gcc/../../libexec/gcc/i686-pc-mingw32/4.6.0/lto1.exe -quiet -dumpbase cc0lkcdl.o -mtune=generic -march=pentiumpro -auxbase cc0lkcdl -version -fltrans-output-list=C:\Users\coolypf\AppData\Local\Temp\ccuIPX1f.ltrans.out -fwpa -fresolution=C:\Users\coolypf\AppData\Local\Temp\ccAKIfIl.res @C:\Users\coolypf\AppData\Local\Temp\cc2biTYe GNU GIMPLE (GCC) version 4.6.0 20110108 (experimental) (i686-pc-mingw32) compiled by GNU C version 4.6.0 20110101 (experimental), GMP version 5.0.1, MPFR version 3.0.0, MPC version 0.8.2 GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096 GNU GIMPLE (GCC) version 4.6.0 20110108 (experimental) (i686-pc-mingw32) compiled by GNU C version 4.6.0 20110101 (experimental), GMP version 5.0.1, MPFR version 3.0.0, MPC version 0.8.2 GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096 COMPILER_PATH=d:/mingw/lib/gcc/../../libexec/gcc/i686-pc-mingw32/4.6.0/;d:/mingw/lib/gcc/../../libexec/gcc/;d:/mingw/bin/../libexec/gcc/i686-pc-mingw32/4.6.0/;d:/mingw/bin/../libexec/gcc/i686-pc-mingw32/4.6.0/;d:/mingw/bin/../libexec/gcc/ LIBRARY_PATH=d:/mingw/bin/../lib/gcc/i686-pc-mingw32/4.6.0/;d:/mingw/bin/../lib/gcc/;d:/mingw/bin/../lib/gcc/i686-pc-mingw32/4.6.0/;d:/mingw/bin/../lib/gcc/i686-pc-mingw32/4.6.0/;d:/mingw/bin/../lib/gcc/;d:/mingw/bin/../lib/gcc/i686-pc-mingw32/4.6.0/../../../;/mingw/lib/;d:/mingw/bin/../lib/gcc/i686-pc-mingw32/4.6.0/../../../;/mingw/lib/ COLLECT_GCC_OPTIONS='-c' '-v' '-mtune=generic' '-march=pentiumpro' '-fltrans-output-list=C:\Users\coolypf\AppData\Local\Temp\ccuIPX1f.ltrans.out' '-fwpa' '-fresolution=C:\Users\coolypf\AppData\Local\Temp\ccAKIfIl.res' D:\MinGW\bin\gcc-4.exe @C:\Users\coolypf\AppData\Local\Temp\ccK0v2Xy.args Using built-in specs. COLLECT_GCC=D:\MinGW\bin\gcc-4.exe COLLECT_LTO_WRAPPER=d:/mingw/lib/gcc/../../libexec/gcc/i686-pc-mingw32/4.6.0/lto-wrapper.exe Target: i686-pc-mingw32 Configured with: ../gcc-4.6-20110108/configure --prefix=/gcc4 --program-suffix=-4 --with-gnu-as --with-gnu-ld --enable-threads --disable-shared --disable-win32-registry --disable-werror --disable-nls --disable-libquadmath --disable-bootstrap Thread model: win32 gcc version 4.6.0 20110108 (experimental) (GCC) COLLECT_GCC_OPTIONS='-c' '-v' '-mtune=generic' '-march=pentiumpro' '-fltrans' '-o' 'C:\Users\coolypf\AppData\Local\Temp\ccuIPX1f.ltrans0.ltrans.o' d:/mingw/lib/gcc/../../libexec/gcc/i686-pc-mingw32/4.6.0/lto1.exe -quiet -dumpbase ccuIPX1f.ltrans0.o -mtune=generic -march=pentiumpro -auxbase-strip C:\Users\coolypf\AppData\Local\Temp\ccuIPX1f.ltrans0.ltrans.o -version -fltrans @C:\Users\coolypf\AppData\Local\Temp\cc0meYVk -o C:\Users\coolypf\AppData\Local\Temp\ccQziMHv.s GNU GIMPLE (GCC) version 4.6.0 20110108 (experimental) (i686-pc-mingw32) compiled by GNU C version 4.6.0 20110101 (experimental), GMP version 5.0.1, MPFR version 3.0.0, MPC version 0.8.2 GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096 GNU GIMPLE (GCC) version 4.6.0 20110108 (experimental) (i686-pc-mingw32) compiled by GNU C version 4.6.0 20110101 (experimental), GMP version 5.0.1, MPFR version 3.0.0, MPC version 0.8.2 GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096 COLLECT_GCC_OPTIONS='-c' '-v' '-mtune=generic' '-march=pentiumpro' '-fltrans' '-o' 'C:\Users\coolypf\AppData\Local\Temp\ccuIPX1f.ltrans0.ltrans.o' as -v -o C:\Users\coolypf\AppData\Local\Temp\ccuIPX1f.ltrans0.ltrans.o C:\Users\coolypf\AppData\Local\Temp\ccQziMHv.s GNU assembler version 2.21.51 (i686-pc-mingw32) using BFD version (GNU Binutils) 2.21.51.20110109 COMPILER_PATH=d:/mingw/lib/gcc/../../libexec/gcc/i686-pc-mingw32/4.6.0/;d:/mingw/lib/gcc/../../libexec/gcc/;d:/mingw/bin/../libexec/gcc/i686-pc-mingw32/4.6.0/;d:/mingw/bin/../libexec/gcc/i686-pc-mingw32/4.6.0/;d:/mingw/bin/../libexec/gcc/ LIBRARY_PATH=d:/mingw/bin/../lib/gcc/i686-pc-mingw32/4.6.0/;d:/mingw/bin/../lib/gcc/;d:/mingw/bin/../lib/gcc/i686-pc-mingw32/4.6.0/;d:/mingw/bin/../lib/gcc/i686-pc-mingw32/4.6.0/;d:/mingw/bin/../lib/gcc/;d:/mingw/bin/../lib/gcc/i686-pc-mingw32/4.6.0/../../../;/mingw/lib/;d:/mingw/bin/../lib/gcc/i686-pc-mingw32/4.6.0/../../../;/mingw/lib/ COLLECT_GCC_OPTIONS='-c' '-v' '-mtune=generic' '-march=pentiumpro' '-fltrans' '-o' 'C:\Users\coolypf\AppData\Local\Temp\ccuIPX1f.ltrans0.ltrans.o' D:\MinGW\bin/ld.exe: could not unlink output file collect2: ld returned 1 exit status gcc 4.6.0 snapshot 20110101 works fine with '-flto' so changes between 1/1 and 1/8 cause lto failure on mingw32