Reducing the size of C++ executables - eliminating malloc

2006-11-11 Thread Michael Eager
GCC 4.1.1 for PowerPC generates a 162K executable for a minimal program "int main() { return 0; }". GCC 3.4.1 generated a 7.2K executable. Mark Mitchell mentioned the same problem for ARM and proposed a patch to remove the reference to malloc in atexit (http://sourceware.org/ml/newlib/2006/msg0

Re: Reducing the size of C++ executables - eliminating malloc

2006-11-12 Thread Mark Mitchell
Michael Eager wrote: > GCC 4.1.1 for PowerPC generates a 162K executable for a > minimal program "int main() { return 0; }". GCC 3.4.1 > generated a 7.2K executable. Mark Mitchell mentioned the > same problem for ARM and proposed a patch to remove the > reference to malloc in atexit > (http://so

Re: Reducing the size of C++ executables - eliminating malloc

2006-11-12 Thread Michael Eager
Mark Mitchell wrote: Michael Eager wrote: GCC 4.1.1 for PowerPC generates a 162K executable for a minimal program "int main() { return 0; }". GCC 3.4.1 generated a 7.2K executable. Mark Mitchell mentioned the same problem for ARM and proposed a patch to remove the reference to malloc in atexi

Re: Reducing the size of C++ executables - eliminating malloc

2006-11-12 Thread Mark Mitchell
Michael Eager wrote: > Preallocating space is a good thing, particularly if the size > can be computed at compile time. It's a little bit more awkward > if it has to be calculated at link time. It's a bit awkward, but it's also one of the clever tricks ARM's proprietary linker uses, and we shoul

Re: Reducing the size of C++ executables - eliminating malloc

2006-11-12 Thread Michael Eager
Mark Mitchell wrote: Generating __gxx_personality_v0 is suppressed with the -fno-exceptions flag, but it would seem better if this symbol were only generated when catch/throw was used. This happens in cxx_init_decl_processing(), which is called before it's known whether or not EH is really neede

Re: Reducing the size of C++ executables - eliminating malloc

2006-11-12 Thread Mark Mitchell
Michael Eager wrote: > Mark Mitchell wrote: >>> Generating __gxx_personality_v0 is suppressed with the -fno-exceptions >>> flag, but it would seem better if this symbol were only generated >>> when catch/throw was used. This happens in cxx_init_decl_processing(), >>> which is called before it's kn

Re: Reducing the size of C++ executables - eliminating malloc

2006-11-12 Thread Michael Eager
Mark Mitchell wrote: Michael Eager wrote: Why should the personality routine be included in all C++ programs? Because all non-trivial, exceptions-enabled programs, may need to do stack unwinding. It would seem that the place to require the personality routine would be in the routine which ca

Re: Reducing the size of C++ executables - eliminating malloc

2006-11-12 Thread Paul Brook
On Sunday 12 November 2006 22:46, Michael Eager wrote: > Mark Mitchell wrote: > > Michael Eager wrote: > >> Why should the personality routine be included in all C++ programs? > > > > Because all non-trivial, exceptions-enabled programs, may need to do > > stack unwinding. > > It would seem that th

Re: Reducing the size of C++ executables - eliminating malloc

2006-11-12 Thread Mark Mitchell
Michael Eager wrote: > Mark Mitchell wrote: >> Michael Eager wrote: >>> Why should the personality routine be included in all C++ programs? >> >> Because all non-trivial, exceptions-enabled programs, may need to do >> stack unwinding. > > It would seem that the place to require the personality > r

Re: Reducing the size of C++ executables - eliminating malloc

2006-11-12 Thread Michael Eager
Mark Mitchell wrote: But, the way the ABI works requires a reference from each unit which may cause unwinding. Even if you lose the personality routine, you will still have the exception tables, which themselves are a significant cost. If you don't want to pay for exceptions, you really have to

Re: Reducing the size of C++ executables - eliminating malloc

2006-11-12 Thread Daniel Jacobowitz
On Sun, Nov 12, 2006 at 11:17:14PM +, Paul Brook wrote: > The code being unwound through (ie. with frame data) needs to be able to > say "I need routine X if __Unwind_Raise is used anywhere in this program". > I'm not aware of any way of doing this, other than trying it and starting > again i

Re: Reducing the size of C++ executables - eliminating malloc

2006-11-12 Thread Paul Brook
On Monday 13 November 2006 00:53, Daniel Jacobowitz wrote: > On Sun, Nov 12, 2006 at 11:17:14PM +, Paul Brook wrote: > > The code being unwound through (ie. with frame data) needs to be able to > > say "I need routine X if __Unwind_Raise is used anywhere in this > > program". I'm not aware of a

Re: Reducing the size of C++ executables - eliminating malloc

2006-11-12 Thread Mark Mitchell
Daniel Jacobowitz wrote: > If you try what Michael's been saying, you'll notice that trivial > C++ files get the personality routine reference even if they don't > have anything with a destructor which would need cleaning up. We ought > to be able to emit (somewhat smaller) unwind information whi

Re: Reducing the size of C++ executables - eliminating malloc

2006-11-12 Thread Daniel Jacobowitz
On Mon, Nov 13, 2006 at 01:03:10AM +, Paul Brook wrote: > > C++ files get the personality routine reference even if they don't > > have anything with a destructor which would need cleaning up. We ought > > to be able to emit (somewhat smaller) unwind information which doesn't > > reference the

Re: Reducing the size of C++ executables - eliminating malloc

2006-11-12 Thread Daniel Jacobowitz
On Sun, Nov 12, 2006 at 05:11:39PM -0800, Mark Mitchell wrote: > Daniel Jacobowitz wrote: > > > If you try what Michael's been saying, you'll notice that trivial > > C++ files get the personality routine reference even if they don't > > have anything with a destructor which would need cleaning up.

Re: Reducing the size of C++ executables - eliminating malloc

2006-11-12 Thread Mark Mitchell
Daniel Jacobowitz wrote: > On Sun, Nov 12, 2006 at 05:11:39PM -0800, Mark Mitchell wrote: >> Daniel Jacobowitz wrote: >> >>> If you try what Michael's been saying, you'll notice that trivial >>> C++ files get the personality routine reference even if they don't >>> have anything with a destructor w

Re: Reducing the size of C++ executables - eliminating malloc

2006-11-12 Thread jschopp
> GCC 4.1.1 for PowerPC generates a 162K executable for a > minimal program "int main() { return 0; }". GCC 3.4.1 > generated a 7.2K executable. Mark Mitchell mentioned the > same problem for ARM and proposed a patch to remove the > reference to malloc in atexit > (http://sourceware.org/ml/newl

Re: Reducing the size of C++ executables - eliminating malloc

2006-11-13 Thread Olivier Galibert
On Sun, Nov 12, 2006 at 02:46:58PM -0800, Michael Eager wrote: > It would seem that the place to require the personality > routine would be in the routine which causes the stack > unwinding, not in every C++ object file, whether needed > or not. Doesn't that otherwise very valid point of view brea

Re: Reducing the size of C++ executables - eliminating malloc

2006-11-13 Thread Michael Eager
Olivier Galibert wrote: On Sun, Nov 12, 2006 at 02:46:58PM -0800, Michael Eager wrote: It would seem that the place to require the personality routine would be in the routine which causes the stack unwinding, not in every C++ object file, whether needed or not. Doesn't that otherwise very vali