[libc-commits] [libc] [libc] Disable hidden visibility for LIBC_NAMESPACE with GCC (PR #98549)

Petr Hosek via libc-commits libc-commits at lists.llvm.org
Thu Jul 11 14:05:24 PDT 2024


https://github.com/petrhosek updated https://github.com/llvm/llvm-project/pull/98549

>From 643fec286cd0a6910a08acae083ff5bebf28c0ea Mon Sep 17 00:00:00 2001
From: Petr Hosek <phosek at google.com>
Date: Thu, 11 Jul 2024 13:58:11 -0700
Subject: [PATCH 1/2] [libc] Disable hidden visibility for LIBC_NAMESPACE with
 GCC

GCC emits a warning when using the visibility attribute which needs
to be diagnosed and addressed, but this change should unbreak the GCC
build as a temporary workaround.
---
 libc/src/__support/macros/config.h | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/libc/src/__support/macros/config.h b/libc/src/__support/macros/config.h
index 5c3ec634449f8..23436365cc544 100644
--- a/libc/src/__support/macros/config.h
+++ b/libc/src/__support/macros/config.h
@@ -28,6 +28,7 @@
 #define LIBC_HAS_FEATURE(f) 0
 #endif
 
+#ifndef __GNUC__
 // Declare a LIBC_NAMESPACE with hidden visibility. `namespace
 // LIBC_NAMESPACE_DECL {` should be used around all declarations and definitions
 // for libc internals as opposed to just `namespace LIBC_NAMESPACE {`. This
@@ -37,5 +38,10 @@
 // dynamic relocations. This does not affect the public C symbols which are
 // controlled independently via `LLVM_LIBC_FUNCTION_ATTR`.
 #define LIBC_NAMESPACE_DECL [[gnu::visibility("hidden")]] LIBC_NAMESPACE
+#else
+// TODO(#98548): GCC emits a warning when using the visibility attribute which
+// needs to be diagnosed and addressed.
+#define LIBC_NAMESPACE_DECL LIBC_NAMESPACE
+#endif
 
 #endif // LLVM_LIBC_SRC___SUPPORT_MACROS_CONFIG_H

>From 193ad442bc7dfd6f81b49262c6fab9f1b413be06 Mon Sep 17 00:00:00 2001
From: Petr Hosek <phosek at google.com>
Date: Thu, 11 Jul 2024 14:04:59 -0700
Subject: [PATCH 2/2] Use `#ifdef __clang__`

---
 libc/src/__support/macros/config.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libc/src/__support/macros/config.h b/libc/src/__support/macros/config.h
index 23436365cc544..8b1263e08249c 100644
--- a/libc/src/__support/macros/config.h
+++ b/libc/src/__support/macros/config.h
@@ -28,7 +28,7 @@
 #define LIBC_HAS_FEATURE(f) 0
 #endif
 
-#ifndef __GNUC__
+#ifdef __clang__
 // Declare a LIBC_NAMESPACE with hidden visibility. `namespace
 // LIBC_NAMESPACE_DECL {` should be used around all declarations and definitions
 // for libc internals as opposed to just `namespace LIBC_NAMESPACE {`. This



More information about the libc-commits mailing list