[libc-commits] [libc] [libc] Set default visibility for LLVM functions (PR #116686)

Nick Desaulniers via libc-commits libc-commits at lists.llvm.org
Mon Nov 18 12:00:23 PST 2024


nickdesaulniers wrote:

> One potential issue with this patch might be that users who do use -DLLVM_LIBC_FUNCTION_ATTR may be surprised that they may need to re-set default visibility.

Something like:
```diff
diff --git a/libc/src/__support/common.h b/libc/src/__support/common.h
index 20d6f4c4a2af..d11a0b557570 100644
--- a/libc/src/__support/common.h
+++ b/libc/src/__support/common.h
@@ -18,14 +18,14 @@
 #include "src/__support/macros/properties/architectures.h"
 
 #ifndef LLVM_LIBC_FUNCTION_ATTR
-#define LLVM_LIBC_FUNCTION_ATTR [[gnu::visibility("default")]]
+#define LLVM_LIBC_FUNCTION_ATTR
 #endif
 
 // MacOS needs to be excluded because it does not support aliasing.
 #if defined(LIBC_COPT_PUBLIC_PACKAGING) && (!defined(__APPLE__))
 #define LLVM_LIBC_FUNCTION_IMPL(type, name, arglist)                           \
-  LLVM_LIBC_FUNCTION_ATTR decltype(LIBC_NAMESPACE::name)                       \
-      __##name##_impl__ __asm__(#name);                                        \
+  LLVM_LIBC_FUNCTION_ATTR [[gnu::visibility("default")]]                       \
+  decltype(LIBC_NAMESPACE::name) __##name##_impl__ __asm__(#name);             \
   decltype(LIBC_NAMESPACE::name) name [[gnu::alias(#name)]];                   \
   type __##name##_impl__ arglist
 #else
```
might avoid that, but I guess I don't know if downstream you're specifically trying to avoid default visibility on the non-namespaced symbols by setting `LLVM_LIBC_FUNCTION_ATTR`?

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


More information about the libc-commits mailing list