contrib: harfbuzz: Skip using the _BitScan intrinsics on mingw
authorMartin Storsjö <martin@martin.st>
Mon, 21 May 2018 11:55:15 +0000 (14:55 +0300)
committerMartin Storsjö <martin@martin.st>
Mon, 21 May 2018 11:56:55 +0000 (14:56 +0300)
In mingw targets, both when using GCC and Clang, the __GNUC__
intrinsics right above can be used in most cases anyway.

This fixes building with mingw-w64 for armv7/aarch64, which doesn't
implement the _BitScanForward/_BitScanReverse intrinsics yet.

Not upstreaming this fix yet since the correct fix would be to
implement these intrinsics in mingw-w64 for armv7 and aarch64 as well.

contrib/src/harfbuzz/0001-Skip-using-the-_BitScan-intrinsics-on-mingw.patch [new file with mode: 0644]
contrib/src/harfbuzz/rules.mak

diff --git a/contrib/src/harfbuzz/0001-Skip-using-the-_BitScan-intrinsics-on-mingw.patch b/contrib/src/harfbuzz/0001-Skip-using-the-_BitScan-intrinsics-on-mingw.patch
new file mode 100644 (file)
index 0000000..b933f62
--- /dev/null
@@ -0,0 +1,39 @@
+From 35bda45cd1a96de1802c2174d4c4469c4e204154 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Martin=20Storsj=C3=B6?= <martin@martin.st>
+Date: Mon, 21 May 2018 14:52:41 +0300
+Subject: [PATCH] Skip using the _BitScan intrinsics on mingw
+
+In mingw targets, both when using GCC and Clang, the __GNUC__
+intrinsics right above can be used in most cases anyway.
+
+This fixes building with mingw-w64 for armv7/aarch64, which doesn't
+implement the _BitScanForward/_BitScanReverse intrinsics yet.
+---
+ src/hb-private.hh | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/src/hb-private.hh b/src/hb-private.hh
+index daa496e..2fb6e71 100644
+--- a/src/hb-private.hh
++++ b/src/hb-private.hh
+@@ -380,7 +380,7 @@ _hb_bit_storage (T v)
+     return sizeof (unsigned long long) * 8 - __builtin_clzll (v);
+ #endif
+-#if defined(_MSC_VER) || defined(__MINGW32__)
++#if defined(_MSC_VER)
+   if (sizeof (T) <= sizeof (unsigned int))
+   {
+     unsigned long where;
+@@ -453,7 +453,7 @@ _hb_ctz (T v)
+     return __builtin_ctzll (v);
+ #endif
+-#if defined(_MSC_VER) || defined(__MINGW32__)
++#if defined(_MSC_VER)
+   if (sizeof (T) <= sizeof (unsigned int))
+   {
+     unsigned long where;
+-- 
+2.7.4
+
index 294deb2..45cb10d 100644 (file)
@@ -21,6 +21,7 @@ harfbuzz: harfbuzz-$(HARFBUZZ_VERSION).tar.bz2 .sum-harfbuzz
        $(APPLY) $(SRC)/harfbuzz/harfbuzz-aarch64.patch
        $(APPLY) $(SRC)/harfbuzz/harfbuzz-clang.patch
        $(APPLY) $(SRC)/harfbuzz/Cmake-test.patch
+       $(APPLY) $(SRC)/harfbuzz/0001-Skip-using-the-_BitScan-intrinsics-on-mingw.patch
        $(MOVE)
 
 DEPS_harfbuzz = freetype2 $(DEPS_freetype2)