[Libav-user] reduce dll size

Michael Chisholm chisholm at mitre.org
Tue Mar 25 20:37:35 CET 2014


On 3/24/2014 10:40 PM, YIRAN LI wrote:
>> I'm trying to build all components into one dll, because my manager
>> insisted that building into a single dll may save space by avoiding
>> build duplicated code into separate dlls.
>
> How is this supposed to work?
>
> Or, to rephrase: What are the duplicated code parts that you found
> in different FFmpeg dlls and how much (in %) did they take of the
> overall space?
>
>>> Hi Carl,
>
> I found that every dll links to libm, if it's a static lib (I can only find
> .a on my system), does that mean
> some code will be built into every dll?
>

I think you're getting a bit beyond ffmpeg here.  The way I see it, a 
library is a product of its *.o files.  If there is duplication of code 
across *.o files, the only way to fix it is changing the source, because 
that'll change what goes into the *.o files.  You can lump them all into 
a single library or split them up, afaik it's not going to change the 
overall library contents.  The reason you split them up is so that you 
can pick and choose the components you need.  It's not all-or-nothing. 
There may be some extra packaging overhead in having multiple libs, but 
it seems to me it would be relatively minor.

An obvious source code artifact that would cause code duplication is 
inline functions.  I'm not sure even turning optimizations off 
(disabling inlining) would eliminate the dupes, because inline functions 
are defined in headers, which means they're included in multiple 
translation units, which means the code is compiled into multiple *.o 
files.  The only way to fix that is to change them to no longer be 
inline, which is a source code change.  Are you sure you want to go to 
that much trouble... :-P

(And anyone please correct me if I'm wrong ;)  I am aware that some code 
changes related to dupe removal can occur at link time, e.g. in C++ 
where multiple dupe template instantiations can be merged, but I don't 
know if there's anything like that for C?)

Anyway, its starting to seem to me like your manager's expectations are 
a tad unrealistic...

Andy




More information about the Libav-user mailing list