Topic: -flto option creates a collect2.exe error

Hi,
If I try to compile with the -flto option to enable link time optimizations, I get this error;
Generating sieve2.exe
Driving: C:\Program Files (x86)\Simply Fortran 2\mingw-w64\bin\gfortran.exe -v -o sieve2.exe -static build\sieve2.o -LC:/PROGRA~2/SIMPLY~1/MINGW-~1/lib/ -l gfortran
Using built-in specs.
COLLECT_GCC=C:\Program Files (x86)\Simply Fortran 2\mingw-w64\bin\gfortran.exe
COLLECT_LTO_WRAPPER=c:/program\ files\ (x86)/simply\ fortran\ 2/mingw-w64/bin/../libexec/gcc/x86_64-w64-mingw32/7.2.0/lto-wrapper.exe
Target: x86_64-w64-mingw32
Configured with: ../../src/gcc-7.2.0/configure --target=x86_64-w64-mingw32 --enable-targets=all --enable-languages=c,c++,fortran,lto --prefix=/opt --with-sysroot=/opt --with-gmp=/c/workspace/gcc/dep-6.1.0 --with-mpfr=/c/workspace/gcc/dep-6.1.0 --with-mpc=/c/workspace/gcc/dep-6.1.0 --disable-win32-registry --enable-libgomp --enable-gomp --with-isl=/c/workspace/gcc/dep-6.1.0 --with-cloog=/c/workspace/gcc/dep-6.1.0 --with-libelf=/c/workspace/gcc/dep-6.1.0 --disable-libstdcxx-pch --enable-target-optspace --with-tune=generic --with-pkgversion='GCC for Simply Fortran' --with-bugurl=http://simplyfortran.com/support/ --enable-lto --enable-plugins --enable-linker-plugin-configure-flags=--host=i686-pc-mingw32 --enable-linker-plugin-flags='CC=gcc\ -m32\ -Wl,-rpath,[...]/i686-pc-mingw32/lib'
Thread model: win32
gcc version 7.2.0 (GCC for Simply Fortran)
Reading specs from c:/program files (x86)/simply fortran 2/mingw-w64/bin/../lib/gcc/x86_64-w64-mingw32/7.2.0/../../../../x86_64-w64-mingw32/lib/../lib/libgfortran.spec
rename spec lib to liborig
COLLECT_GCC_OPTIONS='-v' '-o' 'sieve2.exe' '-static' '-LC:/PROGRA~2/SIMPLY~1/MINGW-~1/lib/' '-mtune=generic' '-march=x86-64'
COMPILER_PATH=c:/program files (x86)/simply fortran 2/mingw-w64/bin/../libexec/gcc/x86_64-w64-mingw32/7.2.0/;c:/program files (x86)/simply fortran 2/mingw-w64/bin/../libexec/gcc/;c:/program files (x86)/simply fortran 2/mingw-w64/bin/../lib/gcc/x86_64-w64-mingw32/7.2.0/../../../../x86_64-w64-mingw32/bin/
LIBRARY_PATH=c:/program files (x86)/simply fortran 2/mingw-w64/bin/../lib/gcc/x86_64-w64-mingw32/7.2.0/;c:/program files (x86)/simply fortran 2/mingw-w64/bin/../lib/gcc/;c:/program files (x86)/simply fortran 2/mingw-w64/bin/../lib/gcc/x86_64-w64-mingw32/7.2.0/../../../../x86_64-w64-mingw32/lib/../lib/;c:/program files (x86)/simply fortran 2/mingw-w64/bin/../lib/gcc/x86_64-w64-mingw32/7.2.0/../../../../x86_64-w64-mingw32/lib/
COLLECT_GCC_OPTIONS='-v' '-o' 'sieve2.exe' '-static' '-LC:/PROGRA~2/SIMPLY~1/MINGW-~1/lib/' '-mtune=generic' '-march=x86-64'
c:/program files (x86)/simply fortran 2/mingw-w64/bin/../libexec/gcc/x86_64-w64-mingw32/7.2.0/collect2.exe --sysroot=c:/workspace/gcc/target -m i386pep -Bstatic -o sieve2.exe c:/program files (x86)/simply fortran 2/mingw-w64/bin/../lib/gcc/x86_64-w64-mingw32/7.2.0/../../../../x86_64-w64-mingw32/lib/../lib/crt2.o c:/program files (x86)/simply fortran 2/mingw-w64/bin/../lib/gcc/x86_64-w64-mingw32/7.2.0/crtbegin.o -LC:/PROGRA~2/SIMPLY~1/MINGW-~1/lib/ -Lc:/program files (x86)/simply fortran 2/mingw-w64/bin/../lib/gcc/x86_64-w64-mingw32/7.2.0 -Lc:/program files (x86)/simply fortran 2/mingw-w64/bin/../lib/gcc -Lc:/program files (x86)/simply fortran 2/mingw-w64/bin/../lib/gcc/x86_64-w64-mingw32/7.2.0/../../../../x86_64-w64-mingw32/lib/../lib -Lc:/program files (x86)/simply fortran 2/mingw-w64/bin/../lib/gcc/x86_64-w64-mingw32/7.2.0/../../../../x86_64-w64-mingw32/lib build\sieve2.o -lgfortran -lmingw32 -lgcc -lgcc_eh -lmoldname -lmingwex -lmsvcrt -lquadmath -lm -lmingw32 -lgcc -lgcc_eh -lmoldname -lmingwex -lmsvcrt -ladvapi32 -lshell32 -luser32 -lkernel32 -lmingw32 -lgcc -lgcc_eh -lmoldname -lmingwex -lmsvcrt c:/program files (x86)/simply fortran 2/mingw-w64/bin/../lib/gcc/x86_64-w64-mingw32/7.2.0/crtend.o
collect2.exe: fatal error: CreateProcess: No such file or directory
compilation terminated.
Error: Last command making (sieve2.exe) returned a bad status
Error: Make execution terminated

Any clues?? Everything in the path appears to be where it needs to be.
This line looked suspect but I don't see how to modify it..
COLLECT_LTO_WRAPPER=c:/program\ files\ (x86)/simply\ fortran\ 2/mingw-w64/bin/../libexec/gcc/x86_64-w64-mingw32/7.2.0/lto-wrapper.exe
Regards,
Pete

Re: -flto option creates a collect2.exe error

I'll have to see why exactly the error is occurring, but my understanding is that our build of GNU binutils and its linker, ld, does not support link-time optimizations.  I believe the CreateProcess error is the compiler attempting to call an nonexistent alternate linker.

Jeff Armstrong
Approximatrix, LLC

Re: -flto option creates a collect2.exe error

Hi Jeff,
Is it possible to release a version of the compiler that supports run time link optimization?
Thanks,
Pete

Re: -flto option creates a collect2.exe error

Pete,

I can look into it, but it isn't a simple change.  I believe our binutils distribution somewhat dated for compatibility reasons, which might be problematic.

Jeff Armstrong
Approximatrix, LLC