From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22566 invoked by alias); 27 Aug 2012 05:00:54 -0000 Received: (qmail 22538 invoked by uid 22791); 27 Aug 2012 05:00:52 -0000 X-SWARE-Spam-Status: No, hits=-5.0 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,KHOP_RCVD_TRUST,KHOP_THREADED,RCVD_IN_DNSWL_LOW,RCVD_IN_HOSTKARMA_YE X-Spam-Check-By: sourceware.org Received: from mail-wg0-f51.google.com (HELO mail-wg0-f51.google.com) (74.125.82.51) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 27 Aug 2012 05:00:39 +0000 Received: by wgbed3 with SMTP id ed3so2252564wgb.8 for ; Sun, 26 Aug 2012 22:00:38 -0700 (PDT) MIME-Version: 1.0 Received: by 10.180.91.169 with SMTP id cf9mr25978099wib.1.1346043637953; Sun, 26 Aug 2012 22:00:37 -0700 (PDT) Received: by 10.223.71.3 with HTTP; Sun, 26 Aug 2012 22:00:37 -0700 (PDT) In-Reply-To: References: Date: Mon, 27 Aug 2012 09:27:00 -0000 Message-ID: Subject: Re: libstdc++ From: naga raj To: Jonathan Wakely , Andrew Haley Cc: gcc-help Content-Type: text/plain; charset=ISO-8859-1 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: 2012-08/txt/msg00261.txt.bz2 Hi Jonathan/Andrew Thank you very much for your responses. I think I have to select a subset of the C++ standard libraries and implement a smaller library. Thanks, Nagaraju On Fri, Aug 24, 2012 at 3:09 PM, Jonathan Wakely wrote: > On 24 August 2012 08:46, naga raj wrote: >> Hi, >> >> I have ported Gcc-4.6.2 to an embedded target. My C++ compiler is >> generating huge code size. >> >> #include >> using namespace std; >> int main() >> { >> return 0; >> } >> >> If we execute the above program then all the function in the >> iostream library are included in the elf as a result size of elf is >> increased.... > > Including causes global objects to be constructed, so even > though you're not explicitly using std::cout or std::cin, those > streams are initialized and code is run (before main) just because > is included. If you don't need to use it then don't > include it. If you do need to use it then obviously the code size is > larger if you use I/O features than if you don't use them. > > That said, libstdc++ isn't really optimised for embedded systems. > Some configure-time options such as building libstdc++ without > exceptions can help reduce code size, if you don't need to use > exceptions. > > http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43852 would also help > avoid dependency on the I/O facilities.