Re: Compile and link optimization using gfortran

Hifi-Comp wrote:
On Jun 21, 10:25 am, "e p chandler" <e...@xxxxxxxx> wrote:
"fj" <francois.j...@xxxxxxx> wrote in message


On 21 juin, 04:24, Hifi-Comp <wenbinyu.hea...@xxxxxxxxx> wrote:
On Jun 20, 3:21 am, baf <b...@xxxxxxxxxxx> wrote:
Hifi-Comp wrote:
On Jun 19, 1:31 pm, baf <b...@xxxxxxxxxxx> wrote:
Tobias Burnus wrote:
Hifi-Comp wrote:
I am using gfortran on windows. -flto is not available for win32
version 4.6.0 20100524.
The new build of gfortran for windows is now available at the same link
as you list above. I tested it with -flto and it produced an
that ran fine. The compiler will also install the latest version of
binutilts (2.20.51).- Hide quoted text -
Thanks. I downloaded the updated build. However, when I compile the
codes according to case 3 given by Steve's post. I get the following
error message:
c:/program files/gfortran/bin/../lib/gcc/i586-pc-
32.a(main.o):main.c:(.text+0xd2): undefined reference to `WinMain@16'
collect2: ld returned 1 exit status
I got the same message this morning because I forgot to link with the
main program !
Strange. I usually use G95 and I get a different message, an undefined
reference to _MAIN.
gfortran gives the message above. Interesting. I have not used gfortran
enough to make this mistake on my own. [smile]

-- e- Hide quoted text -

- Show quoted text -

I uninstalled and reinstalled. Still getting the same error message.
My system is WinXP SP3.

I used the code that you provided in your original post and got the following results with the build of the compiler currently available. Looks like there is only a minor "penalty" for using separate files for the modules and main program. I suspect that the problem you are reporting with the linker is due to an old version of ld in the $PATH prior to the new version provided with the latest compiler package.

D:\fortran\test>gfortran -v
Using built-in specs.
COLLECT_LTO_WRAPPER=c:/program files/gfortran/bin/../libexec/gcc/i586-pc-mingw32
Target: i586-pc-mingw32
Configured with: ../gcc-trunk/configure --prefix=/mingw
--enable-languages=c,fortran --with-gmp=/home/brad/gfortran/dependencies
--disable-werror --enable-threads --disable-nls --build=i586-pc-mingw32
--enable-libgomp --disable-shared --disable-win32-registry
--with-dwarf2 --disable-sjlj-exceptions --enable-lto
Thread model: win32
gcc version 4.6.0 20100620 (experimental) [trunk revision 161045] (GCC)

D:\fortran\test>gfortran -O3 -ffast-math -march=native -fwhole-file -flto onefile.f90 -o onefile

Analysis Runs for 9.30000022E-02 Seconds.
DNAD Runs for 0.11000000 Seconds.
-19999999.999990787 25000000.000000000

D:\fortran\test>gfortran -c -O3 -ffast-math -march=native -fwhole-file -flto cputime.f90

D:\fortran\test>gfortran -c -O3 -ffast-math -march=native -fwhole-file -flto dnad.f90

D:\fortran\test>gfortran -c -O3 -ffast-math -march=native -fwhole-file -flto main.f90

Analysis Runs for 9.39999968E-02 Seconds.
DNAD Runs for 0.11000000 Seconds.
-19999999.999990787 25000000.000000000