#!/bin/sh # Build script for glib2 (Meson, Template B). # Deps: pcre2 (ported, above), libffi + zlib (PRESENT in base, /usr/lib - # not ported; their .pc files are picked up via the /usr/lib/pkgconfig # entry below). iconv is provided by illumos libc - meson's builtin # dependency('iconv') probe finds it there with no extra flag needed. # # GOTCHA (Task 6): illumos ships a native Sun/illumos `msgfmt` at # /usr/bin/msgfmt that is NOT command-line compatible with GNU gettext's # msgfmt (confirmed on alpha9: `msgfmt --version` errors with "Cannot open # file --version" - it treats every arg as a filename to open, not an # option). glib's po/meson.build calls i18n.gettext(), which requires a # GNU-compatible msgfmt/xgettext. glib's own `nls` option defaults to # 'auto' and gates the entire po/ subdir behind `find_program('xgettext', # required: get_option('nls'))`, so passing -Dnls=disabled skips that # subdir entirely (no msgfmt/xgettext ever invoked) without touching any # core (non-translation) functionality. No devel/gettext port needed for # this port. # # GOTCHA (Task 6): meson's dtrace/systemtap options default to 'auto' and # both probe-detect true because /usr/sbin/dtrace exists on Hammerhead # (illumos DTrace). But glib's meson dtrace codegen step assumes the # Linux/systemtap-style two-pass workflow (compile objects with probes # first, THEN `dtrace -G` against those objects); it invokes # `dtrace -G -s glib_probes.d -o glib_probes.o` with ONLY the .d script # and no object files, which illumos dtrace rejects: "failed to link # script ...: No probe sites found for declared provider" - not an # illumos/dtrace bug, just glib's meson dtrace glue not matching how # illumos's -G-only invocation needs objects present. Static USDT probes # are optional instrumentation, not core functionality - disable # dtrace/systemtap explicitly rather than relying on 'auto' probing. set -e cd "$SRCDIR" # GOTCHA (Task 6): meson's host_machine.system() comes straight from # Python's platform.system().lower() at configure time, which on # Hammerhead reports 'hammerhead' (confirmed: `uname -s` => "Hammerhead" # post-SYSNAME_PLATFORM_RENAME), not 'sunos'. glib's meson.build has # several `host_system == 'sunos'` branches specifically for illumos/ # Solaris correctness - none of them fire for us. The one that bites at # build time: "if host_system != 'sunos': functions += ['sysinfo']" - # meson then probes cc.has_function('sysinfo') (true - illumos HAS a # sysinfo(), just the unrelated SVR4 systeminfo(2) one, not Linux's # struct-sysinfo RAM-stats one) and sets HAVE_SYSINFO, so # gio/gmemorymonitorbase.c compiles the Linux `struct sysinfo` # code path instead of its already-present Solaris sysconf(_SC_PHYS_PAGES) # fallback. Patch the guard to also exclude 'hammerhead' rather than # disabling memory-monitor functionality outright. if [ -f meson.build ]; then sed -i "s/if host_system != 'sunos'/if host_system != 'sunos' and host_system != 'hammerhead'/" meson.build fi export PKG_CONFIG_PATH="$PREFIX/lib/pkgconfig:$PREFIX/share/pkgconfig:/usr/lib/pkgconfig:$PKG_CONFIG_PATH" # GOTCHA (Task 6): illumos libc's iconv(3) takes `const char **` for the # input-buffer argument (POSIX-conformant), but glib/gconvert.c's g_iconv() # wrapper takes plain `char **` and passes it straight through (glib has no # configure-time ICONV_CONST detection - it assumes the glibc signature). # GCC 14 promoted -Wincompatible-pointer-types from a warning to a hard # error by default in C mode, so this one call site now fails the build. # Rather than patching upstream glib source, demote it back to a warning. # GOTCHA (Task 6): illumos's (and ) gate the POSIX.1c # 5-arg reentrant getpwnam_r()/getpwuid_r() prototypes (returning int, # via a 'struct passwd **' result out-param) behind # `_POSIX_C_SOURCE >= 199506L || defined(_POSIX_PTHREAD_SEMANTICS)`. # __EXTENSIONS__ alone is NOT enough - without one of those two also # defined, the header falls back to the legacy SVR4 4-arg form (returning # 'struct passwd *' directly), which is what glib/gutils.c's # g_get_user_database_entry() gets miscompiled against ("too many # arguments to function 'getpwnam_r'"). Define _POSIX_PTHREAD_SEMANTICS # to select the POSIX form glib expects (also fixes the same class of # issue for getgrnam_r/getgrgid_r if pango/harfbuzz/cairo ever probe them). # GOTCHA (Task 6): glib's meson.build has a `host_system == 'sunos'` # block (unreached here, same host_system-name mismatch as above) that # probes and sets the highest working `_XOPEN_SOURCE` (800/700/600) plus # __EXTENSIONS__ specifically so illumos's exposes the # XPG4v2 struct msghdr fields (msg_control/msg_controllen/msg_flags - # gated behind `#if defined(_XPG4_2)`, which /usr/include/sys/ # feature_tests.h only #defines once _XOPEN_SOURCE is set to 500+). # Without it, gio/gsocket.c's msghdr-based recvmsg/sendmsg ancillary-data # code fails ("struct msghdr has no member named msg_control"). Set # _XOPEN_SOURCE=700 directly (cascades to _XPG4_2 in feature_tests.h); # __EXTENSIONS__ is still required alongside it so the XOPEN-strict mode # doesn't hide the non-standard extensions glib also needs elsewhere. export CFLAGS="${CFLAGS} -D__EXTENSIONS__ -D_XOPEN_SOURCE=700 -D_POSIX_PTHREAD_SEMANTICS -Wno-error=incompatible-pointer-types" export LDFLAGS="${LDFLAGS} -Wl,-R,$PREFIX/lib" meson setup build \ --prefix="$PREFIX" \ --libdir=lib \ --sysconfdir="$SYSCONFDIR" \ --buildtype=release \ -Ddefault_library=shared \ -Dtests=false \ -Dselinux=disabled \ -Dxattr=false \ -Dman-pages=disabled \ -Dintrospection=disabled \ -Dnls=disabled \ -Ddtrace=disabled \ -Dsystemtap=disabled ninja -C build -j${JOBS:-1} DESTDIR="$PKGDIR" ninja -C build install # glib2 - core low-level cross-platform library (Openbox render-stack dep) # https://download.gnome.org/sources/glib/ # # VERSION NOTE (Task 6): the phase1a manifest listed 2.89.2, but GNOME's # glib versioning is even-minor=stable / odd-minor=development (2.89.x is # the development cycle leading to 2.90). Verified against # download.gnome.org/sources/glib/cache.json: the highest STABLE # (even-minor) release is 2.88.2 (2.86.x and earlier are older stable # lines). Using 2.88.2. [package] name = "glib2" version = "2.88.2" release = 1 description = "Core low-level cross-platform library (GLib/GObject/GIO)" url = "https://www.gtk.org/" license = "LGPL-2.1-or-later" maintainer = "Chris Tusa " arch = "x86_64" [dependencies] runtime = ["pcre2"] build = ["pcre2"] [[source]] file = "glib-2.88.2.tar.xz" urls = ["https://download.gnome.org/sources/glib/2.88/glib-2.88.2.tar.xz"] checksum = "cf3f215a640c8a4257f14317586b8f1fdd25a10a93cb4bdda147c0f9ad88e74f" [build] parallel = true