Chris McKillop wrote:
Using “strip” is the smallest on-disk size you can get. You can check for the
“real” size by using the size utility (which isn’t dependant on the
size reported by ls).
strip reduced it to 179K. A vast improvement. size produced pretty much
the same information.
The fact is that “modern” C++ (with everything being
templates) is not suited to small code.
Aint that the truth?
That is why we have the Dinkum
ecpp libs (embedded C++) and the pre-ISO GNU C++ libs.
Take this classic example…
#include <iostream
int main( void ) { std::cout << “Hello World!” << std::endl; }
…compiled with “QCC -static”…
text data bss dec hex filename
233044 91304 3768 328116 501b4 hello_cpp
…compiled with “QCC -static -Vgcc_ntox86_ecpp”…
text data bss dec hex filename
85800 19980 1892 107672 1a498 hello_ecpp
…compiled with “QCC -static -Vgcc_ntox86_gpp”…
text data bss dec hex filename
112703 23468 1540 137711 219ef hello_gpp
Hmm… Too many years with QNX4 and Watcom have spoilt me. My
expectations need to be adjusted downwards…
Doing some tests by only static linking the C++ lib and not the C lib results
in some much better numbers for the ecpp and gnu libs (about 50K less).
Why are you linking statically? Just to get an estimate of the overhead?
Don’t forget that with shared libs the text area is shared between processes
and so you only take that charge once (the whole point of using shared libs).
I guess I am statically linking because that’s what I’m used to doing,
and also because there will/should be only one instance of this
particular process. Given the size of this executable, and my abhorrence
of the idea of a driver being so large (the QNX4 version being only 40K)
I will investigate/experiment with the dynamic libraries. I’m still
pretty new to QNX6 and have a lot of QNX4 baggage to shed…
What sort of embedded systems are out there that have enough memory
resources to accomodate programs written in C++ and come out at 85K to
100K anyway???
Thanks again for your response.
Regards,
Geoff.
chris
Geoff <> geoff@rtts.com.au> > wrote:
What is the best way to strip out all debug and optimise for smallest
size? I have a C++ process that when compiled with -gdwarf-2 is 2.5Mb
long, and 1.5 Mb when no -g options is used. With Watcom the wstrip
utility could remove all the debug crap. Is there an equivalent with
gcc? If not, I’m open to recommendations as to what might be a suitable
list of compile/link options. In fact, I’d appreciate it as I have been
unable to do any better than the 1.5M above, even with -O.
The process is linking to static Dinkum libraries.
Thanks,
Geoff Roberts
–
Chris McKillop <> cdm@qnx.com> > “The faster I go, the behinder I get.”
Software Engineer, QSSL – Lewis Carroll –
http://qnx.wox.org/
–
Realtime Technology Systems Pty Ltd
2 Hadleigh Circuit
Isabella Plains
ACT 2905
AUSTRALIA
Phone: 61-2-6291 3833
Fax: 61-2-6291 3838
Mobile: 0413 634 667
Email: geoff@rtts.com.au