Innumerable duplicate section warning Topic is solved

Do you have a question about makefiles, a compiler or IDE you are using and need to know how to set it up for wxWidgets or why it doesn't compile but other IDE's do ? Post your questions here.
Post Reply
Blueskull
In need of some credit
In need of some credit
Posts: 3
Joined: Mon May 28, 2018 9:12 pm

Innumerable duplicate section warning

Post by Blueskull »

Greetings. First time poster here, so if I ask some stupid questions, please bear with me.

I am trying to build a minimal version of wx for a small application, and I disabled a lot of features.

To be exact, I disabled these features:

../configure --disable-debug --enable-unicode --enable-monolithic --disable-debug_flag --disable-debug_info --disable-shared --enable-no_rtti --enable-no_exceptions --disable-tls --disable-intl --disable-xlocale --disable-protocols --disable-ftp --disable-http --disable-fileproto --disable-sockets --disable-ipv6 --disable-ole --disable-dataobj --disable-baseevtloop --disable-epollloop --disable-selectloop --disable-any --disable-arcstream --disable-base64 --disable-backtrace --disable-catch_segvs --disable-cmdline --disable-debugreport --disable-dialupman --disable-exceptions --disable-ffile --disable-filehistory --disable-filesystem --disable-fontenum --disable-fontmap --disable-fs_archive --disable-fs_inet --disable-fs_zip --disable-fsvolume --disable-fswatcher --disable-geometry --disable-mimetype --disable-printfposparam --disable-stdpaths --disable-stopwatch --disable-sysoptions --disable-tarstream --disable-variant --disable-zipstream --disable-url --disable-protocol --disable-protocol-http --disable-protocol-ftp --disable-protocol-file --disable-threads --disable-iniconf --disable-docview --disable-help --disable-mshtmlhelp --disable-html --disable-htmlhelp --disable-xrc --disable-aui --disable-propgrid --disable-ribbon --disable-stc --disable-loggui --disable-logwin --disable-logdialog --disable-mdi --disable-mdidoc --disable-mediactrl --disable-gstreamer8 --disable-richtext --disable-postscript --disable-printarch --disable-svg --disable-webkit --disable-webview --disable-graphics_ctx --disable-qtkit --disable-clipboard --disable-dnd --disable-markup --disable-animatectrl --disable-bannerwindow --disable-artstd --disable-arttango --disable-bmpcombobox --disable-calendar --disable-caret --disable-checklst --disable-collpane --disable-colourpicker --disable-comboctrl --disable-commandlinkbutton --disable-dataviewctrl --disable-datepick --disable-detect_sm --disable-display --disable-fontpicker --disable-grid --disable-headerctrl --disable-infobar --disable-odcombobox --disable-popupwin --disable-prefseditor --disable-richmsgdlg --disable-richtooltip --disable-rearrangectrl --disable-sash --disable-searchctrl --disable-splitter --disable-timepick --disable-tipwindow --disable-treelist --disable-aboutdlg --disable-coldlg --disable-finddlg --disable-fontdlg --disable-numberdlg --disable-splash --disable-textdlg --disable-tipdlg --disable-progressdlg --disable-wizarddlg --disable-miniframe --disable-splines --disable-mousewheel --disable-validators --disable-busyinfo --disable-hotkey --disable-joystick --disable-metafile --disable-dragimage --disable-accessibility --disable-uiactionsim --disable-dctransform --disable-webviewwebkit --disable-palette --disable-gif --disable-pcx --disable-tga --disable-iff --disable-pnm --disable-xpm --disable-ico_cur --disable-ps-in-msw --disable-webviewie --without-opengl --without-libjpeg --without-libtiff --without-libxpm --without-expat --without-regex --without-libiconv

The library compiles fine and the the test app compiles fine with the following command:

g++ main.cpp test.cpp testdlgMain.cpp `$(WX)/wx-config --cxxflags` -Wno-deprecated-declarations `$(WX)/wx-config --libs` -static -Os -o test.exe

However, I get one "duplicate section `.rdata$_ZTV20wxObjectEventFunctor[__ZTV20wxObjectEventFunctor]' has different size" from EACH object file in libwx_mswu-3.0.a, that's almost 150 of them!

The compiled artifact runs properly, though. But I just want to know why there are so many duplicate sections in rdata. Since they are in rdata, I presume they are some global constants or something, but I no idea how gcc/wx work internally.

This warning does NOT show when I compile the library with default ../configure settings (besides static and monolithic).

Environment: Win10-64, MSYS2, MinGW-w64-i686, gcc 7.3.0, wxWidgets 3.0.4.
Manolo
Can't get richer than this
Can't get richer than this
Posts: 827
Joined: Mon Apr 30, 2012 11:07 pm

Re: Innumerable duplicate section warning

Post by Manolo »

In a static build the point of so many "disable" is not clear. You will get a smaller static library, yes. But the linker will pick only the functions needed, and your app will be of the same size as if you have built the wx lib with not that much disables. For a shared wx lib (i.e. a .dll file in Windows) then the size (of the .dll) may matter.

There's one disable I suspect of: --disable-baseevtloop. I think that if you want to handle events (like "close") you need an event loop. And it looks related to your __ZTV20wxObjectEventFunctor warnings.

I don't know if some body has tried so many disables ever. I'm not sure if this could be a wx bug. If you have time, try disabling by groups of disables, not all of them at once, adding more groups step by step until you find the culprit.
Blueskull
In need of some credit
In need of some credit
Posts: 3
Joined: Mon May 28, 2018 9:12 pm

Re: Innumerable duplicate section warning

Post by Blueskull »

Removing options indeed shrinks the size of statically linked executables.
Some features are interlinked, as can be observed from wx source code -- lots of #ifdef/#ifundef blocks are used to insert and remove code blocks depending on compiling options.

For instance, with all features enabled, a simple hello world (wxDialog, wxApp and wxMsgDlg) runs about 5.3MB after being stripped.
With the library compiled with configuration shown above, the executable went down to 2.4MB after being stripped.
Packing both with UPX, the former became 1.8MB, while the latter became 0.8MB.

Anyway, after fiddling with options, I found the smoking gun being --enable-no_rtti. After disabling this option, the final executable links properly, and the size actually went down a little bit, by a few tens of kB.

The finished program is still larger than what I would like it to be. With TDM GCC 5.1.0, the final file went down to ~600kB after being UPXed. I seem to get stuck at 800kB with MinGW-w64-i686.
I did a simple test with -lstdc++_s, and it seems like the C++ library is 900kB, while the TDM version is much smaller. This could be the difference between the file sizes (2100kB vs 2500kB) -- so my next target is to shrink libstdc++.
Post Reply