public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: John Love-Jensen <eljay@adobe.com>
To: Lin George <george4academic@yahoo.com>,
	MSX to GCC <gcc-help@gcc.gnu.org>
Subject: Re: to reduce footprint
Date: Tue, 19 Dec 2006 13:18:00 -0000	[thread overview]
Message-ID: <C1AD42C8.1A934%eljay@adobe.com> (raw)
In-Reply-To: <20061219024131.25705.qmail@web32111.mail.mud.yahoo.com>

Hi George,

> I am wondering how to reduce the footprint of a binary build (C/C++) program
> generated by gcc.

Memory footprint, or file footprint?

> 1. Any ideas of reduce the footprint of a debug version build?
> 2. Any ideas of reduce the footprint of a release version build?

Just some suggestions, by no means a comprehensive list...

If you have an object file with 100 routines in it, but you only use 1
routine out of the hundred, isolate that one routine and link just it (.o
file).  Then you won't get the unnecessary 99 fallow routines.

Use footprint techniques (such as inheritance, specialization and partial
specialization) to reduce the amount of code generated by templates.

Avoid the convenience of multiple copies of weak linkage for stronger,
explicit linkage.  [Depending on what kind of footprint you are trying to
reduce.]

Make sure all your header files do not emit any code (e.g., no static
variables in header files).  Compile your header files to confirm that all
your header files are non-code-generating.

Use code coverage tools to identify code that is not used.  Figure out why
it isn't used, and consider if it can be disposed.

Use enums instead of strings for references to resources.

If you have a value range of, say, 0 to 100, and you have a large array of
them, consider using a typedef unsigned char uint8_t; instead of an array of
int to hold them.

> I think some linker or compiler options may help, what are they? Any other
> ideas to reduce footprint?

Depending on your platform, you may be able to use these switches:
--gc-sections -ffunction-sections -fdata-sections

HTH,
--Eljay

  reply	other threads:[~2006-12-19 13:18 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-12-19  2:41 Lin George
2006-12-19 13:18 ` John Love-Jensen [this message]
2006-12-20 16:46 Lin George
2006-12-21 15:30 ` John Love-Jensen
2006-12-21 17:50 Lin George
2006-12-21 19:13 ` John Love-Jensen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=C1AD42C8.1A934%eljay@adobe.com \
    --to=eljay@adobe.com \
    --cc=gcc-help@gcc.gnu.org \
    --cc=george4academic@yahoo.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).