diff options
author | Alexandru Croitor <alexandru.croitor@qt.io> | 2020-10-02 18:24:32 +0200 |
---|---|---|
committer | Alexandru Croitor <alexandru.croitor@qt.io> | 2020-10-06 10:07:10 +0200 |
commit | 2354274f39934b94383923834479901106489def (patch) | |
tree | 5c509bbf04b5301c4866492b6f4dfb83e5668675 | |
parent | 98bea5857a0b63925ebab160a717105ad6ee9445 (diff) |
CMake: Allow embedding debug info in object files with MSVC
Introduce a new feature called 'FEATURE_msvc_obj_debug_info' which
should allow usage of sccache for Windows MSVC configs.
Enabling the feature will replace the default '/Zi' compile flag
that CMake sets in Windows-MSVC.cmake with '/Z7'.
This ensures that the debug info is placed into the compiled object
file instead of placing it in the compilation .pdb file via
mspdbsrv.exe.
The final pdb file will still be created for shared libraries and
executables due to the linker '/debug' flag.
Static libraries will not have a .pdb file, instead the debug info
being embeeded in the .lib file.
The downsides of using '/Z7' are more disk space usage, slower
link times, more memory used for linking because the linker needs
to deal with more symbols.
The upside is that caching each indepedent cl.exe call is possible.
This is what Chromium uses with goma, and Firefox with sccache.
We're not enabling the feature by default to allow easier
testing (and switching it off) in the CI if it proves not to be
feasible.
It will probably have to be disabled at least for building
qtwebengine due to high memory requirements.
Task-number: QTQAINFRA-3934
Change-Id: I89e0e57995e938a780be318d1faec700194aa93f
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
-rw-r--r-- | cmake/QtFlagHandlingHelpers.cmake | 11 | ||||
-rw-r--r-- | configure.cmake | 6 |
2 files changed, 17 insertions, 0 deletions
diff --git a/cmake/QtFlagHandlingHelpers.cmake b/cmake/QtFlagHandlingHelpers.cmake index 4dd37b35f7..b65bee2df6 100644 --- a/cmake/QtFlagHandlingHelpers.cmake +++ b/cmake/QtFlagHandlingHelpers.cmake @@ -832,6 +832,17 @@ function(qt_internal_set_up_config_optimizations_like_in_qmake) IN_CACHE) endif() + # Allow opting into generating debug info in object files with a fake feature. + # This would allow us to enable caching with sccache. + # See QTQAINFRA-3934 for details. + if(MSVC AND QT_FEATURE_msvc_obj_debug_info) + qt_internal_replace_compiler_flags( + "/Zi" "/Z7" + CONFIGS RELWITHDEBINFO DEBUG + TYPES ${target_link_types} + IN_CACHE) + endif() + if(QT_DEBUG_OPTIMIZATION_FLAGS) message(STATUS "") message(STATUS "DEBUG: Modified optimization flags to mirror qmake mkspecs.\n") diff --git a/configure.cmake b/configure.cmake index 46a6c776c0..57cd7baf39 100644 --- a/configure.cmake +++ b/configure.cmake @@ -437,6 +437,12 @@ qt_feature("optimize_full" AUTODETECT OFF ) qt_feature_config("optimize_full" QMAKE_PRIVATE_CONFIG) +qt_feature("msvc_obj_debug_info" + LABEL "Embed debug info in object files (MSVC)" + CONDITION MSVC + AUTODETECT OFF +) +qt_feature_config("msvc_obj_debug_info" QMAKE_PRIVATE_CONFIG) # special case end qt_feature("pkg-config" PUBLIC LABEL "Using pkg-config" |