[Development] PSA: symbol visibility and export macros need to be re-thought for clang/libc++

Thiago Macieira thiago.macieira at intel.com
Fri Apr 4 20:24:21 CEST 2025


On Friday, 4 April 2025 11:15:35 Pacific Daylight Time Thiago Macieira wrote:
> BTW, I said we "have the same problem with QMetaType", but in reality we
> don't because we take this into account.
>     friend bool comparesEqual(const QMetaType &lhs,
>                               const QMetaType &rhs)
>     {
>         if (lhs.d_ptr == rhs.d_ptr)
>             return true;
>         if (!lhs.d_ptr || !rhs.d_ptr)
>             return false; // one type is undefined, the other is defined
>         // avoid id call if we already have the id
>         const int aId = lhs.id();
>         const int bId = rhs.id();
>         return aId == bId;
>     }

libstdc++'s type_info has similar code:
  _GLIBCXX23_CONSTEXPR inline bool
  type_info::operator==(const type_info& __arg) const _GLIBCXX_NOEXCEPT
  {
    if (std::__is_constant_evaluated())
      return this == &__arg;

    if (__name == __arg.__name)
      return true;

#if !__GXX_TYPEINFO_EQUALITY_INLINE
    // ABI requires comparisons to be non-inline.
    return __equal(__arg);
#elif !__GXX_MERGED_TYPEINFO_NAMES
    // Need to do string comparison.
    return __name[0] != '*' && __builtin_strcmp (__name, __arg.name()) == 0;
#else
    return false;
#endif
  }

I just don't know when it emits that * prefix. I've seen them before, but I 
don't recall the details of how it works. The GCC source code uses 
TREE_PUBLIC() but I don't understand how to set it.

libc++ does not have that: their std::type_info::operator== only compares the 
type_name pointer address on non-Windows systems (see the definition of the 
_LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION macro in <typeinfo>).

-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Principal Engineer - Intel DCAI Platform & System Engineering
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 5150 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/development/attachments/20250404/c1fb6324/attachment-0001.bin>


More information about the Development mailing list