[libcxx-commits] [libcxxabi] cb942d0 - [libc++abi] Always enable -fvisibility=hidden (#207333)

via libcxx-commits libcxx-commits at lists.llvm.org
Mon Jul 6 00:35:16 PDT 2026


Author: Nikolas Klauser
Date: 2026-07-06T09:35:11+02:00
New Revision: cb942d009a5ed029ce20d9b75b3604f551f0cb56

URL: https://github.com/llvm/llvm-project/commit/cb942d009a5ed029ce20d9b75b3604f551f0cb56
DIFF: https://github.com/llvm/llvm-project/commit/cb942d009a5ed029ce20d9b75b3604f551f0cb56.diff

LOG: [libc++abi] Always enable -fvisibility=hidden (#207333)

Building with `-fvisibility=hidden` is generally a good idea, since it
avoids unnecessary relocations when loading a dylib. For libc++abi this
should be a no-op, since most things are annotated explicitly. By
enabling `-fvisibility=hidden` we can remove these explicit annotations
however.

Added: 
    

Modified: 
    libcxxabi/src/CMakeLists.txt

Removed: 
    


################################################################################
diff  --git a/libcxxabi/src/CMakeLists.txt b/libcxxabi/src/CMakeLists.txt
index 1889d7d5a82de..fc66ce7187170 100644
--- a/libcxxabi/src/CMakeLists.txt
+++ b/libcxxabi/src/CMakeLists.txt
@@ -195,6 +195,7 @@ if (LIBCXXABI_SUPPORTS_SHARED_LIBRARY)
   # Build with -fsized-deallocation, which is default in recent versions of Clang.
   # TODO(LLVM 21): This can be dropped once we only support Clang >= 19.
   target_add_compile_flags_if_supported(cxxabi_shared_objects PRIVATE -fsized-deallocation)
+  target_add_compile_flags_if_supported(cxxabi_shared_objects PRIVATE -fvisibility=hidden)
 
   add_library(cxxabi_shared SHARED)
   set_target_properties(cxxabi_shared
@@ -285,9 +286,9 @@ target_compile_options(cxxabi_static_objects PRIVATE "${LIBCXXABI_ADDITIONAL_COM
 # Build with -fsized-deallocation, which is default in recent versions of Clang.
 # TODO(LLVM 21): This can be dropped once we only support Clang >= 19.
 target_add_compile_flags_if_supported(cxxabi_static_objects PRIVATE -fsized-deallocation)
+target_add_compile_flags_if_supported(cxxabi_static_objects PRIVATE -fvisibility=hidden)
 
 if(LIBCXXABI_HERMETIC_STATIC_LIBRARY)
-  target_add_compile_flags_if_supported(cxxabi_static_objects PRIVATE -fvisibility=hidden)
   # If the hermetic library doesn't define the operator new/delete functions
   # then its code shouldn't declare them with hidden visibility.  They might
   # actually be provided by a shared library at link time.


        


More information about the libcxx-commits mailing list