[PATCH] D113610: [cmake] Add option LLVM_ENABLE_VISIBILITY_MACROS
Ben Langmuir via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 10 14:01:10 PST 2021
benlangmuir created this revision.
benlangmuir added a reviewer: lhames.
Herald added subscribers: dexonsmith, mgorny.
benlangmuir requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Add an option `LLVM_ENABLE_VISIBILITY_MACROS` (default ON) to control whether or not to honor the `LLVM_*_VISIBILITY ` macros, or whether to use the normal visibility. This enables the configuration `-DLLVM_ENABLE_VISIBILITY_MACROS=0 -DCMAKE_CXX_VISIBILITY_PRESET=hidden` to stop exporting any symbols, which is useful when linking LLVM statically into a library that does not want to expose any LLVM symbols.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D113610
Files:
llvm/CMakeLists.txt
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
@@ -124,7 +124,8 @@
/// this attribute will be made public and visible outside of any shared library
/// they are linked in to.
#if __has_attribute(visibility) && !defined(__MINGW32__) && \
- !defined(__CYGWIN__) && !defined(_WIN32)
+ !defined(__CYGWIN__) && !defined(_WIN32) && \
+ defined(LLVM_ENABLE_VISIBILITY_MACROS)
#define LLVM_LIBRARY_VISIBILITY __attribute__ ((visibility("hidden")))
#define LLVM_EXTERNAL_VISIBILITY __attribute__ ((visibility("default")))
#else
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
@@ -100,4 +100,7 @@
/* Define if the xar_open() function is supported on this platform. */
#cmakedefine LLVM_HAVE_LIBXAR ${LLVM_HAVE_LIBXAR}
+/* Whether LLVM_*_VISIBILITY macros should be enabled */
+#cmakedefine LLVM_ENABLE_VISIBILITY_MACROS
+
#endif
Index: llvm/CMakeLists.txt
===================================================================
--- llvm/CMakeLists.txt
+++ llvm/CMakeLists.txt
@@ -729,6 +729,9 @@
" be removed in a future release.")
endif()
+set(LLVM_ENABLE_VISIBILITY_MACROS ON CACHE BOOL
+ "Whether to honor LLVM_*_VISIBILITY macros")
+
include(HandleLLVMOptions)
find_package(Python3 ${LLVM_MINIMUM_PYTHON_VERSION} REQUIRED
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D113610.386309.patch
Type: text/x-patch
Size: 1626 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211110/e849c57d/attachment.bin>
More information about the llvm-commits
mailing list