-O2 to the linker? 18%? I just tried that and the filesize is still the same.
-Wl,-O2
Am I missing something?
I don't know really, lol. When I read that in the manpages, I immediately tested it, and it turned a 802kB app into a 658kB app, which made me go "wowww!". I then tried recompiling wxWidgets in that manner, but it did not seem to make a difference (although I am not sure whether or not I did it correctly. You know compiling wxWidgets is not precisely intuitive...). And since building wx takes forever, I did not bother any further. So far my experience with it.
Personally, I have currently no need to squeeze every bit out of my applications, so I prefer the linker running faster instead
But still, there is more in it than the eye meets.
Although I don't know how the linker optimizes at all, I guess it is mostly useful on large executables because you have the minimum overhead of 4k due to sections (at least using PE, don't know the limits of ELF) which is less noticeable the bigger the executable is, and because most likely "optimize" means dead-stripping unused code and playing with function alignments where it does not break anything.
The most notable thing, however, is that nobody (including myself) ever reads the documentation (yes, reading documentation sucks almost as much as writing), but everybody thinks he knows the tools he is using.
And then one day after many years, you discover that you don't know anything at all... I have half an hour of reading documentations on my daily schedule now