In article <9phov7$rkn$1@inn.qnx.com>, <tom_usenet@hotmail.com> wrote:
Ken Appleby <> ken@soft-optics.co.uk> > wrote:
“Tom” <> tom_usenet@hotmail.com> > wrote in message
news:9pdog7$el7$> 1@inn.qnx.com> …
I have 4 main problems with g++, listed in order of annoyance:
- Executable size - with template code the executables are often truly
enormous. This is partly due to the inability of the compiler to remove
duplicate instantiations of templates in separate compilation units.
- Compiler bugs - I see “Internal compiler error” with alarming
regularity.
Workarounds have wasted me hours.
- Compile speed - with the addition of the Dinkumware libraries this has
actually got a lot worse (I was using STLport before which compiled much
quicker).
- Conformance - g++ isn’t too bad here if used with Dinkumware or
STLport,
but there are a number of missing features that annoy me. Still, it is
heaven having inhabited the massively unconforming MSVC++6 world in
Windows.
…
I’m convinced the problems with executable size and compiler speed (not just
executables, actually but all object code) are caused by the use of the new
C++ header files in 6.1. A simple “hello world” program that uses
iostream> compiles to about 5k on 6.0 and 24k on 6.1. Compilation also
takes 7 times longer on 6.1.
A “hello world” program that uses instead of compiles to
about 4.5k on both systems and takes about the same amount of time. So it’s
not the compiler that is at fault.
However, we’re building embedded systems here and the excessive object code
and executable size is a complete show-stopper for us. Until 6.1 we’ve been
able to build reasonably compact embedded software using C++. We can’t move
to 6.1 until the Gnu C++ library, or another that generates smaller code
sizes is ported.
The change in header files to 6.1 was a bit of a different change for
me that for you, since before I was using STLport, which also
produced quite large object code - only about 20% smaller than
Dinkumware.
Why are the executables so large? It comes down mainly to templated
library code. The old gcc headers use non-standard non-templated
iostreams/locales which means that the non-inline code could be
compiled into libstdc++. Templated code can’t in general be compiled
into a library, but must be compiled each time it is seen in the
header. Explicit specialisations for char and wchar_t of all templated
iostreams classes would remove most of this issue (both in compile
time and executable size), but unfortunately Dinkumware chose not to
add them, so they can’t be compiled into their shared library.
Although this is all true, I just can’t bring muself to agree that
there is a sole reason why the executable are so large with various
compilers.
This is a quality of implementation issue,
I agree that’s involved.
and besides conformance, I don’t
consider the Dinkumware implementation to be very good yet, although I
expect that their MSVC.NET port is better (because of the huge
royalties for that port I expect they took the time to use the dll
facilities of Windows to their full).
There is no perfect lib or perfect compiler yet (not even in C IMO)
but I think getting it correct is a quality of implementation issue
as well, so saying “besides conformance” is kinda not fairish.
That aside, I sure do with somebody combines the various lib
strategies going on. As well, as per the other email, there is
various things that a “compiler system” can do to help here that
is still untapped.
STLport has smaller executables because much more code seems to be
compiled into the shared library meaning that much less has to be
compiled into your own object code.
It’s still somewhere then though, and making it a shared lib
can have an effect, but I think that needs to be approached
judiciously.
What can be done about large library size overhead?
http://www.dinkumware.com/libecpp.html > details one approach - simply
have a standard embedded C++ library that does away with the
templated iostreams and string (not to mention the whole STL)
replacing them with non-templated ones. I really don’t think that
this hatchet approach would be necessary if the g++ Dinkumware
libraries were written with thought for code size. g++ has support
for a number of techniques to place specific instantiations of
templates in libraries (using the extern keyword in front of an
explicit template instantiation to forward declare it is one
technique). STLport uses this technique extensively and it has a good
effect on both compile times and object code sizes.
I don’t particularly prefer that approach either, but I do
also recognize that for some people it’s just the thing to do.
One interesting thing in the existence of a Standard Library
implementation that produces a 4k statically linked hello world
executable using g++ under Linux. How is this done? Ask Dietmar
Kuehl, author of the (unfortunately a little incomplete and
currently Linux only) standard library implementation cxxrt. You can
download it from: > http://www.dietmar-kuehl.de/cxxrt/ > although it’s
only any use in Linux. I may have a go at porting it to QNX, since it
would probably be the answer to some of our executable size and even
compile time problems. I expect this is quite a big job though.
Probably. OTOH, it shows what is potentially possible.
So I agree that the Dinkumware library is mainly to blame. STLport
is only about 20% better (although the library .so it produces is
pretty huge), and there are no other standard libraries available on
QNX at present, so you must use the horrible non-standard g++ ones in
6.0 if you need small executables. If I decide I need it I will port
STLport to 6.1 QNX. The current dire compile times are pushing me
that way, although it was nice to be using the standard tool chain
for a while…
Standard C++ is not too big to use for embedded applications.
However, finding a compiler and library implementation that is up to
it is still very difficult. Personally I don’t want to use
non-standard C++, since our in house library code is much more useful
if it is portable.
I agree that it’s not too big. However, lots of work still needs
to be done. As well, iostreams and exception handling are two of
the most obvious issues that need to be dealt with in this market.
Greg Comeau export ETA: Dec 1 10% “End of Summer” Offer
Comeau C/C++ ONLINE ==> http://www.comeaucomputing.com/tryitout
World Class Compilers: Breathtaking C++, Amazing C99, Fabulous C90.
Comeau C/C++ with Dinkumware’s Libraries… Have you tried it?