public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jonathan Wakely <jwakely.gcc@gmail.com>
To: naga raj <gnuuser.raj@gmail.com>
Cc: gcc-help <gcc-help@gcc.gnu.org>
Subject: Re: libstdc++
Date: Fri, 24 Aug 2012 13:40:00 -0000	[thread overview]
Message-ID: <CAH6eHdRpxoPerOwyf0kPhJjCvJDZQqpC7xYCZpu3wj_Va9yjZg@mail.gmail.com> (raw)
In-Reply-To: <CAKuVEhAV-gtkJ4qOHwU4OguKn+Ou_edxA-3iXQNJZz9Az3tL4w@mail.gmail.com>

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 <iostream>
>  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 <iostream> 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
<iostream> 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.

  parent reply	other threads:[~2012-08-24  9:40 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-24  8:10 libstdc++ naga raj
2012-08-24  9:33 ` libstdc++ Andrew Haley
2012-08-24 13:40 ` Jonathan Wakely [this message]
2012-08-27  9:27   ` libstdc++ naga raj
  -- strict thread matches above, loose matches on Subject: below --
1999-11-04 18:42 libstdc++ Inferno
1999-11-07  5:16 ` libstdc++ J.H.M. Dassen (Ray)
1999-11-30 23:28   ` libstdc++ J.H.M. Dassen (Ray)
1999-11-30 23:28 ` libstdc++ Inferno
1999-10-01  0:00 libstdc++ Inferno

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=CAH6eHdRpxoPerOwyf0kPhJjCvJDZQqpC7xYCZpu3wj_Va9yjZg@mail.gmail.com \
    --to=jwakely.gcc@gmail.com \
    --cc=gcc-help@gcc.gnu.org \
    --cc=gnuuser.raj@gmail.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).