Boost logo

Boost Users :

Subject: Re: [Boost-users] [serialization] boost::serialization adds huge amounts of exports to resultant Windows PE file (Robert Ramey)
From: Robert Ramey (ramey_at_[hidden])
Date: 2010-09-30 20:26:22


Chris Yuen wrote:
> Robert Ramey wrote:
>> Are you sure you're building in release mode?
>
> Yes of course. Is that expected to make a difference? Reading from
> `force_include.hpp`, even Release mode wouldn't escape from this (see
> below)
>
> I dug into the problem a little bit more. I replaced
> `force_include.hpp` with the following two lines and then actually
> recompiled boost::serialization
>
> #define BOOST_DLLEXPORT
> #define BOOST_USED
>
> The code bloat is gone (as shown by `dumpbin /exports`, yes, actually
> by 8MB), *and* the resulting program actually compiles and runs fine
> (sample program at: http://boost.codepad.org/f9LodmfD **). I tested
> again at MSVC2010 at both Release|x64 and Release|Win32.
>
> This seems to be a rather intrusive hack that seems to have become
> outdated with MSVC2010 (haven't tested with MSVC2005 and MSVC2008 yet.
> It's installed on another machine).
>
> Right now, `force_include.hpp` reads this:
>
> #if defined(BOOST_HAS_DECLSPEC) && !defined(__COMO__)
> // ...
> # define BOOST_DLLEXPORT __declspec(dllexport)
>
> This means we are unconditionally doing this explosive exports for all
> MS platforms. Even Release mode cannot optimize away these explicitly
> marked DLL exports. Should we at least have an option to turn off this
> very intrusive workaround? Right now my only option is to patch
> `force_include.hpp` manually. There might be some people that actually
> need the hack, but for some of us who's dug into it and actually
> confirmed it's not needed, it would be nice to be able to turn that
> off since the bloat introduced is definitely non-trivial.

If you want to be really helpful you could do the following:

On your own machine run library_test.sh for the serialization library
for each of the three compilers in release mode and send me the results.
For those compilers which pass, we'll tweak the force_include file
accomodate this new information.

>
> ** Of course I don't mean this particular sample program generates 8MB
> of export symbols. This is only to show what I mean by "it compiles
> and runs." The actual program that resulted from
> boost::serialization's 8MB bloat contained 100+ "exported" classes
> serialized through base pointers. The specs is quite close to what I
> showed in the sample program.

That would still amount to 80K per class. In any case, force include
is only in there because I couldn't get things to pass without out. I
would love to suppress it if we knew which versions don't need it.

> ** That doesn't seem to play well with CodePad's boost. Oh well.

I have no idea what this refers to.

Robert Ramey

>
> Best regards,
> Chris Yuen


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net