[tlbuild] Tweak for harfbuzz

Ken Brown kbrow1i at gmail.com
Wed Jan 10 19:46:15 CET 2018


On 12/26/2017 5:27 PM, Karl Berry wrote:
> Hi Ken and all,
> 
>      --- Build/source/libs/harfbuzz/configure.ac     (revision 46123)
>      +++ Build/source/libs/harfbuzz/configure.ac     (working copy)
>      ...
>      -       CXXFLAGS="$CXXFLAGS -std=c++11"
>      +       CXXFLAGS="$CXXFLAGS -std=c++11 -D_GNU_SOURCE"
> 
> Sure, inserted. Though it puzzles me that the original source apparently
> does nothing to force either -std=c++11 or -D_GNU_SOURCE. I guess it's
> because they see C++11 as "optional". I can't remember why we needed to
> require it, can't research further now. :(.

Hi Karl,

With the latest change (making C++ support optional), harfbuzz again 
wouldn't build on Cygwin without _GNU_SOURCE being defined.  But I 
looked into it more deeply and found that this is due to an error in the 
harfbuzz sources.

They actually do define _GNU_SOURCE in hb-private.hh, but they define it 
too far down in the file.  According to 
https://www.gnu.org/software/libc/manual/html_node/Feature-Test-Macros.html, 
feature test macros should be defined before the inclusion of any system 
headers, preferably at the top of the file.

The following patch fixes the problem:

--- Build/source/libs/harfbuzz/harfbuzz-src/src/hb-private.hh 
(revision 46275)
+++ Build/source/libs/harfbuzz/harfbuzz-src/src/hb-private.hh   (working 
copy)
@@ -29,6 +29,8 @@
  #ifndef HB_PRIVATE_HH
  #define HB_PRIVATE_HH

+#define _GNU_SOURCE 1
+
  #ifdef HAVE_CONFIG_H
  #include "config.h"
  #endif
@@ -86,8 +88,6 @@

  #endif // __cplusplus < 201103L

-#define _GNU_SOURCE 1
-
  #if (defined(__GNUC__) || defined(__clang__)) && defined(__OPTIMIZE__)
  #define likely(expr) (__builtin_expect (!!(expr), 1))
  #define unlikely(expr) (__builtin_expect (!!(expr), 0))


I've just submitted a bug report with this patch upstream:

   https://github.com/harfbuzz/harfbuzz/issues/693

Ken


More information about the tlbuild mailing list