www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/07/09/02:32:10

From: "John M. Aldrich" <fighteer AT cs DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Fat exe files with gcc 271
Date: Tue, 08 Jul 1997 20:07:34 +0000
Organization: Two pounds of chaos and a pinch of salt
Lines: 43
Message-ID: <33C29E06.6CBF@cs.com>
References: <33C21932 DOT 2864 AT memco DOT co DOT il>
Reply-To: fighteer AT cs DOT com
NNTP-Posting-Host: ppp211.cs.com
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

ON wrote:
> 
> I've compiled a 40 line program with gcc (djgpp v201) and I got a 90k
> exe file !!
> 
> That's 10 times what I would get with Turbo-C.
> 
> The debug info counts for about 2k, so it makes it 88K.
> 
> I know gcc inserts a stub in the exe file, but it still doesn't explain
> 88K.

Please read the FAQ, chapter 8.15.  Protected mode programs have a great
deal of overhead that is not needed by 16-bit code, but this overhead is
static; it does not grow as your program grows.  In any case, comparing
16-bit and 32-bit code is like comparing grapes and watermelons; they
are significantly different in many ways.

Some things to consider:

- Did you really try stripping all of the debugging code ('-s' switch
during the link stage)?  This can reduce executable size by 40% or more.
- If your program doesn't need command line wildcard expansion, loading
of the DJGPP environment file, or command line arguments at all, you can
remove any of these pieces of functionality to reduce your code size. 
See the aforementioned FAQ section.
- Each library function you use links in additional code, and much of
this has more functionality than the equivalent Turbo C code.  Try
substituting puts() for printf(), or gets() and atoi() for scanf().
- C++ generates much larger executables than C.
- You can pack DJGPP executables with the DJP compressor found in the
mlp105b.zip package.

But really, you can't expect to judge the size of 32-bit code from a 40
line program.  Write a real program and you'll see the difference.

-- 
---------------------------------------------------------------------
|      John M. Aldrich       | "Animals can be driven crazy by pla- |
|       aka Fighteer I       | cing too many in too small a pen.    |
|   mailto:fighteer AT cs DOT com   | Homo sapiens is the only animal that |
| http://www.cs.com/fighteer | voluntarily does this to himself."   |
---------------------------------------------------------------------

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019