[PATCH] D74907: libclang: Make shared object symbol exporting by default
Cristian Adam via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Feb 20 09:06:35 PST 2020
cristian.adam created this revision.
cristian.adam added reviewers: yvvan, mstorsjo, thakis.
Herald added subscribers: cfe-commits, mgorny.
Herald added a project: clang.
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`.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D74907
Files:
clang/include/clang-c/Platform.h
clang/tools/libclang/CMakeLists.txt
Index: clang/tools/libclang/CMakeLists.txt
===================================================================
--- clang/tools/libclang/CMakeLists.txt
+++ clang/tools/libclang/CMakeLists.txt
@@ -113,8 +113,15 @@
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
Index: clang/include/clang-c/Platform.h
===================================================================
--- clang/include/clang-c/Platform.h
+++ 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 @@
#define CINDEX_LINKAGE __declspec(dllimport)
#endif
#endif
-#elif defined(CINDEX_EXPORTS)
+#elif defined(CINDEX_EXPORTS) && defined(__GNUC__)
#define CINDEX_LINKAGE __attribute__((visibility("default")))
#endif
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D74907.245667.patch
Type: text/x-patch
Size: 1226 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200220/2d43d2f8/attachment.bin>
More information about the cfe-commits
mailing list