v0.70.0 build fails on macOS with undeclared identifier `W_EXITCODE`
Seen while packaging vte 0.70.0 in Homebrew -- https://github.com/Homebrew/homebrew-core/pull/111389 during the compilation steps via meson/ninja.
Failure log https://github.com/Homebrew/homebrew-core/actions/runs/3101682900/jobs/5023338316#step:6:390
The error message is
clang++ -Isrc/libvte-2.91.0.dylib.p -Isrc -I../src -I. -I.. -Isrc/vte -I../src/vte -I/opt/homebrew/Cellar/pcre2/10.40/include -I/opt/homebrew/Cellar/glib/2.74.0/include -I/opt/homebrew/Cellar/glib/2.74.0/include/glib-2.0 -I/opt/homebrew/Cellar/glib/2.74.0/lib/glib-2.0/include -I/opt/homebrew/opt/gettext/include -I/Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk/usr/include/ffi -I/opt/homebrew/Cellar/libpng/1.6.38/include/libpng16 -I/opt/homebrew/opt/freetype/include/freetype2 -I/opt/homebrew/Cellar/fontconfig/2.14.0/include -I/opt/homebrew/Cellar/libxau/1.0.10/include -I/opt/homebrew/Cellar/libxdmcp/1.1.3/include -I/opt/homebrew/Cellar/libxcb/1.15/include -I/opt/homebrew/Cellar/libx11/1.8.1/include -I/opt/homebrew/Cellar/libxext/1.3.4/include -I/opt/homebrew/Cellar/libxrender/0.9.10/include -I/opt/homebrew/Cellar/pixman/0.40.0/include/pixman-1 -I/opt/homebrew/Cellar/cairo/1.16.0_5/include/cairo -I/opt/homebrew/Cellar/fribidi/1.0.12/include/fribidi -I/opt/homebrew/Cellar/graphite2/1.3.14/include -I/opt/homebrew/Cellar/harfbuzz/5.2.0/include/harfbuzz -I/opt/homebrew/Cellar/pango/1.50.10/include/pango-1.0 -I/opt/homebrew/Cellar/xorgproto/2022.2/include -I/opt/homebrew/Cellar/libidn2/2.3.3/include -I/opt/homebrew/Cellar/libtasn1/4.19.0/include -I/opt/homebrew/Cellar/nettle/3.8.1/include -I/opt/homebrew/Cellar/p11-kit/0.24.1_1/include/p11-kit-1 -I/opt/homebrew/Cellar/gnutls/3.7.7/include -I/opt/homebrew/Cellar/icu4c/71.1/include -I/opt/homebrew/Cellar/glib/2.74.0/include/gio-unix-2.0 -I/opt/homebrew/Cellar/atk/2.38.0/include/atk-1.0 -I/opt/homebrew/Cellar/jpeg-turbo/2.1.4/include -I/opt/homebrew/Cellar/libtiff/4.4.0_1/include -I/opt/homebrew/Cellar/gdk-pixbuf/2.42.9/include/gdk-pixbuf-2.0 -I/opt/homebrew/Cellar/libepoxy/1.5.10/include -I/opt/homebrew/Cellar/gtk+3/3.24.34/include/gtk-3.0 -fcolor-diagnostics -O3 -std=gnu++20 -Wall -Wextra -Wcast-align -Wcast-function-type -Wempty-body -Wendif-labels -Werror=init-self -Werror=missing-include-dirs -Werror=pointer-arith -Wfloat-equal -Wignored-qualifiers -Winvalid-pch -Wmisleading-indentation -Wmissing-declarations -Wmissing-field-initializers -Wmissing-format-attribute -Wmissing-include-dirs -Wmissing-noreturn -Wno-address-of-packed-member -Wno-c99-designator -Wno-missing-field-initializers -Wno-packed -Wno-switch-enum -Wno-unused-parameter -Wshadow -Wshift-negative-value -Wsign-compare -Wstrict-aliasing=2 -Wtype-limits -Wundef -Wuninitialized -Wuninitialized -Wunused -Wunused-but-set-parameter -Wunused-but-set-variable -Wunused-function -Wunused-label -Wunused-local-typedefs -Wunused-value -Wunused-variable -Wvla -Wwrite-strings -fdiagnostics-show-option -fno-common -fno-strict-aliasing -Wnon-virtual-dtor -Wno-unknown-attributes -fvisibility-inlines-hidden -fvisibility=hidden -Werror=format=2 -Werror=format-nonliteral -Werror=format-security '-DG_LOG_DOMAIN="VTE"' '-DLOCALEDIR="/opt/homebrew/Cellar/vte3/0.70.0/share/locale"' -DVTE_COMPILATION -UPARSER_INCLUDE_NOP '-DGDK_VERSION_MIN_REQUIRED=(G_ENCODE_VERSION(3,24))' '-DGDK_VERSION_MAX_ALLOWED=(G_ENCODE_VERSION(3,24))' -DVTE_GTK=3 -MD -MQ src/libvte-2.91.0.dylib.p/widget.cc.o -MF src/libvte-2.91.0.dylib.p/widget.cc.o.d -o src/libvte-2.91.0.dylib.p/widget.cc.o -c ../src/widget.cc
../src/widget.cc:765:30: error: use of undeclared identifier 'W_EXITCODE'
int status = W_EXITCODE(0, SIGKILL);
^
1 error generated.
This may need a meson.build change similar to BSD platforms as the defines are only exposed in:
#if (!defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE))
#define WCOREDUMP(x) (_W_INT(x) & WCOREFLAG)
#define W_EXITCODE(ret, sig) ((ret) << 8 | (sig))
I see that meson.build will set _NETBSD_SOURCE
on NetBSD and unset _POSIX_C_SOURCE
/etc on FreeBSD.
Manually setting _DARWIN_C_SOURCE
via CFLAGS/CXXFLAGS did fix the build for me.
Also, in terms of patching meson.build, NetBSD/FreeBSD syntax didn't work for me, but the following did:
diff --git a/meson.build b/meson.build
index 49b849e0..0331a256 100644
--- a/meson.build
+++ b/meson.build
@@ -234,6 +234,10 @@ elif system == 'netbsd'
libc_feature_defines += [
'_NETBSD_SOURCE',
]
+elif system == 'darwin'
+ libc_feature_defines += [
+ ['_DARWIN_C_SOURCE', '1']
+ ]
endif
foreach f: libc_feature_defines
Edited by Michael Cho