#123823 - tyraen - Sat Mar 31, 2007 4:39 pm
So I've been working on a DSO plugin in C++. Using --no-rtti and --no-exceptions (as someone had mentioned here previously) the filesize after compiling was around 20kb. In recent builds it has jumped up to 80kb, and I'm having trouble understanding why. Maybe it's an unavoidable issue now (not that it's much of an issue). The major change I've made recently was creating an interface class and a few others that implemented it. Maybe this is a hard question to address without seeing code, but does anyone have any thoughts?
Thanks.
#123824 - tepples - Sat Mar 31, 2007 4:59 pm
If you haven't been using stdio, then any pure virtual methods will bring in printf(), which brings in both the stdio library and the floating-point library.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.
#123827 - tyraen - Sat Mar 31, 2007 5:26 pm
Ouch, ok. I don't really know a ton about C++, heh. Does it... have to bring those in? :) Why does it use those?
#123829 - tyraen - Sat Mar 31, 2007 5:33 pm
Yup, changing to non-pure functions brought the size back down a ways. It's not going to kill me to keep them this way but I'd prefer pure virtual...
#123839 - tepples - Sat Mar 31, 2007 7:01 pm
Is there a place where I could browse the source code of libstdc++ and libsupc++ online so that I could investigate the inner workings of __cxa_pure_virtual (which prints an error message when a pure virtual function is called) without having to download and extract the entire libstdc++ source code?
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.
#123840 - tyraen - Sat Mar 31, 2007 7:11 pm
Thanks for the help tepples.
#123862 - gmiller - Sun Apr 01, 2007 12:09 am
for thinks about gcc there is http://gcc.gnu.org/wiki. I am not sure the libstdc++ stuff is there since I do not use C++ much.
#123874 - tepples - Sun Apr 01, 2007 1:57 am
I found browsable libsupc++ and am looking through it, just for kicks.
From pure.cc:
Code: |
extern "C" void __cxa_pure_virtual (void)
{
std::fputs("pure virtual method called\n", stderr);
std::terminate();
} |
fputs() brings in <cstdio> and the devoptab.
From eh_terminate.cc and eh_term_handler.cc, I determine that std::terminate() calls __verbose_terminate_handler() (which brings in exception support, the name demangler, and malloc/free) followed by abort(). In turn, abort() brings in write() (and thus the devoptab handler).
So it appears you can use pure virtual functions without a big size penalty by writing your own replacement for __cxa_pure_virtual().
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.