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

Milian Wolff mail at milianw.de
Fri Apr 4 17:07:27 CEST 2025


Hey all,

I recently learned that my understanding of how symbol visibility works, and 
how one is supposed to use the export macros we all know from Qt and KDE (and 
that I have used for the last ~20 years) is incorrect for clang/libc++. This 
is mostly a PSA at this stage only, as I cannot yet accurately give a 
meaningful suggestion of what to do instead. 

Please see https://github.com/llvm/llvm-project/issues/133725 for more details 
and the ongoing discussion. I'm trying to learn more, and get more 
documentation from the clang/libc++ folks. At the very least, the following 
part of Qt knowledge is _wrong_ for that specific target platform:

> Never export a non-polymorphic class wholesale
(From https://wiki.qt.io/Things_To_Look_Out_For_In_Reviews)

Because if you do so, and the type is public (i.e. all-inline), then you would 
not be able to safely put that into a `std::any` in one DSO and extract it in 
another DSO. The worst thing is that this is only detectable at runtime. In 
the context of Qt, maybe not a lot of people use std::any (yet?), but being 
compatible with std types should be paramount I hope you all agree. So maybe a 
separate macro needs to be added for `[[clang::type_visibility]]` and added to 
all public types, until https://github.com/llvm/llvm-project/issues/133905 
lands and we can use it to set this globally?

Cheers
-- 
Milian Wolff
mail at milianw.de
http://milianw.de
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.qt-project.org/pipermail/development/attachments/20250404/6c260cfa/attachment.sig>


More information about the Development mailing list