After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 783428 - Cannot build pango with meson on FreeBSD
Cannot build pango with meson on FreeBSD
Status: RESOLVED FIXED
Product: pango
Classification: Platform
Component: general
unspecified
Other FreeBSD
: Normal normal
: ---
Assigned To: pango-maint
pango-maint
: 783855 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2017-06-05 13:26 UTC by Ting-Wei Lan
Modified: 2017-07-18 15:00 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Cast enum to int before doing calculation (1.17 KB, patch)
2017-06-05 13:44 UTC, Ting-Wei Lan
committed Details | Review
Don't check array for NULL (885 bytes, patch)
2017-06-05 13:44 UTC, Ting-Wei Lan
committed Details | Review
meson: Specify version when defining _POSIX_C_SOURCE (1.18 KB, patch)
2017-06-05 13:44 UTC, Ting-Wei Lan
committed Details | Review

Description Ting-Wei Lan 2017-06-05 13:26:07 UTC
There are two problems found when building pango with meson.


[4/102] Compiling c object 'pango/pango-1.0@sha/fonts.c.o'
FAILED: pango/pango-1.0@sha/fonts.c.o
clang  '-Ipango/pango-1.0@sha' '-Ipango' '-I../../source/pango/pango' '-I.' '-I../../source/pango/' '-Ipango/mini-fribidi' '-I../../source/pango/pango/mini-fribidi' '-I/home/lantw44/gnome/devinstall/include/glib-2.0' '-I/home/lantw44/gnome/devinstall/lib/glib-2.0/include' '-Xclang' '-fcolor-diagnostics' '-pipe' '-D_FILE_OFFSET_BITS=64' '-Wall' '-Winvalid-pch' '-std=c99' '-O2' '-g' '-D_POSIX_C_SOURCE' '-D_POSIX_THREAD_SAFE_FUNCTIONS' '-D_GNU_SOURCE' '-march=corei7' '-B/home/lantw44/.local/bin' '-g3' '-O1' '-fPIC' '-Wimplicit-function-declaration' '-Wstrict-prototypes' '-Wmissing-prototypes' '-Wnested-externs' '-Wold-style-definition' '-Wno-int-conversion' '-fno-strict-aliasing' '-Wpointer-arith' '-Wmissing-declarations' '-Wformat=2' '-Wformat-nonliteral' '-Wformat-security' '-Wunused' '-Wcast-align' '-Wmissing-noreturn' '-Wmissing-format-attribute' '-Wmissing-include-dirs' '-Wno-uninitialized' '-Wno-shadow' '-Werror=redundant-decls' '-Werror=implicit' '-Werror=nonnull' '-Werror=init-self' '-Werror=main' '-Werror=missing-braces' '-Werror=sequence-point' '-Werror=return-type' '-Werror=trigraphs' '-Werror=array-bounds' '-Werror=write-strings' '-Werror=address' '-Werror=int-to-pointer-cast' '-Werror=pointer-to-int-cast' '-Werror=empty-body' '-Werror=write-strings' '-Werror=undef' '-fvisibility=hidden' '-DPANGO_ENABLE_DEBUG' '-DG_LOG_DOMAIN="Pango"' '-DG_LOG_USE_STRUCTURED=1' '-DPANGO_COMPILATION' '-DPANGO_ENABLE_BACKEND' '-DPANGO_ENABLE_ENGINE' '-DSYSCONFDIR="/home/lantw44/gnome/devinstall/etc"' '-DLIBDIR="/home/lantw44/gnome/devinstall/lib"' '-MMD' '-MQ' 'pango/pango-1.0@sha/fonts.c.o' '-MF' 'pango/pango-1.0@sha/fonts.c.o.d' -o 'pango/pango-1.0@sha/fonts.c.o' -c ../../source/pango/pango/fonts.c
../../source/pango/pango/fonts.c:616:14: warning: taking the absolute value of unsigned type 'unsigned int' has no effect [-Wabsolute-value]
      return abs(a->weight - b->weight);
             ^
../../source/pango/pango/fonts.c:616:14: note: remove the call to 'abs' since unsigned values cannot be negative
      return abs(a->weight - b->weight);
             ^~~
../../source/pango/pango/fonts.c:623:24: warning: taking the absolute value of unsigned type 'unsigned int' has no effect [-Wabsolute-value]
      return 1000000 + abs (a->weight - b->weight);
                       ^
../../source/pango/pango/fonts.c:623:24: note: remove the call to 'abs' since unsigned values cannot be negative
      return 1000000 + abs (a->weight - b->weight);
                       ^~~~
../../source/pango/pango/fonts.c:1191:28: error: address of array 'map[i].str' will always evaluate to 'true' [-Werror,-Wpointer-bool-conversion]
      if (G_LIKELY (map[i].str && map[i].str[0]))
                    ~~~~~~~^~~ ~~
/home/lantw44/gnome/devinstall/include/glib-2.0/glib/gmacros.h:376:60: note: expanded from macro 'G_LIKELY'
#define G_LIKELY(expr) (__builtin_expect (_G_BOOLEAN_EXPR((expr)), 1))
                                                           ^~~~
/home/lantw44/gnome/devinstall/include/glib-2.0/glib/gmacros.h:370:8: note: expanded from macro '_G_BOOLEAN_EXPR'
   if (expr)                                    \
       ^~~~
2 warnings and 1 error generated.

It seems this is caused by -Werror flags added in meson.build. These warnings can be easily fixed and I will attach patches to fix them.


