package/harfbuzz: fix build with gcc < 7

Fix the following build failure with gcc < 7 raised since bump to
version 4.4.0 in commit e186b4d89d:

In file included from ../src/hb.hh:473:0,
                 from ../src/hb-buffer-verify.cc:27:
../src/hb-cplusplus.hh:170:13: error: specialization of 'template<class _Tp> struct std::hash' in different namespace [-fpermissive]
 struct std::hash<hb::shared_ptr<T>>
             ^

Fixes:
 - http://autobuild.buildroot.org/results/3fe7526b685368007ae0f66e15ef2b27d30d5063

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
Reviewed-by: Giulio Benetti <giulio.benetti@benettiengineering.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
This commit is contained in:
Fabrice Fontaine 2022-07-12 18:27:12 +02:00 committed by Thomas Petazzoni
parent a81caea821
commit 5a73e4cca9
2 changed files with 106 additions and 0 deletions

View File

@ -0,0 +1,50 @@
From 7b51bc95d9cf0d9a2e91a37319fa34e4e5f26927 Mon Sep 17 00:00:00 2001
From: Kleis Auke Wolthuizen <github@kleisauke.nl>
Date: Wed, 6 Jul 2022 12:58:15 +0200
Subject: [PATCH] [cplusplus] Fix build on GCC < 7
[Retrieved from:
https://github.com/harfbuzz/harfbuzz/commit/7b51bc95d9cf0d9a2e91a37319fa34e4e5f26927]
Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
---
src/hb-cplusplus.hh | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/src/hb-cplusplus.hh b/src/hb-cplusplus.hh
index 86d0452080..f06a32d912 100644
--- a/src/hb-cplusplus.hh
+++ b/src/hb-cplusplus.hh
@@ -166,8 +166,14 @@ HB_DEFINE_VTABLE (unicode_funcs);
} // namespace hb
+/* Workaround for GCC < 7, see:
+ * https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56480
+ * https://stackoverflow.com/a/25594741 */
+namespace std {
+
+
template<typename T>
-struct std::hash<hb::shared_ptr<T>>
+struct hash<hb::shared_ptr<T>>
{
std::size_t operator()(const hb::shared_ptr<T>& v) const noexcept
{
@@ -177,7 +183,7 @@ struct std::hash<hb::shared_ptr<T>>
};
template<typename T>
-struct std::hash<hb::unique_ptr<T>>
+struct hash<hb::unique_ptr<T>>
{
std::size_t operator()(const hb::unique_ptr<T>& v) const noexcept
{
@@ -187,6 +193,8 @@ struct std::hash<hb::unique_ptr<T>>
};
+} // namespace std
+
#endif /* __cplusplus */
#endif /* HB_CPLUSPLUS_HH */

View File

@ -0,0 +1,56 @@
From 79eb0f74860fb6309e3162b4f17f98481c05a318 Mon Sep 17 00:00:00 2001
From: Kleis Auke Wolthuizen <github@kleisauke.nl>
Date: Wed, 6 Jul 2022 13:29:55 +0200
Subject: [PATCH] [GSUB] Fix build on GCC < 7
[Retrieved (and backported) from:
https://github.com/harfbuzz/harfbuzz/commit/79eb0f74860fb6309e3162b4f17f98481c05a318]
Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
---
src/OT/Layout/GSUB/GSUB.hh | 5 +++--
src/hb-ot-layout-gsub-table.hh | 8 ++++----
2 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/src/OT/Layout/GSUB/GSUB.hh b/src/OT/Layout/GSUB/GSUB.hh
index 372862e2bb..750dca1da3 100644
--- a/src/OT/Layout/GSUB/GSUB.hh
+++ b/src/OT/Layout/GSUB/GSUB.hh
@@ -5,9 +5,10 @@
#include "Common.hh"
#include "SubstLookup.hh"
-using OT::Layout::GSUB::SubstLookup;
-
namespace OT {
+
+using Layout::GSUB::SubstLookup;
+
namespace Layout {
/*
diff --git a/src/hb-ot-layout-gsub-table.hh b/src/hb-ot-layout-gsub-table.hh
index 1eca613b6a..50301ff1d9 100644
--- a/src/hb-ot-layout-gsub-table.hh
+++ b/src/hb-ot-layout-gsub-table.hh
@@ -32,9 +32,8 @@
#include "OT/Layout/GSUB/GSUB.hh"
namespace OT {
-
-using Layout::GSUB::SubstLookup;
-using Layout::GSUB::ExtensionSubst;
+namespace Layout {
+namespace GSUB {
// TODO(garretrieger): Move into the new layout directory.
/* Out-of-class implementation for methods recursing */
@@ -82,7 +81,8 @@ inline bool SubstLookup::dispatch_recurse_func<hb_ot_apply_context_t> (hb_ot_app
}
#endif
-
+} /* namespace GSUB */
+} /* namespace Layout */
} /* namespace OT */