Improvements #11281
openMore tweaks to reduce installed size of Wt
0%
Description
Hello, it would be great to have more CMAKE options to remove unused parts of wt (to reduce the footprint for embedded applications, docker images, etc.)
For example Wt::Auth, Bootstrap2/3/5 (one option for each one), things like that
What do you think?
Updated by Roel Standaert almost 2 years ago
I don't think removing Bootstrap themes will really make that much of a difference. A stripped MinSizeRel
libwt.so.4.9.1
is 6.5 MiB on my machine (using dynamically linked dependencies), and a quick and dirty removal of the Bootstrap themes saves only 58 KiB. Removing Wt::Auth is a bit more significant, making it 6.1 MiB.
However, you'll find that you can save a lot more if you use static linking with garbage collection, the documentation is a bit outdated, but the concept is still the same. If I configure with:
-DCMAKE_C_FLAGS="-ffunction-sections -fdata-sections"
-DCMAKE_CXX_FLAGS="-ffunction-sections -fdata-sections"
-DCMAKE_C_VISIBILITY_PRESET=hidden
-DCMAKE_CXX_VISIBILITY_PRESET=hidden
-DCMAKE_VISIBILITY_INLINES_HIDDEN=ON
-DCMAKE_EXE_LINKER_FLAGS="-Wl,--gc-sections"
-DSHARED_LIBS=OFF
-DINSTALL_EXAMPLES=ON
If I then do an install/strip
hello.wt
is only 1.9 MiB. Of course, I'm still using dynamically linked dependencies, for embedded applications you'd usually have statically linked dependencies built with similar options.
With those options, it shouldn't matter whether you're building Wt with Wt::Auth or Bootstrap themes. If you're not using them, they should get stripped out of your resulting executable entirely.
So I think it's probably not worth it. The feature flags that we do have are mostly related to which dependencies Wt requires.
Updated by Emeric Poupon almost 2 years ago
Thanks for your answer!
Actually for the bootstrap themes I was thinking about the resources installed in Wt/resources/themes/bootstrap
Example:
$ du * -sh
540K 2
1.6M 3
7.5M 5
It makes a huge difference to dig into these resources and manually remove what is not necessary (default/polished theme, jplayer, bootstrap3, etc.)