[FFmpeg-devel] [RFC] gcc garbage collection unused code

matthieu castet castet.matthieu
Thu Jun 12 22:34:33 CEST 2008


Hi,

I want to try to use -fdata-sections -ffunction-sections to remove dead 
code from ffmpeg.

This is trivial to do on static library using 
--extra-cflags="-ffunction-sections -fdata-sections" 
--extra-ldflags="-Wl,--gc-sections -Wl,--print-gc-sections"

But I want to try it also on shared libraries.
For that I need to play with symbol visibility. I put all symbol to 
hidden except the public symbols. For that I use -fvisibility=hidden and 
pragma to set default visibility in public header (see attached patch).
I don't really like it, because I wonder what will happen with compiler 
not supporting these pragma. But that's the only simple solution I see ATM.

With the patch and setting --enable-shared 
--extra-cflags=-ffunction-sections -fdata-sections -fvisibility=hidden 
--extra-ldflags=-Wl,--gc-sections -Wl,--print-gc-sections,
it mostly work but there are some problem with function that are not 
public but shared across libraries [1].

What do you think of that ?

What should be the best way to unhide private symbol shared across 
libraries ? Working at header level or function level ?


Matthieu

[1]
for --disable-decoders --disable-encoders --disable-muxers :
/mnt/data/tmp/test/ffmpeg/libavformat/libavformat.so: undefined 
reference to `av_aes_crypt'
/mnt/data/tmp/test/ffmpeg/libavformat/libavformat.so: undefined 
reference to `ff_mpegaudio_decode_header'
/mnt/data/tmp/test/ffmpeg/libavformat/libavformat.so: undefined 
reference to `ff_mpeg4audio_channels'
/mnt/data/tmp/test/ffmpeg/libavformat/libavformat.so: undefined 
reference to `ff_mpeg4audio_get_config'
/mnt/data/tmp/test/ffmpeg/libavformat/libavformat.so: undefined 
reference to `ff_mpa_decode_header'
/mnt/data/tmp/test/ffmpeg/libavformat/libavformat.so: undefined 
reference to `av_tree_node_size'
/mnt/data/tmp/test/ffmpeg/libavformat/libavformat.so: undefined 
reference to `av_aes_init'
/mnt/data/tmp/test/ffmpeg/libavformat/libavformat.so: undefined 
reference to `ff_mpeg4audio_sample_rates'
/mnt/data/tmp/test/ffmpeg/libavformat/libavformat.so: undefined 
reference to `ff_des_encdec'
/mnt/data/tmp/test/ffmpeg/libavformat/libavformat.so: undefined 
reference to `av_aes_size'
/mnt/data/tmp/test/ffmpeg/libavformat/libavformat.so: undefined 
reference to `ff_mpa_freq_tab'
/mnt/data/tmp/test/ffmpeg/libavdevice/libavdevice.so: undefined 
reference to `dv_init_demux'
/mnt/data/tmp/test/ffmpeg/libavdevice/libavdevice.so: undefined 
reference to `dv_produce_packet'
/mnt/data/tmp/test/ffmpeg/libavformat/libavformat.so: undefined 
reference to `ff_ac3_parse_header'
/mnt/data/tmp/test/ffmpeg/libavdevice/libavdevice.so: undefined 
reference to `dv_get_packet'
/mnt/data/tmp/test/ffmpeg/libavformat/libavformat.so: undefined 
reference to `av_tree_insert'
/mnt/data/tmp/test/ffmpeg/libavformat/libavformat.so: undefined 
reference to `ff_rc4_enc'
/mnt/data/tmp/test/ffmpeg/libavformat/libavformat.so: undefined 
reference to `av_tree_find'
/mnt/data/tmp/test/ffmpeg/libavformat/libavformat.so: undefined 
reference to `ff_frame_rate_tab'
-------------- next part --------------
A non-text attachment was scrubbed...
Name: public.diff
Type: text/x-diff
Size: 11571 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20080612/d7d41b94/attachment.diff>



More information about the ffmpeg-devel mailing list