<div dir="ltr">Hi Eli,<div><br></div><div>I can't say I'm super-excited about adding more workarounds, specially since I don't even understand why you can't use mingw64 instead.</div><div><br></div><div>At any rate, I'm not one to judge.  Please open a github Pull Request with your changes and we'll go from there.</div><div><br></div><div>Thanks</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, Jun 2, 2019 at 9:35 AM Eli Zaretskii <<a href="mailto:eliz@gnu.org">eliz@gnu.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi,<br>
<br>
I'd like to submit a few small patches that allow HarfBuzz to be built<br>
on Windows with <a href="http://mingw.org" rel="noreferrer" target="_blank">mingw.org</a>'s MinGW toolchain.  (And before you ask: the<br>
reason you don't see the problems I describe below in your MinGW<br>
builds is that you use MinGW64, which is a different flavor of MinGW.)<br>
<br>
The patches are against HarfBuzz 2.5.1.<br>
<br>
Here are the patches, with explanations:<br>
<br>
1. This patch is needed because MinGW doesn't have _BitScanForward and<br>
_BitScanReverse.  They are only used with old GCC versions, so<br>
conditioning their calls by those old versions of GCC is good enough,<br>
IMO.<br>
<br>
--- src/hb-algs.hh~0    2019-06-01 08:49:47.000000000 +0300<br>
+++ src/hb-algs.hh      2019-06-02 11:03:52.373677900 +0300<br>
@@ -400,7 +400,7 @@<br>
     return sizeof (unsigned long long) * 8 - __builtin_clzll (v);<br>
 #endif<br>
<br>
-#if (defined(_MSC_VER) && _MSC_VER >= 1500) || defined(__MINGW32__)<br>
+#if (defined(_MSC_VER) && _MSC_VER >= 1500) || (defined(__MINGW32__) && (__GNUC__ < 4))<br>
   if (sizeof (T) <= sizeof (unsigned int))<br>
   {<br>
     unsigned long where;<br>
@@ -474,7 +474,7 @@<br>
     return __builtin_ctzll (v);<br>
 #endif<br>
<br>
-#if (defined(_MSC_VER) && _MSC_VER >= 1500) || defined(__MINGW32__)<br>
+#if (defined(_MSC_VER) && _MSC_VER >= 1500) || (defined(__MINGW32__) && (__GNUC__ < 4))<br>
   if (sizeof (T) <= sizeof (unsigned int))<br>
   {<br>
     unsigned long where;<br>
<br>
<br>
2. This patch is needed because <a href="http://mingw.org" rel="noreferrer" target="_blank">mingw.org</a>'s MinGW defines<br>
MemoryBarrier as an inline function, not as a macro.<br>
__MINGW32_VERSION is defined only by <a href="http://mingw.org" rel="noreferrer" target="_blank">mingw.org</a>'s MinGW, so the change<br>
shouldn't affect MinGW64.<br>
<br>
--- src/hb-atomic.hh~0  2019-05-27 20:07:58.000000000 +0300<br>
+++ src/hb-atomic.hh    2019-06-02 10:55:49.013099500 +0300<br>
@@ -107,7 +107,7 @@<br>
<br>
 static inline void _hb_memory_barrier ()<br>
 {<br>
-#ifndef MemoryBarrier<br>
+#if !defined(MemoryBarrier) && !defined(__MINGW32_VERSION)<br>
   /* MinGW has a convoluted history of supporting MemoryBarrier. */<br>
   LONG dummy = 0;<br>
   InterlockedExchange (&dummy, 1);<br>
<br>
<br>
3. This patch is needed because MinGW doesn't define<br>
E_NOT_SUFFICIENT_BUFFER.<br>
<br>
--- src/hb-uniscribe.cc~0       2019-05-14 03:28:16.000000000 +0300<br>
+++ src/hb-uniscribe.cc 2019-06-02 11:04:43.843081900 +0300<br>
@@ -31,6 +31,10 @@<br>
 #include <usp10.h><br>
 #include <rpc.h><br>
<br>
+#ifndef E_NOT_SUFFICIENT_BUFFER<br>
+#define E_NOT_SUFFICIENT_BUFFER HRESULT_FROM_WIN32 (ERROR_INSUFFICIENT_BUFFER)<br>
+#endif<br>
+<br>
 #include "hb-uniscribe.h"<br>
<br>
 #include "hb-open-file.hh"<br>
<br>
<br>
4. This patch is needed because <a href="http://mingw.org" rel="noreferrer" target="_blank">mingw.org</a>'s MinGW doesn't have the<br>
intrin.h header file; instead, the intrinsics are declared by<br>
including windows.h.<br>
<br>
--- src/hb.hh~0 2019-05-14 09:42:00.000000000 +0300<br>
+++ src/hb.hh   2019-06-02 11:06:01.413041500 +0300<br>
@@ -183,8 +183,15 @@<br>
 #include <stdarg.h><br>
<br>
 #if (defined(_MSC_VER) && _MSC_VER >= 1500) || defined(__MINGW32__)<br>
+#ifdef __MINGW32_VERSION<br>
+#ifndef WIN32_LEAN_AND_MEAN<br>
+#define WIN32_LEAN_AND_MEAN 1<br>
+#endif<br>
+#include <windows.h><br>
+#else<br>
 #include <intrin.h><br>
 #endif<br>
+#endif<br>
<br>
 #define HB_PASTE1(a,b) a##b<br>
 #define HB_PASTE(a,b) HB_PASTE1(a,b)<br>
<br>
<br>
Thank you for developing HarfBuzz.<br>
_______________________________________________<br>
HarfBuzz mailing list<br>
<a href="mailto:HarfBuzz@lists.freedesktop.org" target="_blank">HarfBuzz@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/harfbuzz" rel="noreferrer" target="_blank">https://lists.freedesktop.org/mailman/listinfo/harfbuzz</a></blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature">behdad<br><a href="http://behdad.org/" target="_blank">http://behdad.org/</a></div>