Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-98894

Make the binary smaller on Windows

    XMLWordPrintable

    Details

    • Type: Suggestion
    • Status: Reported
    • Priority: P3: Somewhat important
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Build System
    • Labels:
      None
    • Platform/s:
      Windows

      Description

      We can make MSVC produce smaller binary by passing some specific parameters to it.

      Possible choices:

      /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.

        Attachments

        1. size compare-dev-c6c039.png
          127 kB
          赵 宇航
        2. size compare-dev-c6c039.xlsx
          15 kB
          赵 宇航
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

            Assignee:
            qtbuildsystem Qt Build System Team
            Reporter:
            wangwenx190 赵 宇航
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:

                Gerrit Reviews

                There are no open Gerrit changes