MSVC: Improve the LTCG build

When we use MSVC to build static libraries, enabling LTCG will
generate very large output, for example, Qt's bundled 3rd party
libraries can be greater than 100MB per file (some of them even >200MB!).
This is not good if we are building a shared version of Qt and
enabling LTCG at the same time. On Windows Qt's bundled 3rd party
dependencies will be built as static libraries and they will make
the final Qt package way too large. From my side, if I only build
a release version, the package size is usually around 500MB but
when LTCG is enabled, it become over 2GB. The exe and dlls' size
don't vary much, but there are many large static libraries.

Fixes: QTBUG-108719
Change-Id: Ic521f500b9c24389524e96a8cdc2e7b3427b51a9
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Amir Masoud Abdol <amir.abdol@qt.io>
This commit is contained in:
Yuhang Zhao 2022-11-22 15:22:30 +08:00
parent 58861f78c0
commit 0d708a9aad

View File

@ -310,6 +310,12 @@ function(qt_internal_add_3rdparty_library target)
qt_enable_separate_debug_info(${target} "${debug_install_dir}") qt_enable_separate_debug_info(${target} "${debug_install_dir}")
qt_internal_install_pdb_files(${target} "${INSTALL_LIBDIR}") qt_internal_install_pdb_files(${target} "${INSTALL_LIBDIR}")
endif() endif()
if(BUILD_SHARED_LIBS AND MSVC)
set_target_properties(${target} PROPERTIES
INTERPROCEDURAL_OPTIMIZATION OFF
)
endif()
endfunction() endfunction()
function(qt_install_3rdparty_library_wrap_config_extra_file target) function(qt_install_3rdparty_library_wrap_config_extra_file target)