CMake/ELF: allow using Qt's full version number in the private tags

We added the feature to tag private symbols using the Qt major version
only, because us developers often move between versions and need to keep
compiled code working, even when using private API (we're supposed to
know what we're doing). Linux distributions, however, want to be told
that something used private API and therefore needs to be rebuilt. See
[1][2][3].

Distributors will learn about this feature when updating Qt causes the
existing patch to fail to apply.

[1] https://build.opensuse.org/projects/openSUSE:Factory/packages/qt6-base/files/0001-Tell-the-truth-about-private-API.patch?expand=1
[2] https://src.fedoraproject.org/rpms/qt6-qtbase/blob/rawhide/f/qtbase-tell-the-truth-about-private-API.patch
[3] https://github.com/clearlinux-pkgs/qtbase/blob/main/tell-the-truth-about-private-api.patch

Change-Id: I5f663c2f9f4149af84fefffd17bed69026f4038d
Reviewed-by:  Alexey Edelev <alexey.edelev@qt.io>
(cherry picked from commit e0940081bc7439d87d9ca41402a543a9c17fb857)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Thiago Macieira 2024-03-21 10:07:03 -07:00 committed by Qt Cherry-pick Bot
parent d96653f559
commit bccbdc2255
2 changed files with 11 additions and 1 deletions

View File

@ -69,7 +69,11 @@ function(qt_internal_add_linker_version_script target)
endforeach()
endforeach()
string(APPEND contents "\n};\nQt_${PROJECT_VERSION_MAJOR}_PRIVATE_API { qt_private_api_tag*;\n")
string(APPEND contents "\n};\nQt_${PROJECT_VERSION_MAJOR}")
if(QT_FEATURE_elf_private_full_version)
string(APPEND contents ".${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}")
endif()
string(APPEND contents "_PRIVATE_API { qt_private_api_tag*;\n")
if(arg_PRIVATE_HEADERS)
foreach(ph ${arg_PRIVATE_HEADERS})
string(APPEND contents " @FILE:${ph}@\n")

View File

@ -551,6 +551,12 @@ qt_feature("rpath" PUBLIC
CONDITION BUILD_SHARED_LIBS AND UNIX AND NOT WIN32 AND NOT ANDROID
)
qt_feature_config("rpath" QMAKE_PUBLIC_QT_CONFIG)
qt_feature("elf_private_full_version" PRIVATE
LABEL "Use Qt's full version number in ELF version symbols"
AUTODETECT OFF
CONDITION BUILD_SHARED_LIBS AND UNIX AND NOT APPLE
)
qt_feature_config("elf_private_full_version" QMAKE_PRIVATE_QT_CONFIG)
qt_feature("force_asserts" PUBLIC
LABEL "Force assertions"
AUTODETECT OFF