[llvm-commits] [PATCH] LLVM 3.0 broken in lib/Support/Windows/DynamicLibrary.inc

Ruben Van Boxem vanboxem.ruben at gmail.com
Wed Nov 2 07:22:44 PDT 2011


I don't know since when, but this file has been changed to remove all the
trickery (aka defines) needed for MinGW-w64 (and probably everything else
that as forgotten) to succesfully compile it.

Attached is a patch that reintroduces the compiler checking. I would like
to see this in LLVM 3.0, otherwise (by the looks of the reintroduced code)
anything newer than _MSC_VER_1500 will be broken.

Thanks!

Ruben

PS: any replies please "reply-to-all", only subscribed to cfe-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20111102/5e2fe363/attachment.html>
-------------- next part --------------
diff --git a/lib/Support/Windows/DynamicLibrary.inc b/lib/Support/Windows/DynamicLibrary.inc
index 83da82a..dba81b4 100644
--- a/lib/Support/Windows/DynamicLibrary.inc
+++ b/lib/Support/Windows/DynamicLibrary.inc
@@ -43,10 +43,34 @@ static DenseSet<HMODULE> *OpenedHandles;
 
 extern "C" {
 
-  static BOOL CALLBACK ELM_Callback(WIN32_ELMCB_PCSTR ModuleName,
-                                    ULONG_PTR ModuleBase,
+// Use old callback if:
+//  - Not using Visual Studio
+//  - Visual Studio 2005 or earlier but only if we are not using the Windows SDK
+//    or Windows SDK version is older than 6.0
+// Use new callback if:
+//  - Newer Visual Studio (comes with newer SDK).
+//  - Visual Studio 2005 with Windows SDK 6.0+
+#if defined(_MSC_VER)
+  #if _MSC_VER < 1500 && (!defined(VER_PRODUCTBUILD) || VER_PRODUCTBUILD < 6000)
+    #define OLD_ELM_CALLBACK_DECL 1
+  #endif
+#elif defined(__MINGW64__)
+  // Use new callback.
+#elif defined(__MINGW32__)
+  #define OLD_ELM_CALLBACK_DECL 1
+#endif
+
+#ifdef OLD_ELM_CALLBACK_DECL
+  static BOOL CALLBACK ELM_Callback(PSTR  ModuleName,
+                                    DWORD_PTR ModuleBase,
+                                    ULONG ModuleSize,
+                                    PVOID UserContext)
+#else
+  static BOOL CALLBACK ELM_Callback(PCSTR  ModuleName,
+                                    DWORD_PTR ModuleBase,
                                     ULONG ModuleSize,
                                     PVOID UserContext)
+#endif
   {
     // Ignore VC++ runtimes prior to 7.1.  Somehow some of them get loaded
     // into the process.


More information about the llvm-commits mailing list