[PATCH] D101972: Do not set CMAKE_CXX_VISIBILITY_PRESET to hidden

serge via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed May 5 22:15:24 PDT 2021


serge-sans-paille created this revision.
Herald added subscribers: hiraditya, mgorny.
serge-sans-paille requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Using this feature is error prone and interacts in subtle ways with the LLVM
codebase.

As an example, llvm::Any::TypeId::Id relies on the uniqueness of the address of a
static variable defined in a template function. hidden visibility implies vague
linkage for that variable, which does not guarantee the uniqueness of the address
across a binary and a shared library. This totally breaks the implementation of
llvm::Any.

See https://gcc.gnu.org/wiki/Visibility and https://gcc.gnu.org/onlinedocs/gcc/Vague-Linkage.html
for more information on that topic.


https://reviews.llvm.org/D101972

Files:
  llvm/lib/Target/CMakeLists.txt


Index: llvm/lib/Target/CMakeLists.txt
===================================================================
--- llvm/lib/Target/CMakeLists.txt
+++ llvm/lib/Target/CMakeLists.txt
@@ -19,14 +19,6 @@
   Support
   )
 
-# When building shared objects for each target there are some internal APIs
-# that are used across shared objects which we can't hide.
-if (NOT BUILD_SHARED_LIBS AND NOT APPLE)
-  # Set default visibility to hidden, so we don't export all the Target classes
-  # in libLLVM.so.
-  set(CMAKE_CXX_VISIBILITY_PRESET hidden)
-endif()
-
 foreach(t ${LLVM_TARGETS_TO_BUILD})
   message(STATUS "Targeting ${t}")
   add_subdirectory(${t})


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D101972.343286.patch
Type: text/x-patch
Size: 646 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210506/e8acd315/attachment.bin>


More information about the llvm-commits mailing list