cristian.adam updated this revision to Diff 245683.
cristian.adam added a comment.

`-DLLVM_ENABLE_PIC=OFF`  on Windows if `LIBCLANG_BUILD_STATIC` is not set to 
`ON` will generate a SHARED libclang.dll


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D74907/new/

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
@@ -77,7 +77,7 @@
   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 @@
   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
 


Index: clang/tools/libclang/CMakeLists.txt
===================================================================
--- clang/tools/libclang/CMakeLists.txt
+++ clang/tools/libclang/CMakeLists.txt
@@ -77,7 +77,7 @@
   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 @@
   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
 
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to