From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24990 invoked by alias); 19 Dec 2006 13:18:55 -0000 Received: (qmail 24979 invoked by uid 22791); 19 Dec 2006 13:18:53 -0000 X-Spam-Check-By: sourceware.org Received: from exprod6og53.obsmtp.com (HELO exprod6og53.obsmtp.com) (64.18.1.187) by sourceware.org (qpsmtpd/0.31) with SMTP; Tue, 19 Dec 2006 13:18:39 +0000 Received: from source ([192.150.11.134]) by exprod6ob53.postini.com ([64.18.5.12]) with SMTP; Tue, 19 Dec 2006 05:18:37 PST Received: from inner-relay-3.eur.adobe.com (inner-relay-3.adobe.com [192.150.20.198] (may be forged)) by outbound-smtp-1.corp.adobe.com (8.12.10/8.12.10) with ESMTP id kBJDFdvV007791; Tue, 19 Dec 2006 05:15:40 -0800 (PST) Received: from fe1.corp.adobe.com (fe1.corp.adobe.com [10.8.192.70]) by inner-relay-3.eur.adobe.com (8.12.10/8.12.9) with ESMTP id kBJDIYeA009142; Tue, 19 Dec 2006 05:18:35 -0800 (PST) Received: from namailgen.corp.adobe.com ([10.8.192.91]) by fe1.corp.adobe.com with Microsoft SMTPSVC(6.0.3790.1830); Tue, 19 Dec 2006 05:18:34 -0800 Received: from 10.32.16.88 ([10.32.16.88]) by namailgen.corp.adobe.com ([10.8.192.91]) via Exchange Front-End Server namailhost.corp.adobe.com ([10.8.192.72]) with Microsoft Exchange Server HTTP-DAV ; Tue, 19 Dec 2006 13:18:33 +0000 User-Agent: Microsoft-Entourage/11.2.5.060620 Date: Tue, 19 Dec 2006 13:18:00 -0000 Subject: Re: to reduce footprint From: John Love-Jensen To: Lin George , MSX to GCC Message-ID: In-Reply-To: <20061219024131.25705.qmail@web32111.mail.mud.yahoo.com> Mime-version: 1.0 Content-type: text/plain; charset="US-ASCII" Content-transfer-encoding: 7bit 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/msg00278.txt.bz2 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