[clang] 7a7c753 - libclang: Make shared object symbol exporting by default
Nico Weber via cfe-commits
cfe-commits at lists.llvm.org
Thu Feb 20 11:26:32 PST 2020
Author: Cristian Adam
Date: 2020-02-20T14:26:25-05:00
New Revision: 7a7c753b0cca6abb61f054842fb087dfc30dc563
URL: https://github.com/llvm/llvm-project/commit/7a7c753b0cca6abb61f054842fb087dfc30dc563
DIFF: https://github.com/llvm/llvm-project/commit/7a7c753b0cca6abb61f054842fb087dfc30dc563.diff
LOG: libclang: Make shared object symbol exporting by default
https://reviews.llvm.org/D74564 enabled static building for libclang,
and for non CMake consumers they had to set the `CMAKE_EXPORTS` define
when consuming libclang.
This commit makes the non CMake users of the static building have to define `CMAKE_NO_EXPORTS`.
Differential Revision: https://reviews.llvm.org/D74907
Added:
Modified:
clang/include/clang-c/Platform.h
clang/tools/libclang/CMakeLists.txt
Removed:
################################################################################
diff --git a/clang/include/clang-c/Platform.h b/clang/include/clang-c/Platform.h
index 9c15516f362f..67c1fff8ff78 100644
--- a/clang/include/clang-c/Platform.h
+++ b/clang/include/clang-c/Platform.h
@@ -19,6 +19,9 @@
LLVM_CLANG_C_EXTERN_C_BEGIN
/* Windows DLL import/export. */
+#ifndef CINDEX_NO_EXPORTS
+ #define CINDEX_EXPORTS
+#endif
#ifdef _WIN32
#ifdef CINDEX_EXPORTS
#ifdef _CINDEX_LIB_
@@ -27,7 +30,7 @@ LLVM_CLANG_C_EXTERN_C_BEGIN
#define CINDEX_LINKAGE __declspec(dllimport)
#endif
#endif
-#elif defined(CINDEX_EXPORTS)
+#elif defined(CINDEX_EXPORTS) && defined(__GNUC__)
#define CINDEX_LINKAGE __attribute__((visibility("default")))
#endif
diff --git a/clang/tools/libclang/CMakeLists.txt b/clang/tools/libclang/CMakeLists.txt
index 99de3b399855..3c5941e77848 100644
--- a/clang/tools/libclang/CMakeLists.txt
+++ b/clang/tools/libclang/CMakeLists.txt
@@ -77,7 +77,7 @@ if(MSVC)
set(LLVM_EXPORTED_SYMBOL_FILE)
endif()
-if(LLVM_ENABLE_PIC)
+if(LLVM_ENABLE_PIC OR NOT LIBCLANG_BUILD_STATIC)
set(ENABLE_SHARED SHARED)
endif()
@@ -113,8 +113,15 @@ add_clang_library(libclang ${ENABLE_SHARED} ${ENABLE_STATIC} INSTALL_WITH_TOOLCH
Support
)
+if(ENABLE_STATIC)
+ foreach(name libclang obj.libclang libclang_static)
+ if (TARGET ${name})
+ target_compile_definitions(${name} PUBLIC CINDEX_NO_EXPORTS)
+ endif()
+ endforeach()
+endif()
+
if(ENABLE_SHARED)
- target_compile_definitions(libclang PUBLIC CINDEX_EXPORTS)
if(WIN32)
set_target_properties(libclang
PROPERTIES
More information about the cfe-commits
mailing list