Skip to content

Commit

Permalink
Disable finalizers by default for the non-ld linkers
Browse files Browse the repository at this point in the history
Check if link order matters before use the object library finalizer.

Amends 5fb99e3

Pick-to: 6.2
Change-Id: Ie996bc175ebea36ccda1bb2fe388ae3b7fcde395
Reviewed-by: Alexandru Croitor <[email protected]>
  • Loading branch information
semlanik committed Jun 19, 2021
1 parent 72e21ad commit cdbb390
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
18 changes: 15 additions & 3 deletions cmake/QtPublicFinalizerHelpers.cmake
Original file line number Diff line number Diff line change
@@ -1,11 +1,23 @@
# Helper to check if the finalizer mode should be used.
# If true or unset, use finalizer mode.
# If true, use finalizer mode.
# If false, use regular mode (usage requirement propagation via associated Qt module)
# Arguments:
# DEFAULT_VALUE specifies the default value of the finalizer mode flag if it is not set.
function(__qt_internal_check_finalizer_mode target out_var finalizer)
set(option_args "")
set(single_args DEFAULT_VALUE)
set(multi_args "")
cmake_parse_arguments(arg "${option_args}" "${single_args}" "${multi_args}" ${ARGN})

if(NOT DEFINED arg_DEFAULT_VALUE OR arg_DEFAULT_VALUE)
set(arg_DEFAULT_VALUE TRUE)
else()
set(arg_DEFAULT_VALUE FALSE)
endif()
get_target_property(value ${target} _qt_${finalizer}_finalizer_mode)
if("${value}" STREQUAL "value-NOTFOUND")
__qt_internal_enable_finalizer_mode(${target} ${finalizer} "TRUE")
set(value "TRUE")
__qt_internal_enable_finalizer_mode(${target} ${finalizer} "${arg_DEFAULT_VALUE}")
set(value "${arg_DEFAULT_VALUE}")
endif()
set(${out_var} "${value}" PARENT_SCOPE)
endfunction()
Expand Down
4 changes: 4 additions & 0 deletions cmake/QtPublicTargetHelpers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,13 @@ function(__qt_internal_process_dependency_object_libraries target)
endif()
set_target_properties(${target} PROPERTIES _qt_object_libraries_finalizer_processed TRUE)

get_target_property(qt_link_order_matters
${QT_CMAKE_EXPORT_NAMESPACE}::Platform _qt_link_order_matters
)
__qt_internal_check_finalizer_mode(${target}
use_finalizer_mode
object_libraries
DEFAULT_VALUE "${qt_link_order_matters}"
)

if(NOT use_finalizer_mode)
Expand Down

0 comments on commit cdbb390

Please sign in to comment.