P3: Somewhat important
We can make MSVC produce smaller binary by passing some specific parameters to it.
/O1: optimize for size. Will be enabled if pass -DFEATURE_optimize_size=ON when configuring Qt. TESTED. Can reduce the binary size quite some bit.
/Ob1: lower inline code expansion level. TESTED. Can reduce the binary size in some degree. Better use it together with /O1.
/Gy + /Zc:inline + /OPT:REF + /OPT:ICF: eliminate dead code. Qt's default since long time ago. /Gy will be implied by /O1 and /O2.
/Gw: optimize global data. TESTED. Can reduce the binary size indeed, but not very much.
/GL + /LTCG: enable whole program optimization / link time code generation. TESTED. Sometimes the binary size becomes smaller, sometimes larger, not sure the exact condition.
/GR-: disable runtime type information (RTTI) generation. TESTED. Can reduce the binary size in some degree, but sadly some Qt modules depend on this feature so we can't disable RTTI unconditionally.
/EHs-c-: disable C++ exception handling. TESTED. Can reduce the binary size quite some bit.
/EHsc + /d2FH4: enable C++ exception handling but use the new exception handling model introduced in VS2019. In theory it will be much smaller than the traditional exception handling model. The binary size will become much smaller if the code makes heavy usage of exception handling, such as Microsoft's WinUI library.
|For Gerrit Dashboard: QTBUG-98894|
|382116,4||MSVC: Optimize global data to reduce binary size||dev||qt/qtbase||Status: MERGED||+2||0|
|384442,1||MSVC: Reduce inline expansion level when optimize for size||dev||qt/qtbase||Status: ABANDONED||-1||0|