From 9198a9b8cc8df04ad130410a9c9f32de2b7b2335 Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Thu, 16 Dec 2021 13:25:43 +0100 Subject: [PATCH] CMake: Fix qt_run_linker_version_script_support to use active linker The version script compile test did not use the linker that the build system determined to use to link Qt, but rather the system linker. Run qt_run_linker_version_script_support only after the global qtbase features have been evaluated and make sure to include the active linker flags. Pick-to: 6.2 6.3 Change-Id: I0ff82406828daaf0dc5ec25a55f53ac7d98e3347 Reviewed-by: Joerg Bornemann Reviewed-by: Qt CI Bot Reviewed-by: Alexey Edelev --- cmake/QtBaseConfigureTests.cmake | 8 +++++++- cmake/QtBaseGlobalTargets.cmake | 5 +++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/cmake/QtBaseConfigureTests.cmake b/cmake/QtBaseConfigureTests.cmake index ae16e8e53be..618554e16c6 100644 --- a/cmake/QtBaseConfigureTests.cmake +++ b/cmake/QtBaseConfigureTests.cmake @@ -118,6 +118,13 @@ VERS_1; set(CMAKE_REQUIRED_FLAGS "") endif() set(CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS} "-Wl,--version-script=\"${CMAKE_CURRENT_BINARY_DIR}/version_flag.map\"") + + # Pass the linker that the main project uses to the version script compile test. + qt_internal_get_active_linker_flags(linker_flags) + if(linker_flags) + set(CMAKE_REQUIRED_LINK_OPTIONS ${linker_flags}) + endif() + check_cxx_source_compiles("int main(void){return 0;}" HAVE_LD_VERSION_SCRIPT) if(DEFINED CMAKE_REQUIRED_FLAGS_SAVE) set(CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS_SAVE}) @@ -164,7 +171,6 @@ endfunction() function(qt_run_qtbase_config_tests) qt_run_config_test_architecture() - qt_run_linker_version_script_support() qt_internal_ensure_latest_win_nt_api() endfunction() diff --git a/cmake/QtBaseGlobalTargets.cmake b/cmake/QtBaseGlobalTargets.cmake index c8499e39217..8cc19ac0309 100644 --- a/cmake/QtBaseGlobalTargets.cmake +++ b/cmake/QtBaseGlobalTargets.cmake @@ -107,6 +107,11 @@ endif() qt_feature_module_end(GlobalConfig OUT_VAR_PREFIX "__GlobalConfig_") +# The version script support check has to happen after we determined which linker is going +# to be used. The linker decision happens in the qtbase/configure.cmake file that is processed +# above. +qt_run_linker_version_script_support() + qt_generate_global_config_pri_file() qt_generate_global_module_pri_file() qt_generate_global_device_pri_file()