From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24766 invoked by alias); 20 Dec 2006 16:46:01 -0000 Received: (qmail 24752 invoked by uid 22791); 20 Dec 2006 16:45:59 -0000 X-Spam-Check-By: sourceware.org Received: from web32110.mail.mud.yahoo.com (HELO web32110.mail.mud.yahoo.com) (68.142.207.124) by sourceware.org (qpsmtpd/0.31) with SMTP; Wed, 20 Dec 2006 16:45:49 +0000 Received: (qmail 28808 invoked by uid 60001); 20 Dec 2006 16:45:47 -0000 Message-ID: <20061220164547.28806.qmail@web32110.mail.mud.yahoo.com> Received: from [222.68.242.79] by web32110.mail.mud.yahoo.com via HTTP; Wed, 20 Dec 2006 08:45:47 PST Date: Wed, 20 Dec 2006 16:46:00 -0000 From: Lin George Subject: Re: to reduce footprint To: John Love-Jensen , MSX to GCC MIME-Version: 1.0 Content-Type: text/plain; charset=ascii Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org X-SW-Source: 2006-12/txt/msg00310.txt.bz2 Thanks John! I want to reduce the file size of my shared library. I think y= ou are an expert in this field. I have read through your comments below and= I am especially interested in the following points, 1. Use footprint techniques (such as inheritance, specialization and partial specialization) to reduce the amount of code generated by templates. Could you provide some references to them? 2. Avoid the convenience of multiple copies of weak linkage for stronger, explicit linkage. [Depending on what kind of footprint you are trying to reduce.] Could you provide some reference about weak linker and a strong (explicit l= inker)? 3. 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. I can understand what you mean, but I do not know why if header files emit = code, the footprint will be larger? 4. --gc-sections -ffunction-sections -fdata-sections gcc manual does not contain much information about these parameters. Could = you briefly introduce the functions of them? thanks in advance, George ----- Original Message ---- From: John Love-Jensen To: Lin George ; MSX to GCC Sent: Tuesday, December 19, 2006 9:18:32 PM Subject: Re: to reduce footprint Hi George, > I am wondering how to reduce the footprint of a binary build (C/C++) prog= ram > 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 hHTH, --Eljay __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around=20 http://mail.yahoo.com