Don't repeat conditions of use_*_linker features in QtFeature.cmake

qt_config_linker_supports() repeated the conditions of all use_*_linker
features, because the features are not evaluated yet when this function
is called, and the function needs to know what linker is used to build Qt.

Move the required tests and features before any
qt_config_linker_supports() call and evaluate the use_*_linker features
early.

Change-Id: I306f032356682a0e82e4d7c4234e5bbc820ab143
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This commit is contained in:
Joerg Bornemann 2021-07-12 12:43:27 +02:00
parent adfb767bcc
commit 564f07086c
2 changed files with 62 additions and 55 deletions

View File

@ -1046,15 +1046,11 @@ function(qt_config_linker_supports_flag_test name)
# Select the right linker.
if(GCC OR CLANG)
# TODO: This works for now but is... suboptimal. Once
# QTBUG-86186 is resolved, we should check the *features*
# QT_FEATURE_use_gold_linker etc. instead of trying to
# replicate the feature conditions.
if(QT_FEATURE_use_gold_linker_alias OR INPUT_linker STREQUAL "gold")
if(QT_FEATURE_use_gold_linker)
list(PREPEND flags "-fuse-ld=gold")
elseif(INPUT_linker STREQUAL "bfd")
elseif(QT_FEATURE_use_bfd_linker)
list(PREPEND flags "-fuse-ld=bfd")
elseif(INPUT_linker STREQUAL "lld")
elseif(QT_FEATURE_use_lld_linker)
list(PREPEND flags "-fuse-ld=lld")
endif()
endif()
@ -1095,5 +1091,3 @@ function(qt_make_features_available target)
endforeach()
endforeach()
endfunction()

View File

@ -22,6 +22,65 @@ qt_find_package(WrapDBus1 1.2 PROVIDED_TARGETS dbus-1 MODULE_NAME global QMAKE_L
qt_find_package(Libudev PROVIDED_TARGETS PkgConfig::Libudev MODULE_NAME global QMAKE_LIB libudev)
#### Early-evaluated, Linker-related Tests and Features
qt_config_compiler_supports_flag_test(use_bfd_linker
LABEL "bfd linker"
FLAG "-fuse-ld=bfd"
)
qt_config_compiler_supports_flag_test(use_gold_linker
LABEL "gold linker"
FLAG "-fuse-ld=gold"
)
qt_config_compiler_supports_flag_test(use_lld_linker
LABEL "lld linker"
FLAG "-fuse-ld=lld"
)
qt_feature("use_bfd_linker"
PRIVATE
LABEL "bfd"
AUTODETECT false
CONDITION NOT WIN32 AND NOT INTEGRITY AND NOT WASM AND TEST_use_bfd_linker
ENABLE INPUT_linker STREQUAL 'bfd'
DISABLE INPUT_linker STREQUAL 'gold' OR INPUT_linker STREQUAL 'lld'
)
qt_feature_config("use_bfd_linker" QMAKE_PRIVATE_CONFIG)
qt_feature("use_gold_linker_alias"
AUTODETECT false
CONDITION NOT WIN32 AND NOT INTEGRITY AND NOT WASM AND TEST_use_gold_linker
)
qt_feature("use_gold_linker"
PRIVATE
LABEL "gold"
AUTODETECT false
CONDITION NOT WIN32 AND NOT INTEGRITY AND NOT WASM AND NOT rtems AND TEST_use_gold_linker
ENABLE INPUT_linker STREQUAL 'gold' OR QT_FEATURE_use_gold_linker_alias
DISABLE INPUT_linker STREQUAL 'bfd' OR INPUT_linker STREQUAL 'lld'
)
qt_feature_config("use_gold_linker" QMAKE_PRIVATE_CONFIG)
qt_feature("use_lld_linker"
PRIVATE
LABEL "lld"
AUTODETECT false
CONDITION NOT WIN32 AND NOT INTEGRITY AND NOT WASM AND TEST_use_lld_linker
ENABLE INPUT_linker STREQUAL 'lld'
DISABLE INPUT_linker STREQUAL 'bfd' OR INPUT_linker STREQUAL 'gold'
)
qt_feature_config("use_lld_linker" QMAKE_PRIVATE_CONFIG)
if(NOT QT_CONFIGURE_RUNNING)
qt_evaluate_feature(use_bfd_linker)
qt_evaluate_feature(use_gold_linker_alias)
qt_evaluate_feature(use_gold_linker)
qt_evaluate_feature(use_lld_linker)
endif()
#### Tests
# machineTuple
@ -98,21 +157,6 @@ qt_config_compile_test(precompile_header
PROJECT_PATH "${CMAKE_CURRENT_SOURCE_DIR}/config.tests/precompile_header"
)
qt_config_compiler_supports_flag_test(use_bfd_linker
LABEL "bfd linker"
FLAG "-fuse-ld=bfd"
)
qt_config_compiler_supports_flag_test(use_gold_linker
LABEL "gold linker"
FLAG "-fuse-ld=gold"
)
qt_config_compiler_supports_flag_test(use_lld_linker
LABEL "lld linker"
FLAG "-fuse-ld=lld"
)
qt_config_compiler_supports_flag_test(optimize_debug
LABEL "-Og support"
FLAG "-Og"
@ -360,37 +404,6 @@ qt_feature_config("cross_compile" QMAKE_PRIVATE_CONFIG)
qt_feature("gc_binaries" PRIVATE
CONDITION NOT QT_FEATURE_shared
)
qt_feature("use_bfd_linker"
PRIVATE # special case
LABEL "bfd"
AUTODETECT false
CONDITION NOT WIN32 AND NOT INTEGRITY AND NOT WASM AND TEST_use_bfd_linker
ENABLE INPUT_linker STREQUAL 'bfd'
DISABLE INPUT_linker STREQUAL 'gold' OR INPUT_linker STREQUAL 'lld'
)
qt_feature_config("use_bfd_linker" QMAKE_PRIVATE_CONFIG)
qt_feature("use_gold_linker_alias"
AUTODETECT false
CONDITION NOT WIN32 AND NOT INTEGRITY AND NOT WASM AND TEST_use_gold_linker
)
qt_feature("use_gold_linker"
PRIVATE # special case
LABEL "gold"
AUTODETECT false
CONDITION NOT WIN32 AND NOT INTEGRITY AND NOT WASM AND NOT rtems AND TEST_use_gold_linker
ENABLE INPUT_linker STREQUAL 'gold' OR QT_FEATURE_use_gold_linker_alias
DISABLE INPUT_linker STREQUAL 'bfd' OR INPUT_linker STREQUAL 'lld'
)
qt_feature_config("use_gold_linker" QMAKE_PRIVATE_CONFIG)
qt_feature("use_lld_linker"
PRIVATE # special case
LABEL "lld"
AUTODETECT false
CONDITION NOT WIN32 AND NOT INTEGRITY AND NOT WASM AND TEST_use_lld_linker
ENABLE INPUT_linker STREQUAL 'lld'
DISABLE INPUT_linker STREQUAL 'bfd' OR INPUT_linker STREQUAL 'gold'
)
qt_feature_config("use_lld_linker" QMAKE_PRIVATE_CONFIG)
qt_feature("optimize_debug"
LABEL "Optimize debug build"
AUTODETECT NOT QT_FEATURE_developer_build