executable size
Calvin H. Vu
calvin at dinkum.sgi.com
Thu Mar 1 10:03:05 AEST 1990
I planned to e-mail this to glennrp at brl.mil to respond to his question
but since so many people seem to be unaware of this I will make a general
posting instead. Here it goes:
----------------------------------------------------------------------
By defaults, f77 uses the libmpc.a library to allow multiprocessing
system calls. This MP capability adds about 70K to the executable
size as compared to the standard libc.a library. If you can use the
shared C library you can cut another 30K from your executable.
To use the standard libc.a library all you need to do is to replace the
f77 driver with the cc driver i.e. use: (BTW, this will also make your
executable runs marginally faster if you don't need MP Fortran)
cc -g -G 0 *.o -lfgl -lgl_s
instead of:
f77 -g -G 0 *.o -lfgl -lgl_s
To use the shared libc_s.a library, you need to include all Fortran
runtime libraries before the -lc_s to make sure that all C systems calls
will be resolved by using the shared library, not the libc.a library. In
other words, use:
cc -g -G 0 *.o -lfgl -lgl_s -lF77 -lI77 -lU77 -lisam -lm -lc_s
The multiply-defined warnings you get when using -lc_s on the command
line stems from the fact that those multiply-defined routines
are resolved in libc_s.a but are also defined in libmpc.a. This should be
O.K. unless you do want to use MP Fortran. In that case forget everything
I said above and just use the default f77 driver. The additional
100K is the price you have to pay for this extra MP capability and you
will need every bit of it (pun intended).
Another major factor which makes Fortran executable size much bigger than
C is the libisam.a library which adds over 100K to the size. Currently,
this ISAM library is intertwined with the standard runtime I/O library
(libI77.a) and will be dragged in even if you do not need ISAM capability.
In future releases, we will remove this interdependency to reduce the size
of the executable.
And of course you can use 'strip' to make the executable even smaller.
All in all, after everything is said AND DONE :-), the size of a simple
'hello world' program can probably be reduced from 310K to under 60K.
Right now, if you apply all the tricks above you can reduce it to about
140K. Oh well, you never have a REAL Fortran program which is less than
1M anyway, so an extra 100K of overhead is nothing. Right ? Right ?
Hmmm, I guess I can't take over Johny Carson's job yet :-).
BTW, if you don't have the standard 4 gigabytes of disk space on your
standard Unix system and are desperate enough to to go after the 100K+
added by libisam.a you can remove -lisam from the linker command line
generated by 'f77 -v' and get a list of undefined references then use
dummy procedures for all of them. This is royally painful, but
as I said, if you are desperate ...
Calvin Vu
-----------------------------------------------------------------------
"Don't blame it on RISC. Just blame it on FORTRAN and Rio"
More information about the Comp.sys.sgi
mailing list