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 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/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