Fix Android -ltcg build

We're passing -Oz for release builds, but that's not a flag the linker
understands when -ltcg is enabled.  The build fails with:
    ld.gold: fatal error: Optimization level must be between 0 and 3

Fix this by using -O2, which -Oz is based on, and -O3 for the "full
optimization" that is used for core and gui.

Pick-to: 6.2
Fixes: QTBUG-89472
Change-Id: Ie1a86888baefce5ca97026e7d635f10d2819f9f4
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This commit is contained in:
Joerg Bornemann 2021-08-19 22:13:53 +02:00
parent cd36734ff4
commit 80de516565
2 changed files with 14 additions and 2 deletions

View File

@ -168,8 +168,14 @@ endif()
# Android Clang
if(CLANG AND ANDROID)
set(QT_CFLAGS_OPTIMIZE "-Oz")
set(QT_CFLAGS_OPTIMIZE_FULL "-Oz")
if(QT_FEATURE_ltcg)
# When using LTCG, the linker cannot cope with -Oz. See QTBUG-89472 for details.
set(QT_CFLAGS_OPTIMIZE "-O2")
set(QT_CFLAGS_OPTIMIZE_FULL "-O3")
else()
set(QT_CFLAGS_OPTIMIZE "-Oz")
set(QT_CFLAGS_OPTIMIZE_FULL "-Oz")
endif()
endif()
# qcc

View File

@ -624,6 +624,12 @@ qt_feature("ltcg"
CONDITION __qt_ltcg_detected
)
qt_feature_config("ltcg" QMAKE_PRIVATE_CONFIG)
if(NOT QT_CONFIGURE_RUNNING)
# This feature is used early in QtCompilerOptimization.cmake.
qt_evaluate_feature(ltcg)
endif()
qt_feature("enable_new_dtags"
LABEL "Using new DTAGS"
CONDITION LINUX AND TEST_enable_new_dtags