avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-gcc-list] Re: [avr-chat] AVR-G++ (Was: more of the same ;))


From: Joerg Wunsch
Subject: Re: [avr-gcc-list] Re: [avr-chat] AVR-G++ (Was: more of the same ;))
Date: Fri, 25 Aug 2006 07:03:23 +0200 (MET DST)

Rolf Magnus <address@hidden> wrote:

> Anyway, I'm pretty new to gcc and don't really have much of a clue
> about it.  After all, my first look at its sources was two days ago.

Given that, you've demonstrated that you can quickly navigate there,
and found as much information as one could find there at a quick
glance.

Seriously, none of the current avr-libc maintainers would have done
that better than you.

(libsupc++)

> Hmm, I just tried to compile it, and to my surprise, it actually
> does compile in freestanding mode if you don't go with the avr-g++
> default of disabling exceptions and rtti.

These have been mainly disabled because of a lack of such library in
our standard installation.

> Now I tried to compile the following program with that lib:

> int main()
> {
>     throw 3;
> }

> but avr-size tells me:

> It produced 22 kBytes of code and 1.2 kBytes of data.

That's bee the second reason to default it to not handling exceptions
many years ago when I tried my own first C++ program.  Even worse, I
seem to recall that just an empty main() already drags in the
exception code unless explicitly disabled from the command-line.  So
later on, their defaults have been changed.

> And:

> int main()
> {
>     delete new int(5);
> }

> produces:
> 
> section              size      addr
> .data                 386   8388864
> .text               20454         0
> .bss                  526   8389250
> .stab                7296         0
> .stabstr            18171         0
> .gcc_except_table      39   8389776
> Total               46872

Is this with the exceptions still enabled?  Otherwise, it could be the
issue I've told above: even if the application doesn't use them, a lot
of code is dragged in to be *prepared* for using them.

> Dunno if it actually works or what operator new is using for memory
> allocation here. It doesn't seem to be avr-libc's malloc.

Hmm, that's bad then.  new and delete really should use the same
memory allocator.

> Well, new and delete aren't much of a problem, as long as you keep
> exceptions out of the picture.

Agreed.  That's been my opinion as well some 5 years ago.  OTOH, if
exceptions were at least possible (without being enabled by default),
people with large processors might find them valuable for development/
debugging.  If the 20 KB shown are only something like an initial
overhead for exceptions that doesn't grow proportional to the size of
the source code, on an ATmega128 or ATmega1281 this might be bearable.

At least, your libsupc++ has got the helper function that was
otherwise missing to get the exceptions even to link correctly at all.
When I tried that, it failed to link, and just to see what would
happen (and how large it will become), I then went ahead and supplied
a dummy for that exception helper.  That got me into the same ~ 20 KiB
application size you're seeing.  I think the division between
libstdc++ and libsupc++ didn't exist back then (it's probably still
been on GCC 2.95), and the full libstdc++ didn't compile on the AVR
target.

So the dirty work to be done would be to turn all this into some kind
of patch for GCC so it would do your steps automatically when being
compiled for C++.  If possible, I'd vote to disable exceptions by
default still, but you then have to override that for compiling
libsupc++, which again means to patch something...

-- 
cheers, J"org               .-.-.   --... ...--   -.. .  DL8DTL

http://www.sax.de/~joerg/                        NIC: JW11-RIPE
Never trust an operating system you don't have sources for. ;-)





reply via email to

[Prev in Thread] Current Thread [Next in Thread]