From 133e989cee5b4e3b32afa10618d700c0590a9c63 Mon Sep 17 00:00:00 2001 From: Christophe Giboudeaux Date: Tue, 12 Jan 2021 12:31:10 +0100 Subject: CMake: Fix build with GCC and ltcg The porting script could not handle this special case. To achieve the same thing, we'll use an intermediate 'OBJECT' library which will get the '-fno-lto' build flag if the conditions are met. Fixes: QTBUG-89426 Change-Id: Ied62502ce9c7f7fd6b89fab166f7bccfcd6e7433 Reviewed-by: Joerg Bornemann (cherry picked from commit 2d4a40f93fd3f0fd31110ef7d19a12fc56c00967) Reviewed-by: Qt Cherry-pick Bot --- src/corelib/CMakeLists.txt | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) (limited to 'src/corelib/CMakeLists.txt') diff --git a/src/corelib/CMakeLists.txt b/src/corelib/CMakeLists.txt index 6389e9f09b..c4461da6b5 100644 --- a/src/corelib/CMakeLists.txt +++ b/src/corelib/CMakeLists.txt @@ -54,7 +54,6 @@ qt_internal_add_module(Core global/qsysinfo.h global/qsystemdetection.h global/qtypeinfo.h - global/qversiontagging.cpp global/qversiontagging.h # special case io/qabstractfileengine.cpp io/qabstractfileengine_p.h io/qbuffer.cpp io/qbuffer.h io/qdataurl.cpp io/qdataurl_p.h @@ -599,22 +598,28 @@ qt_internal_extend_target(Core CONDITION QT_FEATURE_journald PkgConfig::Libsystemd ) -#### Keys ignored in scope 39:.:global:global/global.pri:GCC AND ltcg: -# QMAKE_EXTRA_COMPILERS = "versiontagging_compiler" -# versiontagging_compiler.commands = "$$QMAKE_CXX" "-c" "$(CXXFLAGS)" "$(INCPATH)" "-fno-lto" "-o" "${QMAKE_FILE_OUT}" "${QMAKE_FILE_IN}" -# versiontagging_compiler.dependency_type = "TYPE_C" -# versiontagging_compiler.input = "VERSIONTAGGING_SOURCES" -# versiontagging_compiler.name = "compiling[versiontagging]" "${QMAKE_FILE_IN}" -# versiontagging_compiler.output = "${QMAKE_VAR_OBJECTS_DIR}${QMAKE_FILE_BASE}$${firstQMAKE_EXT_OBJ}" -# versiontagging_compiler.variable_out = "OBJECTS" +# special case begin +add_library(Core_versiontagging OBJECT + global/qversiontagging.cpp global/qversiontagging.h +) -#### Keys ignored in scope 40:.:global:global/global.pri:silent: -# versiontagging_compiler.commands = "@echo" "compiling[versiontagging]" "${QMAKE_FILE_IN}" "&&" +set_target_properties(Core_versiontagging PROPERTIES + COMPILE_OPTIONS $ + COMPILE_DEFINITIONS $ + INCLUDE_DIRECTORIES $ +) + +# Disable LTO, as the symbols disappear somehow under GCC +# (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=48200) +if(GCC AND FEATURE_ltcg) + target_compile_options(Core_versiontagging PRIVATE "-fno-lto") +endif() -qt_internal_extend_target(Core CONDITION NOT GCC OR NOT ltcg +qt_internal_extend_target(Core SOURCES - global/qversiontagging.cpp + $ ) +# special case end qt_internal_extend_target(Core CONDITION UNIX SOURCES -- cgit v1.2.3