aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2021-07-16 17:59:28 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2021-07-19 15:28:41 +0000
commitcbfe111a77eee86e11460629e02b35c17cd886c6 (patch)
treecc3c56c05df376ecd25ff78d9d21221554c75007
parent4d89fe418a9713c14c62953424f389f88d4fe060 (diff)
Fix Integrity duplicate symbol errors when linking an app with qml
The qmlcache_loader.cpp and qmlcachegen'd qml cpp files contain static initializers which contain the name of the file. On Integrity, this can lead to duplicate symbol errors when linking 2 qtquickcontrols2 style plugins into the same application, because the symbols have global visibility. There doesn't to be a way to control the visibility of these symbols. Work around the issue by making the generated file names more unique (by including the target name in the file name). Sample errors symbol __sti___16_GroupBox_qml_cpp_11acedbd multiply defined in Controls/Basic/libqtquickcontrols2basicstyleplugin.a(GroupBox_qml.cpp.o) Controls/Fusion/libqtquickcontrols2fusionstyleplugin.a(GroupBox_qml.cpp.o) symbol __sti___19_qmlcache_loader_cpp_11acedbd multiply defined in Controls/Basic/objects-Release/qtquickcontrols2basicstyleplugin_qmlcache/.rcc/qmlcache/qtquickcontrols2basicstyleplugin/qmlcache_loader.cpp.o Controls/Fusion/objects-Release/qtquickcontrols2fusionstyleplugin_qmlcache/.rcc/qmlcache/qtquickcontrols2fusionstyleplugin/qmlcache_loader.cpp.o Task-number: QTBUG-90757 Change-Id: I921b82a03993dee02367e65fcff7277565d39b71 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Tatiana Borisova <tatiana.borisova@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> (cherry picked from commit ab15dbdac277422e78a5ed241ce040ad5c369018) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--src/qml/Qt6QmlMacros.cmake27
1 files changed, 23 insertions, 4 deletions
diff --git a/src/qml/Qt6QmlMacros.cmake b/src/qml/Qt6QmlMacros.cmake
index 8ab618d012..2d9e6b55f3 100644
--- a/src/qml/Qt6QmlMacros.cmake
+++ b/src/qml/Qt6QmlMacros.cmake
@@ -684,10 +684,25 @@ function(_qt_internal_target_enable_qmlcachegen target output_targets_var qmlcac
set_target_properties(${target} PROPERTIES _qt_cachegen_set_up TRUE)
get_target_property(target_binary_dir ${target} BINARY_DIR)
- set(qmlcache_dir ${target_binary_dir}/.rcc/qmlcache/${target})
+ set(qmlcache_dir ${target_binary_dir}/.rcc/qmlcache)
set(qmlcache_resource_name qmlcache_${target})
- set(qmlcache_loader_cpp ${qmlcache_dir}/qmlcache_loader.cpp)
- set(qmlcache_loader_list ${qmlcache_dir}/qml_loader_file_list.rsp)
+
+ # INTEGRITY_SYMBOL_UNIQUENESS
+ # The cache loader file name has to be unique, because the Integrity compiler uses the file name
+ # for the generation of the translation unit static constructor symbol name.
+ # e.g. __sti___19_qmlcache_loader_cpp_11acedbd
+ # For some reason the symbol is created with global visibility.
+ #
+ # When an application links against the Basic and Fusion static qml plugins, the linker
+ # fails with duplicate symbol errors because both of those plugins will contain the same symbol.
+ #
+ # With gcc on regular Linux, the symbol names are also the same, but it's not a problem because
+ # they have local (hidden) visbility.
+ #
+ # Make the file name unique by prepending the target name.
+ set(qmlcache_loader_cpp ${qmlcache_dir}/${target}_qmlcache_loader.cpp)
+
+ set(qmlcache_loader_list ${qmlcache_dir}/${target}_qml_loader_file_list.rsp)
set(qmlcache_resource_paths "$<TARGET_PROPERTY:${target},QT_QML_MODULE_RESOURCE_PATHS>")
_qt_internal_genex_getjoinedproperty(qrc_resource_args ${target}
@@ -1387,7 +1402,11 @@ function(qt6_target_qml_sources target)
file(RELATIVE_PATH file_relative ${CMAKE_CURRENT_SOURCE_DIR} ${file_absolute})
string(REGEX REPLACE "\\.(js|mjs|qml)$" "_\\1" compiled_file ${file_relative})
string(REGEX REPLACE "[$#?]+" "_" compiled_file ${compiled_file})
- set(compiled_file "${CMAKE_CURRENT_BINARY_DIR}/.rcc/qmlcache/${target}/${compiled_file}.cpp")
+
+ # The file name needs to be unique to work around an Integrity compiler issue.
+ # Search for INTEGRITY_SYMBOL_UNIQUENESS in this file for details.
+ set(compiled_file
+ "${CMAKE_CURRENT_BINARY_DIR}/.rcc/qmlcache/${target}_${compiled_file}.cpp")
get_filename_component(out_dir ${compiled_file} DIRECTORY)
add_custom_command(