Skip to content

[libc++] Always build the dylib with hidden visibility #131313

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 25, 2025

Conversation

philnik777
Copy link
Contributor

The comment seems to be wrong by now. The only difference this makes for GCC is that there are fewer private symbols exported from the dylib, which can't ever be accessed by user code anyways.

@philnik777 philnik777 marked this pull request as ready for review March 25, 2025 14:43
@philnik777 philnik777 requested a review from a team as a code owner March 25, 2025 14:43
@philnik777 philnik777 merged commit 7334024 into llvm:main Mar 25, 2025
82 of 87 checks passed
@llvmbot llvmbot added the libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi. label Mar 25, 2025
@llvmbot
Copy link
Member

llvmbot commented Mar 25, 2025

@llvm/pr-subscribers-libcxx

Author: Nikolas Klauser (philnik777)

Changes

The comment seems to be wrong by now. The only difference this makes for GCC is that there are fewer private symbols exported from the dylib, which can't ever be accessed by user code anyways.


Full diff: https://github.com/llvm/llvm-project/pull/131313.diff

1 Files Affected:

  • (modified) libcxx/CMakeLists.txt (+1-7)
diff --git a/libcxx/CMakeLists.txt b/libcxx/CMakeLists.txt
index abe12c2805a7c..ebaa6e9fd0e97 100644
--- a/libcxx/CMakeLists.txt
+++ b/libcxx/CMakeLists.txt
@@ -522,13 +522,7 @@ function(cxx_add_basic_build_flags target)
   # the dylib when get ODR used by another function.
   target_add_compile_flags_if_supported(${target} PRIVATE -fvisibility-inlines-hidden)
 
-  # Our visibility annotations are not quite right for non-Clang compilers,
-  # so we end up not exporting all the symbols we should. In the future, we
-  # can improve the situation by providing an explicit list of exported
-  # symbols on all compilers.
-  if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
-    target_add_compile_flags_if_supported(${target} PRIVATE -fvisibility=hidden)
-  endif()
+  target_add_compile_flags_if_supported(${target} PRIVATE -fvisibility=hidden)
 
   # 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.

@philnik777 philnik777 deleted the build_with_hidden_visibility branch March 29, 2025 08:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants