[libunwind] r319300 - Support building libunwind as a DLL

Martin Storsjo via cfe-commits cfe-commits at lists.llvm.org
Wed Nov 29 00:21:12 PST 2017


Author: mstorsjo
Date: Wed Nov 29 00:21:12 2017
New Revision: 319300

URL: http://llvm.org/viewvc/llvm-project?rev=319300&view=rev
Log:
Support building libunwind as a DLL

Differential Revision: https://reviews.llvm.org/D40483

Modified:
    libunwind/trunk/CMakeLists.txt
    libunwind/trunk/src/config.h

Modified: libunwind/trunk/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/libunwind/trunk/CMakeLists.txt?rev=319300&r1=319299&r2=319300&view=diff
==============================================================================
--- libunwind/trunk/CMakeLists.txt (original)
+++ libunwind/trunk/CMakeLists.txt Wed Nov 29 00:21:12 2017
@@ -308,6 +308,11 @@ if (MSVC)
   add_definitions(-D_CRT_SECURE_NO_WARNINGS)
 endif()
 
+# Disable DLL annotations on Windows for static builds.
+if (WIN32 AND LIBUNWIND_ENABLE_STATIC AND NOT LIBUNWIND_ENABLE_SHARED)
+  add_definitions(-D_LIBUNWIND_DISABLE_VISIBILITY_ANNOTATIONS)
+endif()
+
 #===============================================================================
 # Setup Source Code
 #===============================================================================

Modified: libunwind/trunk/src/config.h
URL: http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/config.h?rev=319300&r1=319299&r2=319300&view=diff
==============================================================================
--- libunwind/trunk/src/config.h (original)
+++ libunwind/trunk/src/config.h Wed Nov 29 00:21:12 2017
@@ -50,9 +50,13 @@
   #define _LIBUNWIND_EXPORT
   #define _LIBUNWIND_HIDDEN
 #else
-  // FIXME: these macros are not correct for COFF targets
-  #define _LIBUNWIND_EXPORT __attribute__((visibility("default")))
-  #define _LIBUNWIND_HIDDEN __attribute__((visibility("hidden")))
+  #if !defined(__ELF__) && !defined(__MACH__)
+    #define _LIBUNWIND_EXPORT __declspec(dllexport)
+    #define _LIBUNWIND_HIDDEN
+  #else
+    #define _LIBUNWIND_EXPORT __attribute__((visibility("default")))
+    #define _LIBUNWIND_HIDDEN __attribute__((visibility("hidden")))
+  #endif
 #endif
 
 #if (defined(__APPLE__) && defined(__arm__)) || defined(__USING_SJLJ_EXCEPTIONS__)




More information about the cfe-commits mailing list