This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Abnormally large executable with gcc 3.0
- To: gcc at gcc dot gnu dot org
- Subject: Abnormally large executable with gcc 3.0
- From: "R L" <ral at hotmail dot com>
- Date: Sat, 26 May 2001 02:13:21 -0000
Hello,
I was trying out gcc 3.0 with the 05/21 snapshot. I compiled it
with gcc 2.95.2 from Slackware 7.1. When I re-compiled gcc 3.0 with
gcc 3.0 nothing changed, and so currently I am testing with gcc 3.0
compiled with gcc 3.0. I'm using an Athlon 750 (slot A) with 128MB
of ram.
Here is the problem I encounterd, and maybe I'm doing something wrong. I
compiled a small test "hello world" program for C and C++. The C version
was just slightly larger, about 2%. The C++ version is where the problem
seems to lie. The g++ 3.0 compiler produced
executables that were 2x as large or more. I tried stripping them
in case that would help, but didn't. I then tried running the
executables and found that the g++ 3.0 compiler produced much slower
code than the g++ 2.95.2 compiler. If there is something wrong with
the way I was doing something, please let me know. I don't mind
testing the compilers further in my spare time. Below I pasted my results
as well as the test programs. Also, I was experimenting with something and
decided to give g++ 3.0 a try. That uses one template class. It produced
code nearly 10x larger and executed over 100x slower. That code is a bit
large to paste here so if anyone wants to see just let me know.
helloworld.cc:
-----------------------------------------------------
#include <iostream>
int
main(void)
{
std::cout << "Hello world\n";
return(0);
}
-----------------------------------------------------
helloworld.c
-----------------------------------------------------
#include <stdio.h>
int
main(void)
{
printf("Hello world!\n");
return(0);
}
-----------------------------------------------------
Hello World Results: (The size of the executable is in bytes).
Executable size
---------------
11637 helloworld-c-2-opt
2960 helloworld-c-2-opt-stripped
11669 helloworld-c-2-std
2992 helloworld-c-2-std-stripped
11807 helloworld-c-3-opt
3108 helloworld-c-3-opt-stripped
11825 helloworld-c-3-std
3124 helloworld-c-3-std-stripped
12885 helloworld-cc-2-opt
4136 helloworld-cc-2-opt-stripped
12917 helloworld-cc-2-std
4168 helloworld-cc-2-std-stripped
27732 helloworld-cc-3-opt
14172 helloworld-cc-3-opt-stripped
38713 helloworld-cc-3-std
19988 helloworld-cc-3-std-stripped
std = -O0 -Wall
opt = -O3 -Wall
stipped = I ran strip on the executable
3 = gcc/g++ 3.0
2 = gcc/g++ 2.95.2
Execution Time
--------------
helloworld-c-2-opt 0.0020s/0.0001s/0.0000s
helloworld-c-2-std 0.0021s/0.0001s/0.0000s
helloworld-c-3-opt 0.0022s/0.0020s/0.0000s
helloworld-c-3-std 0.0021s/0.0022s/0.0002s
helloworld-cc-2-opt 0.0055s/0.0040s/0.0002s
helloworld-cc-2-std 0.0050s/0.0060s/0.0000s
helloworld-cc-3-opt 0.0112s/0.0080s/0.0020s
helloworld-cc-3-std 0.0132s/0.0080s/0.0040s
I used the 'time' command from bash to get the execution times
and then just added the extra digit from averaging 5 tests.
_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com