[10/94] Compiling c object 'pango/pango-1.0@sha/pango-utils.c.o'
FAILED: pango/pango-1.0@sha/pango-utils.c.o
clang  '-Ipango/pango-1.0@sha' '-Ipango' '-I../../source/pango/pango' '-I.' '-I../../source/pango/' '-Ipango/mini-fribidi' '-I../../source/pango/pango/mini-fribidi' '-I/home/lantw44/gnome/devinstall/include/glib-2.0' '-I/home/lantw44/gnome/devinstall/lib/glib-2.0/include' '-Xclang' '-fcolor-diagnostics' '-pipe' '-D_FILE_OFFSET_BITS=64' '-Wall' '-Winvalid-pch' '-std=c99' '-O2' '-g' '-D_POSIX_C_SOURCE' '-D_POSIX_THREAD_SAFE_FUNCTIONS' '-D_GNU_SOURCE' '-march=corei7' '-B/home/lantw44/.local/bin' '-g3' '-O1' '-fPIC' '-Wimplicit-function-declaration' '-Wstrict-prototypes' '-Wmissing-prototypes' '-Wnested-externs' '-Wold-style-definition' '-Wno-int-conversion' '-fno-strict-aliasing' '-Wpointer-arith' '-Wmissing-declarations' '-Wformat=2' '-Wformat-nonliteral' '-Wformat-security' '-Wunused' '-Wcast-align' '-Wmissing-noreturn' '-Wmissing-format-attribute' '-Wmissing-include-dirs' '-Wno-uninitialized' '-Wno-shadow' '-Werror=redundant-decls' '-Werror=implicit' '-Werror=nonnull' '-Werror=init-self' '-Werror=main' '-Werror=missing-braces' '-Werror=sequence-point' '-Werror=return-type' '-Werror=trigraphs' '-Werror=array-bounds' '-Werror=write-strings' '-Werror=address' '-Werror=int-to-pointer-cast' '-Werror=pointer-to-int-cast' '-Werror=empty-body' '-Werror=write-strings' '-Werror=undef' '-fvisibility=hidden' '-DPANGO_ENABLE_DEBUG' '-DG_LOG_DOMAIN="Pango"' '-DG_LOG_USE_STRUCTURED=1' '-DPANGO_COMPILATION' '-DPANGO_ENABLE_BACKEND' '-DPANGO_ENABLE_ENGINE' '-DSYSCONFDIR="/home/lantw44/gnome/devinstall/etc"' '-DLIBDIR="/home/lantw44/gnome/devinstall/lib"' '-MMD' '-MQ' 'pango/pango-1.0@sha/pango-utils.c.o' '-MF' 'pango/pango-1.0@sha/pango-utils.c.o.d' -o 'pango/pango-1.0@sha/pango-utils.c.o' -c ../../source/pango/pango/pango-utils.c
../../source/pango/pango/pango-utils.c:282:3: error: implicit declaration of function 'flockfile' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
  flockfile (stream);
  ^
../../source/pango/pango/pango-utils.c:290:11: error: implicit declaration of function 'getc_unlocked' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
      c = getc_unlocked (stream);
          ^
../../source/pango/pango/pango-utils.c:362:3: error: implicit declaration of function 'funlockfile' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
  funlockfile (stream);
  ^
../../source/pango/pango/pango-utils.c:362:3: note: did you mean 'flockfile'?
../../source/pango/pango/pango-utils.c:282:3: note: 'flockfile' declared here
  flockfile (stream);
  ^
3 errors generated.

This is caused by -D_POSIX_C_SOURCE used in meson.build. Using -D_POSIX_C_SOURCE on FreeBSD means POSIX 1003.1-1988, which hides many functions that are not available in this old standard. Replacing it with -D_POSIX_C_SOURCE=200809L fixes the problem.
Comment 1 Ting-Wei Lan 2017-06-05 13:44:01 UTC
Created attachment 353181 [details] [review]
Cast enum to int before doing calculation

It seems that it is possible for compilers to use unsigned interger
types to store enum values, so we should cast them to signed interger
types before doing calculation to avoid getting unexpected results.
Comment 2 Ting-Wei Lan 2017-06-05 13:44:43 UTC
Created attachment 353182 [details] [review]
Don't check array for NULL

Arrays can never be NULL, and doing unnecessary checking causes
compilers to show warnings.
Comment 3 Ting-Wei Lan 2017-06-05 13:44:49 UTC
Created attachment 353183 [details] [review]
meson: Specify version when defining _POSIX_C_SOURCE

FreeBSD libc assumes defining _POSIX_C_SOURCE without specifying a
version means a pre-C89 environment with the oldest version of POSIX
standard, IEEE Std 1003.1-1988, causing several functions used by pango
to be undeclared. To resolve this problem, simply provide a version
number when defining _POSIX_C_SOURCE.
Comment 4 Ernestas Kulik 2017-06-18 09:52:30 UTC
*** Bug 783855 has been marked as a duplicate of this bug. ***
Comment 5 Emmanuele Bassi (:ebassi) 2017-07-17 14:57:49 UTC
Review of attachment 353181 [details] [review]:

The ISO C99 spec says that enumerations must have, at minimum, the same storage size of an int, but some compilers do use unsigned int because the spec is even less useful than usual.

In any case, it's a good idea to do this.
Comment 6 Emmanuele Bassi (:ebassi) 2017-07-17 14:58:47 UTC
Review of attachment 353182 [details] [review]:

Looks good.
Comment 7 Emmanuele Bassi (:ebassi) 2017-07-17 14:59:12 UTC
Review of attachment 353183 [details] [review]:

Thanks, that looks good to me.
Comment 8 Ting-Wei Lan 2017-07-18 15:00:21 UTC
Attachment 353181 [details] pushed as a3325f6 - Cast enum to int before doing calculation
Attachment 353182 [details] pushed as 2e107ff - Don't check array for NULL
Attachment 353183 [details] pushed as ffba476 - meson: Specify version when defining _POSIX_C_SOURCE