[gnu.gcc] linking gcc object files on vax/vms

mkemi@jupiter.dk (Morten Kjeldsgaard) (07/07/89)

I have just installed gcc version 1.35 on our microvax II. My first program
was (of course) good old "Hello, world". I link my 1 block .OBJ file 
like this:

   $ link hello, sys$library:vaxcrtl/lib

and the resulting executable is 87 blocks!! A bit excessive for the most
minimal program possible! 

Any suggestions as how to decrease the .EXE file size would be most welcome!!

 ---
Morten Kjeldgaard, mok@kemi.aau.dk
Dept. of Chemistry, Aarhus University,
Langelandsgade 140, DK-8000 Aarhus C, Denmark

albaugh@dms.UUCP (Mike Albaugh) (07/08/89)

From article <2686@daimi.dk>, by mkemi@jupiter.dk (Morten Kjeldsgaard):
>    $ link hello, sys$library:vaxcrtl/lib
> 
> and the resulting executable is 87 blocks!! A bit excessive for the most
> minimal program possible! 
> 
> Any suggestions as how to decrease the .EXE file size would be most welcome!!

As with Vax11c, the trick is use of shared libraries. The command:

	$ link hello, share.opt/opt	! see below

produces a 4 block file(I just tried it with 1.34). The "magic" in share.opt
is a single line:

	sys$library:vaxcrtl.exe/share

Two caveats:

	The classic "hello" will probably exit with an error message of
some sort because it returns dust to the caller, which is interpreted
as an error code. An explicit return fixes this.

	I anticipated a problem with errno, as it is usually declared
(in vax11c) as "extern noshare int errno", but GCC does not know about the
vax11c extension keyword "noshare". However, David Kashtan apparently _also_
anticipated such a problem so there is a hack in the stdio.h and errno.h
files to take care of it. Just be sure to #include these files if you use
stdio or errno.

Some of you might prefer:

$ link hello,sys$input/opt
sys$library:vaxcrtl.exe/share

which is easily placed in your makefile.

	Yes, folks, I would have mailed, but this looked like the rare case
where more than one person might benefit from the info. I was also unsure
whether David Kashtan would respond this way, since this trick is not
included in the GCC/VMS write-up. Be happy :-)

					Mike

| Mike Albaugh (albaugh@dms.UUCP || {...decwrl!turtlevax!}weitek!dms!albaugh)
| Atari Games Corp (Arcade Games, no relation to the makers of the ST)
| 675 Sycamore Dr. Milpitas, CA 95035		voice: (408)434-1709
| The opinions expressed are my own (Boy, are they ever)

desnoyer@apple.com (Peter Desnoyers) (07/08/89)

In article <2686@daimi.dk> mkemi@jupiter.dk (Morten Kjeldsgaard) writes:
>  I link my 1 block .OBJ file 
> like this:
>    $ link hello, sys$library:vaxcrtl/lib
> and the resulting executable is 87 blocks!! A bit excessive for the most
> minimal program possible! 

Your link probably took a good fraction of a CPU minute, as well. 
I seem to remember (it's been over two years since I touched VMS) that 
you can link with a shareable image, with the result that your link will 
take mere seconds and your  executable will be little bigger than your 
.OBJ file.

The more I think of it, the more I think that
  $link hello /share=sys$library:vaxcrtl.exe
will work. (or maybe sys$share instead of sys$library.) 

                                      Peter Desnoyers
                                      Apple ATG
                                      (408) 974-4469

phws00::wood%phvax.dnet@SMITHKLINE.COM (Bill Wood, SmithKline &French R&D 215-2705163) (07/10/89)

>I link my 1 block .OBJ file 
>like this:
>
>   $ link hello, sys$library:vaxcrtl/lib
>
>and the resulting executable is 87 blocks!! A bit excessive for the most
>minimal program possible! 
>
>Any suggestions as how to decrease the .EXE file size would be most welcome!!


You should link vaxcrtl in as a shared library, as follows:

	$ link hello,sys$input:/opt
	sys$share:vaxcrtl/share

That should reduce the size to 5-10 blocks.

- Bill    wood@smithkline.com

rick@ut-emx.UUCP (Rick Watson) (07/11/89)

> The more I think of it, the more I think that
>   $link hello /share=sys$library:vaxcrtl.exe
> will work. (or maybe sys$share instead of sys$library.) 

NO! NO! NO! This will attempt to write over sys$library:vaxcrtl.exe.  Please
do not think; read the manual.  :-)

my favorite is:

$link hello/opt

where hello.opt contains:
hello,sys$share:vaxcrtl/share

Rick Watson
The University of Texas Computation Center
 arpa:   watson@utadnx.cc.utexas.edu (128.83.1.26)
 uucp:   ...cs.utexas.edu!ut-emx!rick
 bitnet: watson@utadnx
 span:   utspan::watson (UTSPAN is 25.128)
 phone:  512/471-8220 512/471-3241

scott@fred.cs.washington.edu (Scott Northrop) (07/28/89)

(mkemi@jupiter.dk writes:)

	How do I reduce the size of my executables?

Link to the shareable image that is always in memory - that way your
executable uses code that it doesn't carry around. Like so:

$ link hello, sys$library:vaxcrtl.exe/share

That should bring the executable down to a more manageable size, like 3k.

scott@fred.cs.washington.edu (Scott Northrop) (07/30/89)

In article <8832@june.cs.washington.edu> scott@fred.cs.washington.edu (Scott Northrop) writes:
>(mkemi@jupiter.dk writes:)
>>	How do I reduce the size of my executables?
>Link to the shareable image that is always in memory - that way your
>executable uses code that it doesn't carry around. Like so:
>	$ link hello, sys$library:vaxcrtl.exe/share
>That should bring the executable down to a more manageable size, like 3k.

Boy, I screwed the pooch on that one. It's sys$share, not sys$library, and you
should have it and the non-shareable library in an option file. Take #2:

	$ create c.opt
	sys$library:vaxcrtl.olb/library
	sys$share:vaxcrtl.exe/share
	^Z
	$ link hello, c.opt/opt