Topic: can't compile with -flto set

If I attempt to use link optimization ( -flto) I get the following error.
==============================================================================
Generating Makefile... Okay
==============================================================================
Compiling .\cycles.c
Compiling .\dualpart.c
Compiling .\predictor.f90
Generating target.exe
collect2.exe: fatal error: CreateProcess: No such file or directory
compilation terminated.
Error(E42): Last command making (target.exe) returned a bad status
Error(E02): Make execution terminated

* Failed *

The makefile is as follows; (note the ldir entries are as a result of me setting the search directories manually. Before, they were empty)
#
# Automagically generated by Approximatrix Simply Fortran 2.17
#
FC="C:\Program Files (x86)\Simply Fortran 2\mingw-w64\bin\gfortran.exe"
CC="C:\Program Files (x86)\Simply Fortran 2\mingw-w64\bin\gcc.exe"
AR="C:\Program Files (x86)\Simply Fortran 2\mingw-w64\bin\ar.exe"
WRC="C:\PROGRA~2\SIMPLY~1\MINGW-~1\bin\windres.exe"
RM=rm -f

IDIR=
# -I error: Directory C:\Users\Pete\AppData\Local\\sfpm\64\include does not exist

LDIR=-LC:/PROGRA~2/SIMPLY~1/MINGW-~1/X86_64~1/lib64 -LC:/PROGRA~2/SIMPLY~1/MINGW-~1/X86_64~1 -LC:/PROGRA~2/SIMPLY~1/MINGW-~1/X86_64~1/lib32 -LC:/PROGRA~2/SIMPLY~1/MINGW-~1/X86_64~1/lib
# -L error: Directory C:\Users\Pete\AppData\Local\\sfpm\64\lib does not exist


OPTFLAGS= -O3 -fgraphite-identity -floop-interchange -floop-strip-mine -floop-block -floop-parallelize-all -mtune=nehalem -march=nehalem

SPECIALFLAGS=$(IDIR)

RCFLAGS=-O coff

PRJ_FFLAGS=-flto -fschedule-insns -finline-functions -fopenmp -fno-underscoring -funroll-loops -msse3 -msse2 -mmmx -msse  -mfpmath=sse  -fopenmp

PRJ_CFLAGS=-std=gnu99 -fopenmp

PRJ_LFLAGS=-lgomp -lpthread

FFLAGS=$(SPECIALFLAGS) $(OPTFLAGS) $(PRJ_FFLAGS) -Jmodules

CFLAGS=$(SPECIALFLAGS) $(OPTFLAGS) $(PRJ_CFLAGS)


"build\cycles.o": ".\cycles.c"
    @echo Compiling .\cycles.c
    @$(CC) -c -o "build\cycles.o" $(CFLAGS) ".\cycles.c"


"build\dualpart.o": ".\dualpart.c"
    @echo Compiling .\dualpart.c
    @$(CC) -c -o "build\dualpart.o" $(CFLAGS) ".\dualpart.c"

"build\predictor.o": ".\predictor.f90"
    @echo Compiling .\predictor.f90
    @$(FC) -c -o "build\predictor.o" $(FFLAGS) ".\predictor.f90"
"modules\stuff.mod" : "build\predictor.o" .EXISTSONLY
    @echo Compiling .\predictor.f90
    @$(FC) -c -o "build\predictor.o" $(FFLAGS) ".\predictor.f90"

clean: .SYMBOLIC
    @echo Deleting build\cycles.o and related files
    @$(RM) "build\cycles.o"
    @echo Deleting build\dualpart.o and related files
    @$(RM) "build\dualpart.o"
    @echo Deleting build\predictor.o and related files
    @$(RM) "build\predictor.o" "modules\stuff.mod"
    @echo Deleting target.exe
    @$(RM) "target.exe"

"target.exe":  "build\cycles.o" "build\dualpart.o" "build\predictor.o"
    @echo Generating target.exe
    @$(FC) -o "target.exe" -static -fopenmp "build\cycles.o" "build\dualpart.o" "build\predictor.o" $(LDIR) $(PRJ_LFLAGS)

all: "target.exe" .SYMBOLIC

Re: can't compile with -flto set

I'll have to look into what's going wrong.  It sounds like there might be a problem with the configuration of the compiler and linker in Simply Fortran.  I can replicate the issue on my end.  For the time being, you'll need to disable link time optimizations.

Jeff Armstrong
Approximatrix, LLC

Re: can't compile with -flto set

Thank you! I have disabled it and will wait to see what you come up with!

Re: can't compile with -flto set

The compiler included with Simply Fortran 2.17 does not seem to have support for link-time optimizations included (which is our fault).  I'll make sure support is in 2.18, which will ship with an updated Fortran compiler (GNU Fortran 4.9.2).  The next version is only a few weeks away.

Jeff Armstrong
Approximatrix, LLC