[PATCH] D113610: Only set LLVM_EXTERNAL_VISIBILITY when building libLLVM dylib

Ben Langmuir via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 10 15:34:27 PST 2021


benlangmuir updated this revision to Diff 393605.
benlangmuir retitled this revision from "[cmake] Add option LLVM_ENABLE_VISIBILITY_MACROS" to "Only set LLVM_EXTERNAL_VISIBILITY when building libLLVM dylib".
benlangmuir edited the summary of this revision.
benlangmuir added a comment.

Updated to set LLVM_EXTERNAL_VISIBILITY only when building the LLVM dylib.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D113610/new/

https://reviews.llvm.org/D113610

Files:
  llvm/include/llvm/Config/llvm-config.h.cmake
  llvm/include/llvm/Support/Compiler.h


Index: llvm/include/llvm/Support/Compiler.h
===================================================================
--- llvm/include/llvm/Support/Compiler.h
+++ llvm/include/llvm/Support/Compiler.h
@@ -121,12 +121,16 @@
 /// On PE/COFF targets, library visibility is the default, so this isn't needed.
 ///
 /// LLVM_EXTERNAL_VISIBILITY - classes, functions, and variables marked with
-/// this attribute will be made public and visible outside of any shared library
-/// they are linked in to.
+/// this attribute will be made public and visible outside the libLLVM dynamic
+/// library.
 #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)
+#define LLVM_EXTERNAL_VISIBILITY __attribute__((visibility("default")))
+#else
+#define LLVM_EXTERNAL_VISIBILITY
+#endif
 #else
 #define LLVM_LIBRARY_VISIBILITY
 #define LLVM_EXTERNAL_VISIBILITY
Index: llvm/include/llvm/Config/llvm-config.h.cmake
===================================================================
--- llvm/include/llvm/Config/llvm-config.h.cmake
+++ llvm/include/llvm/Config/llvm-config.h.cmake
@@ -103,4 +103,7 @@
 /* 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
+
 #endif


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D113610.393605.patch
Type: text/x-patch
Size: 1549 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211210/c84e9a0d/attachment.bin>


More information about the llvm-commits mailing list