diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2023-07-27 21:31:44 -0700 |
---|---|---|
committer | Thiago Macieira <thiago.macieira@intel.com> | 2023-08-30 23:26:26 -0700 |
commit | 946f15efb76fffda37b77f7d194d679b904305b1 (patch) | |
tree | 62f59ea198d492634a1165c9bcdf61e614cf4df1 | |
parent | 167d28e77adbaeb482cfb3c27c5acd41777430cb (diff) |
CMake/ELF: hide all Standard Library symbols
We've had issues in the past where Standard Library constructs either
with or without a Qt type mangled in the middle get exported from our
ABI and thus get marked with the Qt version numbers. For example, I can
see in our libraries:
517: 000000000010e608 24 OBJECT GLOBAL DEFAULT 22 typeinfo for std::_Sp_counted_base<(__gnu_cxx::_Lock_policy)2>@@Qt_6
615: 00000000000eb2a0 47 OBJECT GLOBAL DEFAULT 17 typeinfo name for std::_Mutex_base<(__gnu_cxx::_Lock_policy)2>@@Qt_6
706: 000000000010e5f8 16 OBJECT GLOBAL DEFAULT 22 typeinfo for std::_Mutex_base<(__gnu_cxx::_Lock_policy)2>@@Qt_6
750: 00000000000ed5f0 16 OBJECT GLOBAL DEFAULT 17 std::_Sp_make_shared_tag::_S_ti()::__tag@@Qt_6
754: 00000000000da408 1 OBJECT GLOBAL DEFAULT 17 std::piecewise_construct@@Qt_6
This causes user content to break when an update to Qt stops exporting
such symbols, either because of code changes or because of changes to
the compiler and its optimizer.
In fact, this commit will cause that, for the symbols above. But this
will no longer be random-looking.
[ChangeLog][Important ABI Changes] On ELF-based platforms (e.g., Linux,
FreeBSD), the linking process has been updated to exclude Standard
Library symbols from getting the "Qt_6" ELF version. This solves the
problem of applications and libraries breaking arbitrarily after Qt
updates, but will cause such breakages right now. Content built with
older versions of Qt may need to be relinked.
Change-Id: I5acc02341c5940499682fffd1775edce0021ce6d
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
-rw-r--r-- | cmake/QtFlagHandlingHelpers.cmake | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/cmake/QtFlagHandlingHelpers.cmake b/cmake/QtFlagHandlingHelpers.cmake index 6784232ca9..04fb855269 100644 --- a/cmake/QtFlagHandlingHelpers.cmake +++ b/cmake/QtFlagHandlingHelpers.cmake @@ -23,7 +23,10 @@ function(qt_internal_add_linker_version_script target) endif() if(TEST_ld_version_script) - set(contents "Qt_${PROJECT_VERSION_MAJOR}_PRIVATE_API {\n qt_private_api_tag*;\n") + set(contents "NonQt { local:\n") + string(APPEND contents " _ZT?S*;\n") # {typeinfo {,name},vtable,VTT} for std:: + string(APPEND contents " extern \"C++\" { std::*; };\n") + string(APPEND contents "};\nQt_${PROJECT_VERSION_MAJOR}_PRIVATE_API { qt_private_api_tag*;\n") if(arg_PRIVATE_HEADERS) foreach(ph ${arg_PRIVATE_HEADERS}) string(APPEND contents " @FILE:${ph}@\n") |