delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/05/18/14:17:11

From: mert0407 AT sable DOT ox DOT ac DOT uk (George Foot)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Why does gcc make such big binaries?
Date: 18 May 1997 14:02:24 GMT
Organization: Oxford University, England
Message-ID: <5ln25g$2p4@news.ox.ac.uk>
References: <Pine DOT OSF DOT 3 DOT 91 DOT 970518132348 DOT 61A-100000 AT hermes DOT otago DOT ac DOT nz>
NNTP-Posting-Host: sable.ox.ac.uk
Lines: 41
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Richard Collins (rcollins AT hermes DOT otago DOT ac DOT nz) wrote:

: Which worked well, but I was shocked to see the program was about 80k.

: So I tried:

: Main(){}

: Which compiled to 60k.

: I tried the equivilent programs in turbo pascal, and got 2.4k and 1.6k 
: respectivly.

Do the same thing using debug, writing it in assembler; you'll only need a
couple of bytes :)

The point is, there is a certain amount of startup code which gets added
to all your programs. It performs several functions, including looking for
a DPMI host, loading CWSDPMI if it can't find one, globbing the
command-line, switching to protected mode and starting your actual program
code. For these short programs it is pretty useless; you don't need
protected mode to just do nothing; nor do you need therefore a DPMI
server, a stub, command-line globbing, etc.

If you write longer programs, you shouldn't see so much difference between
executable sizes in DJGPP and other environments, relative to the size of
the executable. The second thing you should try is stripping the debugging
information out of the executables. By default, gcc puts a certain amount
in, and if you specify -g it puts a great deal more in. Specifying -s, or
running strip on the executable, will remove all this debugging
information.

This isn't actually the problem with the above code, since there isn't
really much debugging information to strip, but when you write longer
programs bear this in mind. I would suggest using -g during the
development stage, and only stripping the information before distributing
your programs.

-- 
George Foot <mert0407 AT sable DOT ox DOT ac DOT uk>
Merton College, Oxford

- Raw text -


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