This has been discussed here before, but I wanted to start adding visibility attributes to clang’s public classes and functions. The ultimate goal is to reduce the number of exported symbols in the libclang-cpp.so. This will make the library smaller and faster to load and it will give us more flexibility when backporting bug-fixes for the stable releases (less symbols means less fixes we have to reject or rewrite to avoid changes to the ABI).
The first step is to add the default visibility attribute to all the classes and functions declared in include/clang. This makes it possible to compile libclang-cpp.so with -fvisibility=hidden without (in theory) changing the visibility of any symbols currently exported in clang. Once this is complete, we can go through and start dropping default visibility from any classes or functions we don’t think need to be part of the library.
I have submitted a (patch)[⚙ D152051 libclang-cpp: Add external visibility attribute to all classes] implementing the first step of this process. I’ve tested this by building both lldb and clang-tools-extra with -DCLANG_LINK_CLANG_DYLIB and running
ninja check. Please take a look at the patch and let me know what you think.