diff --git a/llvm/include/llvm/Config/llvm-config.h.cmake b/llvm/include/llvm/Config/llvm-config.h.cmake --- a/llvm/include/llvm/Config/llvm-config.h.cmake +++ b/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 diff --git a/llvm/include/llvm/Support/Compiler.h b/llvm/include/llvm/Support/Compiler.h --- a/llvm/include/llvm/Support/Compiler.h +++ b/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