GNOME Bugzilla – Bug 783428
Cannot build pango with meson on FreeBSD
Last modified: 2017-07-18 15:00:33 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.
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.
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.
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.
*** Bug 783855 has been marked as a duplicate of this bug. ***
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.
Review of attachment 353182 [details] [review]: Looks good.
Review of attachment 353183 [details] [review]: Thanks, that looks good to me.
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