diff --git a/cmake/QtFlagHandlingHelpers.cmake b/cmake/QtFlagHandlingHelpers.cmake index 4ef1bd78694..91e1de86445 100644 --- a/cmake/QtFlagHandlingHelpers.cmake +++ b/cmake/QtFlagHandlingHelpers.cmake @@ -1,6 +1,23 @@ # Copyright (C) 2022 The Qt Company Ltd. # SPDX-License-Identifier: BSD-3-Clause +# Sets '${var}' to a genex that extracts the target's property. +# Sets 'have_${var}' to a genex that checks that the property has a +# non-empty value. +macro(qt_internal_genex_get_property var target property) + set(${var} "$") + set(have_${var} "$") +endmacro() + +# Sets '${var}' to a genex that will join the given property values +# using '${glue}' and will surround the entire output with '${prefix}' +# and '${suffix}'. +macro(qt_internal_genex_get_joined_property var target property prefix suffix glue) + qt_internal_genex_get_property("${var}" "${target}" "${property}") + set(${var} + "$<${have_${var}}:${prefix}$${suffix}>") +endmacro() + # This function generates LD version script for the target and uses it in the target linker line. # Function has two modes dependending on the specified arguments. # Arguments: @@ -33,9 +50,21 @@ function(qt_internal_add_linker_version_script target) endif() string(APPEND contents "};\n") set(current "Qt_${PROJECT_VERSION_MAJOR}") - string(APPEND contents "${current} { *; };\n") + string(APPEND contents "${current} {\n *;") + + get_target_property(target_type ${target} TYPE) + if(NOT target_type STREQUAL "INTERFACE_LIBRARY") + set(genex_prefix "\n ") + set(genex_glue "$\n ") + set(genex_suffix "$") + qt_internal_genex_get_joined_property( + linker_exports "${target}" _qt_extra_linker_script_exports + "${genex_prefix}" "${genex_suffix}" "${genex_glue}" + ) + string(APPEND contents "${linker_exports}") + endif() + string(APPEND contents "\n};\n") - get_target_property(type ${target} TYPE) if(NOT target_type STREQUAL "INTERFACE_LIBRARY") set(property_genex "$") set(check_genex "$") diff --git a/cmake/QtTargetHelpers.cmake b/cmake/QtTargetHelpers.cmake index 180ec33b677..42e419cc703 100644 --- a/cmake/QtTargetHelpers.cmake +++ b/cmake/QtTargetHelpers.cmake @@ -16,6 +16,8 @@ # Custom compilation flags. # EXTRA_LINKER_SCRIPT_CONTENT # Extra content that should be appended to a target linker script. Applicable for ld only. +# EXTRA_LINKER_SCRIPT_EXPORTS +# Extra content that should be added to export section of the linker script. # NO_PCH_SOURCES # Skip the specified source files by PRECOMPILE_HEADERS feature. function(qt_internal_extend_target target) @@ -51,6 +53,7 @@ function(qt_internal_extend_target target) CONDITION CONDITION_INDEPENDENT_SOURCES COMPILE_FLAGS + EXTRA_LINKER_SCRIPT_EXPORTS ) cmake_parse_arguments(PARSE_ARGV 1 arg @@ -260,6 +263,10 @@ function(qt_internal_extend_target target) set_target_properties(${target} PROPERTIES _qt_extra_linker_script_content "${arg_EXTRA_LINKER_SCRIPT_CONTENT}") endif() + if(arg_EXTRA_LINKER_SCRIPT_EXPORTS) + set_target_properties(${target} PROPERTIES + _qt_extra_linker_script_exports "${arg_EXTRA_LINKER_SCRIPT_EXPORTS}") + endif() endfunction() function(qt_is_imported_target target out_var) diff --git a/src/corelib/CMakeLists.txt b/src/corelib/CMakeLists.txt index 99f460f24e3..e3f9ea3aeb7 100644 --- a/src/corelib/CMakeLists.txt +++ b/src/corelib/CMakeLists.txt @@ -1415,4 +1415,10 @@ foreach(minor_version RANGE ${PROJECT_VERSION_MINOR}) endforeach() qt_internal_extend_target(Core EXTRA_LINKER_SCRIPT_CONTENT "${linker_script_contents}" + + # Workaround for QTBUG-117514: + # Function called by inline methods taking a pointer to a private class as a parameter + EXTRA_LINKER_SCRIPT_EXPORTS + # QFutureInterfaceBase::setContinuation(std::function, QFutureInterfaceBasePrivate*) + "_ZN20QFutureInterfaceBase15setContinuationE*P27QFutureInterfaceBasePrivate" )