[libc-commits] [libc] [libc] Migrate to using LIBC_NAMESPACE_DECL for namespace declaration (PR #98075)

Petr Hosek via libc-commits libc-commits at lists.llvm.org
Mon Jul 8 14:12:49 PDT 2024


petrhosek wrote:

> So, this replaces every single namespace declaration with the following?
> 
> ```c
> #define LIBC_NAMESPACE_DECL [[gnu::visibility("hidden")]] LIBC_NAMESPACE
> ```
> 
> Before that we need to identify all the entrypoints and make sure they retain default visibility. @frobtech suggested that we split that up into introducing a macro for exporting global variables, then we'd need to make sure that `LIBC_FUNCTION_ATTRS` includes default visibility.
> 
> However, that's if we want non-hidden visibility at all. The main effect of everything being hidden is that if someone does `clang -shared foo.c -lc` with our `libc` the symbols won't be visible from the shared library. Maybe that's the desired behavior? The GPU doesn't care because we have no shared libraries.

Correct, although it's currently incomplete. Specifically because `LIBC_NAMESPACE_DECL` is declared in `libc/src/__support/macros/config.h`, any file that uses it needs an additional `#include`. I'm trying to see if I can automate this using `clang-include-fixer` rather than doing this manually. Similarly, we also need need to update the CMake files to introduce the additional dependency which I don't yet have a solution for.

https://github.com/llvm/llvm-project/pull/98075


More information about the libc-commits mailing list