diff --git a/mkspecs/features/link_ltcg.prf b/mkspecs/features/link_ltcg.prf new file mode 100644 index 0000000000..537021f11b --- /dev/null +++ b/mkspecs/features/link_ltcg.prf @@ -0,0 +1,18 @@ +gcc { + # When doing link-time code generation, we need to pass the compiler + # flags during linking the stage too. This file is processed after + # default_post.prf, so the QMAKE_CXXFLAGS already contains + # QMAKE_CXXFLAGS_DEBUG or _RELEASE. + use_c_linker { + # use_c_linker.prf is in effect, use the C flags + QMAKE_LFLAGS_LTCG += $$QMAKE_CFLAGS $$QMAKE_CFLAGS_LTCG + QMAKE_LFLAGS_APP += $$QMAKE_CFLAGS_APP + QMAKE_LFLAGS_SHLIB += $$QMAKE_CFLAGS_SHLIB + QMAKE_LFLAGS_PLUGIN += $$QMAKE_CFLAGS_SHLIB + } else { + QMAKE_LFLAGS_LTCG = $$QMAKE_CXXFLAGS $$QMAKE_LFLAGS_LTCG + QMAKE_LFLAGS_APP += $$QMAKE_CXXFLAGS_APP + QMAKE_LFLAGS_SHLIB += $$QMAKE_CXXFLAGS_SHLIB + QMAKE_LFLAGS_PLUGIN += $$QMAKE_CFLAGS_SHLIB + } +} diff --git a/mkspecs/features/ltcg.prf b/mkspecs/features/ltcg.prf index 1459ccdc40..b0765a85c3 100644 --- a/mkspecs/features/ltcg.prf +++ b/mkspecs/features/ltcg.prf @@ -31,25 +31,9 @@ CONFIG(release, debug|release) { QMAKE_CXXFLAGS_LTCG = QMAKE_LFLAGS_LTCG = } - - # When doing link-time code generation, we need to pass the compiler - # flags during linking stage too. This file is processed after - # default_post.prf, so the QMAKE_CXXFLAGS already contains - # QMAKE_CXXFLAGS_DEBUG or _RELEASE. - use_c_linker { - # use_c_linker.prf is in effect, use the C flags - QMAKE_LFLAGS_LTCG += $$QMAKE_CFLAGS $$QMAKE_CFLAGS_LTCG - QMAKE_LFLAGS_APP += $$QMAKE_CFLAGS_APP - QMAKE_LFLAGS_SHLIB += $$QMAKE_CFLAGS_SHLIB - QMAKE_LFLAGS_PLUGIN += $$QMAKE_CFLAGS_SHLIB - } else { - QMAKE_LFLAGS_LTCG = $$QMAKE_CXXFLAGS $$QMAKE_LFLAGS_LTCG - QMAKE_LFLAGS_APP += $$QMAKE_CXXFLAGS_APP - QMAKE_LFLAGS_SHLIB += $$QMAKE_CXXFLAGS_SHLIB - QMAKE_LFLAGS_PLUGIN += $$QMAKE_CFLAGS_SHLIB - } } + load(link_ltcg) QMAKE_CFLAGS *= $$QMAKE_CFLAGS_LTCG QMAKE_CXXFLAGS *= $$QMAKE_CXXFLAGS_LTCG QMAKE_LFLAGS *= $$QMAKE_LFLAGS_LTCG diff --git a/mkspecs/features/qt_functions.prf b/mkspecs/features/qt_functions.prf index a9a622dd1d..7961f6512a 100644 --- a/mkspecs/features/qt_functions.prf +++ b/mkspecs/features/qt_functions.prf @@ -68,6 +68,7 @@ defineTest(qtAddModule) { using_privates = true export(using_privates) } + contains(MODULE_CONFIG, ltcg): CONFIG += link_ltcg qtProcessModuleFlags(CONFIG, QT.$${1}.CONFIG) qtProcessModuleFlags(DEFINES, QT.$${1}.DEFINES) diff --git a/mkspecs/features/qt_module_pris.prf b/mkspecs/features/qt_module_pris.prf index 9a876caf5e..03a8e5db71 100644 --- a/mkspecs/features/qt_module_pris.prf +++ b/mkspecs/features/qt_module_pris.prf @@ -66,6 +66,8 @@ MODULE_FWD_PRI = $$mod_work_pfx/qt_lib_$${MODULE_ID}.pri module_build_type = internal_module: \ module_build_type += internal_module + ltcg: \ + module_build_type += ltcg !isEmpty(MODULE_CONFIG): \ module_config = "QT.$${MODULE_ID}.CONFIG = $$MODULE_CONFIG" else: \