On Friday, 4 April 2025 10:31:48 Pacific Daylight Time Giuseppe D'Angelo via 
Development wrote:
> (I'm still unsure about _how_ the attribute works, specifically how does
> it figure out the TU and thus the shared library in which to pin the
> RTTI information?)

I haven't looked at the patch, but looking at the code that Clang and GCC 
generated in the links to Godbolt I posted, I suspect all it will do is change 
whether to use .hidden, .protected or neither ("default") in the assembly 
output. There is no TU pinning: the symbols are @gnu_unique, so they will be 
merged by the linker at link time. And there's no shared-library pinning 
either, but that is already the case.

The difference is that for any code using "default" visibility, the symbols 
will be indirectly accessed via the GOT, instead of a PC-relative reference to 
something known to be in the executable. That's a minor performance loss, but 
it's required to implement the desired behaviour.

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;
    }

The QMetaType registration process takes type names into account to determine 
if two types are the same or not. That may be the right thing for the majority 
of types, but it's not for everything. For example, if two libraries have two 
different "struct Config" and register them, QMetaType will conclude they are 
the same. We could probably add a bit of smartness here by comparing the size, 
but that's still a good chance that it would be wrong.

Though we should definitely not do a name comparison for types in unnamed 
namespaces (types whose name start with "{anonymous}::" or "(anonymous 
namespace)::"

-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Principal Engineer - Intel DCAI Platform & System Engineering

Attachment: smime.p7s
Description: S/MIME cryptographic signature

-- 
Development mailing list
Development@qt-project.org
https://lists.qt-project.org/listinfo/development

Reply via email to