This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Stipping away locale support


On Friday 15 August 2003 03:26, Loren James Rittle wrote:

> > My application is quite small and uses only basic C++
> > features (no threading, no wchar, no iostreams and no STL),
> > but somehow all of the C locale stuff gets linked in,
> > bringing several other things with it (formatters, etc.).
>
> Telling us what you don't use is not helpful... ;-)  In the future,
> please tell us what you do use...

Ok, I need to reduce my program to some simple testcases... ;-)
See below.

> > With GCC 3.3.1, the text+data size was 384KB. In GCC 3.4,
> > the size increased to 682KB. This is a serious regression.
>
> Please report exactly what you are doing.  Based on what you have said
> above, I can assume the following:
>
> - you added -static (or it is the port default)

It's the default on my platform, which is m68k-elf with several
patches in the m68k back-end required to support the ColdFire
and uClinux. I'm also using uClibc, which looks and tastes
almost like glibc except that it's much smaller and lacks some
advanced functionality.

> - you probably use std::string

Hmmm... hard to tell. By looking at the nm output, the
std::string stuff is certainly being linked in, but my
application doesn't use it directly, nor does the EasySoap
library I'm linking to (it uses its own SOAPString class
instead).

In the disassembly I can see that the C++ demangler has been
linked into my binary and it's heavily using std::string.
Why do I get the demangler? I've even specified -fno-rtti.

Here's the full command line I'm using (stripped of useless
flags such as -I and -D):

 m68k-elf-g++ -Wall -Werror -g -MD -Os -m5307 -fomit-frame-pointer \
    -fno-implement-inlines -fno-rtti -fno-enforce-eh-specs \
    -c -o hello.o hello.cpp
 m68k-elf-g++ -g -MD -Os -m5307 -Wl,-elf2flt -o hello hello.o


> - you indeed ran 'size' instead of 'ls -l'

Well, actually I didn't because uClinux uses a custom
binary format called FLT which is almost a binary
image containing just the text and data segment plus
relocations.

Since GCC really outputs ELF binaries which are later
converted to FLT, I can easily run size on the intermediate
linker output if needed.


Here are some interesting things I've found out:

---------------------------------------------------------------------
#include <string>  // unused!
int main()
{
	printf("Hello, world!\n");
}

 text    data     bss     dec     hex filename
 2528     256     560    3344     d10 hello.gdb
---------------------------------------------------------------------

This was as good as one would expect. But this one isn't:

---------------------------------------------------------------------
#include <iostream> // unused!
int main()
{
        printf("Hello, world!\n");
}

   text    data     bss     dec     hex filename
 193783   70696    4896  269375   41c3f hello.gdb
---------------------------------------------------------------------

And an even better one:

---------------------------------------------------------------------
// no headers at all!
int main()
{
	char *c = new char[20];
}
   text    data     bss     dec     hex filename
 193751   70600    4896  269247   41bbf hello.gdb
---------------------------------------------------------------------

The last two tests contain all sort of rubbish (top 30 symbols, by size):

 0000e0fa 000003a6 T __gxx_personality_v0
 0001c3fc 000003c6 W std::time_get<char, std::istreambuf_iterator<char, std::char_traits<char> > >::do_get_weekday(std::istreambuf_>
 0002e8bc 000003ca W std::vector<__gnu_cxx::demangler::qualifier<std::allocator<char> >, std::allocator<char> >::_M_insert_aux(__gn>
 0001d2b8 000003f6 W std::time_get<char, std::istreambuf_iterator<char, std::char_traits<char> > >::_M_extract_name(std::istreambuf>
 0001cbd8 00000410 W std::time_get<char, std::istreambuf_iterator<char, std::char_traits<char> > >::do_get_year(std::istreambuf_ite>
 0001c7c2 00000416 W std::time_get<char, std::istreambuf_iterator<char, std::char_traits<char> > >::do_get_monthname(std::istreambu>
 0001956e 00000446 W std::num_get<char, std::istreambuf_iterator<char, std::char_traits<char> > >::do_get(std::istreambuf_iterator<>
 00003324 00000496 T strftime
 0000b96c 000004b2 T std::locale::_Impl::_Impl(char const*, unsigned long)
 0000b4ba 000004b2 T std::locale::_Impl::_Impl(char const*, unsigned long)
 00000f06 000004b4 t execute_cfa_program
 0002c060 0000053a W __gnu_cxx::demangler::session<std::allocator<char> >::decode_substitution(std::string&, __gnu_cxx::demangler::>
 00009f10 0000055c T std::locale::locale(char const*)
 000099b4 0000055c T std::locale::locale(char const*)
 000111ce 00000594 T __cxa_demangle
 0000083c 000006ca t execute_stack_op
 0000671c 0000074e T _dtostr
 0000c57e 00000760 T std::locale::_Impl::_Impl(std::locale::facet**, unsigned long, bool)
 0000be1e 00000760 T std::locale::_Impl::_Impl(std::locale::facet**, unsigned long, bool)
 0002d23c 00000766 W __gnu_cxx::demangler::qualifier_list<std::allocator<char> >::decode_qualifiers(std::string&, std::string&, boo>
 0002b884 000007dc W __gnu_cxx::demangler::session<std::allocator<char> >::decode_special_name(std::string&)
 00041430 00000800 b emergency_buffer
 0001d6ae 00000880 W std::time_get<char, std::istreambuf_iterator<char, std::char_traits<char> > >::_M_extract_via_format(std::istr>
 00029160 000009d2 W __gnu_cxx::demangler::session<std::allocator<char> >::decode_encoding(std::string&, char const*, int)
 00017d18 00000af8 W std::num_get<char, std::istreambuf_iterator<char, std::char_traits<char> > >::_M_extract_float(std::istreambuf>
 0002f89e 00000b5a D _string_syserrmsgs
 000163a0 00000d18 W std::money_put<char, std::ostreambuf_iterator<char, std::char_traits<char> > >::do_put(std::ostreambuf_iterato>
 00018810 00000d5e W std::num_get<char, std::istreambuf_iterator<char, std::char_traits<char> > >::_M_extract_int(std::istreambuf_i>
 0001504a 0000106c W std::money_get<char, std::istreambuf_iterator<char, std::char_traits<char> > >::do_get(std::istreambuf_iterato>
 00029b32 00001d52 W __gnu_cxx::demangler::session<std::allocator<char> >::decode_type_with_postfix(std::string&, std::string&, __g>


-- 
  // Bernardo Innocenti - Develer S.r.l., R&D dept.
\X/  http://www.develer.com/

Please don't send Word attachments - http://www.gnu.org/philosophy/no-word-attachments.html



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]