If you link in the Standard C++ Library, global constructors in the library
run before main().  The global constructors that are pulling in all of that
iostream code are std::cout, std::cin, std::cerr, std::wcout, std::wcin,
and std::wcerr.

We build libc++ ourselves rather than letting emscripten do it, and we
simply don't include the source files that define std::cout and friends.


On Thu, Sep 11, 2014 at 1:44 PM, Floh <[email protected]> wrote:

> Hi,
>
> I've been looking through one of my small demos in debug mode (no
> optimizations, no minify) looking for stuff which bloats the executable
> size.
>
> First I found a few strange modules before the asm.js block:
>
> MEMFS, IDBFS, NODEFS, SOCKFS, and FS (and think the former 4 are all
> pulled in by FS). The thing is, my code doesn't use any of emscripten's FS
> emulation, also no fopen/fclose or C++ stream IO (only printf and sprintf
> functions). Does it make sense trying to untangle these FS dependencies and
> get rid of some of them?
>
> The other big block of "useless" code I found was a lot of C++ IO
> streambuf iterator code in the asm.js block, and I have no clue what causes
> this code to be included. I'm not using C++ style IO (<< and >>) or include
> any C++ IO headers directly. I'm seeing that the <iterator> header has
> classes which look like the mangled names (see below), but I'm not seeing
> any code using those (definitely not in my code). I'm not using std
> containers or strings, I *do* use std::lower_bound, std::binary_search and
> std::sort from <algorithm>, chrono::high_resolution_clock, std::function,
> but that's about it.
>
> I'd be thankful for every idea where to start with trying to get rid of
> this C++ IO stuff.
>
> Here are some of the mangled function names:
>
>
> __ZNSt3__19money_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE8__do_getERS4_S4_bRKNS_6localeEjRjRbRKNS_5ctypeIwEERNS_10unique_ptrIwPFvPvEEERPwSM_
>
> __ZNSt3__19money_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE8__do_getERS4_S4_bRKNS_6localeEjRjRbRKNS_5ctypeIcEERNS_10unique_ptrIcPFvPvEEERPcSM_
>
> __ZNKSt3__18time_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE6do_getES4_S4_RNS_8ios_baseERjP2tmcc
>
> __ZNKSt3__18time_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE6do_getES4_S4_RNS_8ios_baseERjP2tmcc
>
> __ZNKSt3__18time_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE3getES4_S4_RNS_8ios_baseERjP2tmPKwSC_
>
> One of those even calls a sscanf function:
>
>
> __ZNKSt3__17num_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE6do_getES4_S4_RNS_8ios_baseERjRPv
>
> this calls: __ZNSt3__110__sscanf_lEPKcP15__locale_structS1_z
>
> Cheers & Thanks,
> -Floh.
>
> --
> You received this message because you are subscribed to the Google Groups
> "emscripten-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Chad Austin
Technical Director, IMVU
http://engineering.imvu.com <http://www.imvu.com/members/Chad/>
http://chadaustin.me

-- 
You received this message because you are subscribed to the Google Groups 
"emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to