Re-apply "Only define LLVM_EXTERNAL_VISIBILITY when building libLLVM dylib"

With a fix for BUILD_SHARED_LIBS.

Original commit message:

When building LLVM static libraries, we should not make symbols more
visible than CMAKE_CXX_VISIBILITY_PRESET, since the goal may be to have
a purely hidden llvm embedded in another library. Instead, we only
define LLVM_EXTERNAL_VISIBILITY for the dynamic library build (when
LLVM_BUILD_LLVM_DYLIB=YES or BUILD_SHARED_LIBS=YES).

Original Review: https://reviews.llvm.org/D113610

Differential Revision: https://reviews.llvm.org/D115825
This commit is contained in:
Ben Langmuir committed 2021-12-16 09:25:41 -08:00
1 parent a2b3e6bed8
commit ec37e0bbaf
3 files changed
+14 -1

No files matched your search

+3
View File
@@ -788,6 +788,9 @@ foreach(t ${LLVM_TARGETS_TO_BUILD})
endif()
endforeach(t)
# Provide an LLVM_ namespaced alias for use in #cmakedefine.
set(LLVM_BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS})
# Produce the target definition files, which provide a way for clients to easily
# include various classes of targets.
configure_file(
@@ -103,4 +103,10 @@
/* Define if the xar_open() function is supported on this platform. */
#cmakedefine LLVM_HAVE_LIBXAR ${LLVM_HAVE_LIBXAR}
/* Define if building libLLVM shared library */
#cmakedefine LLVM_BUILD_LLVM_DYLIB
/* Define if building LLVM with BUILD_SHARED_LIBS */
#cmakedefine LLVM_BUILD_SHARED_LIBS
#endif
+5 -1
View File
@@ -126,7 +126,11 @@
#if __has_attribute(visibility) && !defined(__MINGW32__) && \
!defined(__CYGWIN__) && !defined(_WIN32)
#define LLVM_LIBRARY_VISIBILITY __attribute__ ((visibility("hidden")))
#define LLVM_EXTERNAL_VISIBILITY __attribute__ ((visibility("default")))
#if defined(LLVM_BUILD_LLVM_DYLIB) || defined(LLVM_BUILD_SHARED_LIBS)
#define LLVM_EXTERNAL_VISIBILITY __attribute__((visibility("default")))
#else
#define LLVM_EXTERNAL_VISIBILITY
#endif
#else
#define LLVM_LIBRARY_VISIBILITY
#define LLVM_EXTERNAL_VISIBILITY