diff options
author | Nirbheek Chauhan <nirbheek@centricular.com> | 2018-05-20 10:31:17 +0530 |
---|---|---|
committer | Nirbheek Chauhan <nirbheek@centricular.com> | 2018-05-22 12:09:50 +0530 |
commit | 5ff24813075ea2a746226bf479358811ddd40d05 (patch) | |
tree | 68aa54119f8499aa292a8d0ad4f990db3d950238 | |
parent | 85950cbb16048f85d2ba9c41bbf7136125afe97f (diff) |
Port glib and glib-networking recipes to meson
Also, always use gnutls system trust for glib-networking. This is
backported from latest master, and we should fix our gnutls config to
work with this. Porting it in early so we have some time to deal with
this before the next glib-networking stable release.
Tested on fedora linux, cross-win32/64, cross-android-universal, darwin,
cross-ios-universal, and windows/mingw.
23 files changed, 2541 insertions, 1146 deletions
diff --git a/cerbero/build/build.py b/cerbero/build/build.py index fbd085b5..d348f8f7 100644 --- a/cerbero/build/build.py +++ b/cerbero/build/build.py @@ -360,10 +360,6 @@ class CMake (MakefilesBase): MakefilesBase.configure(self) -# Note: We force stpcpy to be false because our ancient version of the mingw -# toolchain claims to provide it but doesn't define it in the standard string.h -# This is fixed in newer versions of GCC where stpcpy is only available when SSP -# support enabled. MESON_CROSS_FILE_TPL = \ ''' [host_machine] @@ -373,7 +369,6 @@ cpu = '{cpu}' endian = '{endian}' [properties] -has_function_stpcpy = false {extra_properties} [binaries] diff --git a/config/windows.config b/config/windows.config index 8da98c06..a099979b 100644 --- a/config/windows.config +++ b/config/windows.config @@ -46,7 +46,7 @@ os.environ['OBJCFLAGS'] = '-Wall -g -O2 ' ccache = use_ccache and 'ccache ' or '' # Toolchain environment -os.environ['CFLAGS'] += "-DWINVER=0x0501 -D_WIN32_WINNT=0x0501" +os.environ['CFLAGS'] += "-DWINVER=0x0600 -D_WIN32_WINNT=0x0600" os.environ['LIBRARY_PATH'] = "{0}/lib{1}".format(prefix, lib_suffix) os.environ['CXXFLAGS']=os.environ['CFLAGS'] os.environ['CC']= '%s%s' % (ccache, cmd('gcc')) diff --git a/packages/gstreamer-1.0-net.package b/packages/gstreamer-1.0-net.package index bd51bd79..f117feec 100644 --- a/packages/gstreamer-1.0-net.package +++ b/packages/gstreamer-1.0-net.package @@ -28,6 +28,6 @@ class Package(custom.GStreamer, package.Package): [DistroVersion.DEBIAN_SQUEEZE, DistroVersion.UBUNTU_MAVERICK, DistroVersion.UBUNTU_LUCID]: - self.files += ['glib-networking', 'glib-networking-static'] + self.files += ['glib-networking'] elif self.config.target_platform == Platform.LINUX: self.sys_deps = {self.config.target_distro_version: ['glib-networking']} diff --git a/recipes/build-tools/glib-tools.recipe b/recipes/build-tools/glib-tools.recipe index 505828d0..85e13fd4 100644 --- a/recipes/build-tools/glib-tools.recipe +++ b/recipes/build-tools/glib-tools.recipe @@ -2,33 +2,42 @@ class Recipe(recipe.Recipe): name = 'glib-tools' - version = '2.54.2' + version = '2.56.1' stype = SourceType.TARBALL - url = 'http://ftp.acc.umu.se/pub/GNOME/sources/glib/2.54/glib-%(version)s.tar.xz' + url = 'http://ftp.acc.umu.se/pub/GNOME/sources/glib/2.56/glib-%(version)s.tar.xz' tarball_dirname = 'glib-%(version)s' licenses = [License.LGPLv2Plus] - config_sh = 'sh autogen.sh' - configure_options = '--with-pcre=internal --disable-libmount --enable-dtrace=no ' + btype = BuildType.MESON + meson_options = {'gtk_doc': 'false', 'internal_pcre': 'true', 'libmount': 'false', + 'dtrace': 'false', 'iconv': 'libc'} deps = ['libffi', 'zlib'] - can_use_configure_cache = False - patches = ["../glib/0001-Let-user-disable-Cocoa-and-Carbon-support-on-demand.patch", - "../glib/0002-Optionally-revert-to-the-old-pre-2.28-URI-handler-co.patch", - "../glib/0003-Add-support-for-loading-GIO-modules-from-the-distro-.patch", + patches = ["../glib/0003-Add-support-for-loading-GIO-modules-from-the-distro-.patch", "../glib/0004-Allow-for-a-second-distro-GIO-module-path-as-used-on.patch", "../glib/0005-Blacklist-the-bamf-GIO-module.patch", "../glib/0006-giomodule-do-not-try-to-load-modules-from-gio-module.patch", "../glib/0008-Unhide-_g_io_modules_ensure_extension_points_registe.patch", '../glib/0009-Implementation-of-Cocoa-event-loop-integration-in-GM.patch', - '../glib/0010-GSocket-Fix-race-conditions-on-Win32-if-multiple-thr.patch', '../glib/0013-gmain-Fix-erroneous-if-condition-when-dtrace-is-disa.patch', - '../glib/0001-gmodule-Use-RTLD_DEFAULT-if-defined-__BIONIC__.patch' + '../glib/glib-2.57-meson-backported-fixes.patch', + '../glib/0001-DO-NOT-UPSTREAM-Prototypes-missing-in-Cerbero-s-anci.patch', ] def prepare(self): if self.config.target_platform != Platform.LINUX: - self.configure_options += ' --disable-gtk-doc ' - elif self.config.target_platform == Platform.WINDOWS: - self.configure_options = '--with-libiconv=gnu' - self.append_env['CFLAGS'] = ' -DMINGW_HAS_SECURE_API=1 ' - elif self.config.target_platform in Platform.DARWIN: - self.config_sh = 'CFLAGS="$CFLAGS -DHAVE_STRNDUP" ./configure' + # Disable valgrind code on non-Linux, in the best case it just + # gives us compiler errors :) + self.append_env['CFLAGS'] = ' -DNVALGRIND=1 ' + self.meson_options.update({'xattr': 'false'}) + # macOS provides libiconv as a separate library + if self.config.target_platform == Platform.DARWIN: + self.meson_options.update({'iconv': 'native'}) + # linux and BSD provide iconv as a part of libc + elif self.config.target_platform == Platform.LINUX: + self.meson_options.update({'iconv': 'libc'}) + # Other platforms don't provide libiconv, so we build it + else: + self.meson_options.update({'iconv': 'gnu'}) + if self.config.target_platform == Platform.WINDOWS: + # Want secure versions of stdlib functions. Glib already defines + # _WIN32_WINNT, so undefine it on the cmdline to avoid warnings + self.append_env['CFLAGS'] = ' -DMINGW_HAS_SECURE_API=1 -U_WIN32_WINNT ' diff --git a/recipes/glib-networking-static.recipe b/recipes/glib-networking-static.recipe deleted file mode 100644 index 5000c551..00000000 --- a/recipes/glib-networking-static.recipe +++ /dev/null @@ -1,44 +0,0 @@ -# -*- Mode: Python -*- vi:si:et:sw=4:sts=4:ts=4:syntax=python -import shutil -import os -from cerbero.errors import FatalError -from cerbero.utils.shell import which - -class Recipe(recipe.Recipe): - name = 'glib-networking-static' - version = '2.54.1' - licenses = [License.LGPLv2Plus] - stype = SourceType.TARBALL - url = 'http://ftp.gnome.org/pub/gnome/sources/glib-networking/2.54/glib-networking-%(version)s.tar.xz' - tarball_dirname = 'glib-networking-%(version)s' - autoreconf = True - configure_options = "--without-ca-certificates --enable-static-modules --enable-static --enable-more-warnings" - deps = ['glib', 'gnutls', 'glib-networking'] - patches = ['glib-networking/0001-Add-support-for-static-modules.patch', - 'glib-networking/0002-Get-the-CA-certificate-path-from-the-environment-var.patch', - 'glib-networking/0003-gnutls-Use-db-relative-to-libglib-2.0-if-needed.patch', - 'glib-networking/0004-gtlsbackend-gnutls-Get-anchor-file-relative-to-libgi.patch'] - - - files_devel = ['lib/gio/modules/static/libgiognutls.a', - 'lib/gio/modules/static/libgiognutls.la'] - - def prepare(self): - self.tmp_destdir = os.path.join(self.build_dir, 'static-build') - - querymodule_path = which('true') - - if self.config.target_platform in [Platform.ANDROID, Platform.IOS]: - self.append_env['CFLAGS'] = ' -DGST_CA_CERTIFICATES_FROM_ENV' - - self.config_sh = 'GIO_QUERYMODULES=%s %s' % (querymodule_path, self.config_sh) - - def install(self): - plugins_dir = os.path.join(self.config.prefix, - os.path.dirname(self.files_devel[0])) - if not os.path.exists(plugins_dir): - os.makedirs(plugins_dir) - shutil.copy(os.path.join(self.build_dir, 'tls', 'gnutls', '.libs', - 'libgiognutls.a'), plugins_dir) - shutil.copy(os.path.join(self.build_dir, 'tls', 'gnutls', '.libs', - 'libgiognutls.la'), plugins_dir) diff --git a/recipes/glib-networking.recipe b/recipes/glib-networking.recipe index ee30ccb8..24476df1 100644 --- a/recipes/glib-networking.recipe +++ b/recipes/glib-networking.recipe @@ -4,35 +4,23 @@ from cerbero.utils.shell import which class Recipe(recipe.Recipe): name = 'glib-networking' - version = '2.54.1' + version = '2.56.0' licenses = [License.LGPLv2Plus] stype = SourceType.TARBALL - url = 'http://ftp.gnome.org/pub/gnome/sources/glib-networking/2.54/glib-networking-%(version)s.tar.xz' - autoreconf = True - configure_options = "--without-ca-certificates --enable-more-warnings" + btype = BuildType.MESON + url = 'http://ftp.gnome.org/pub/gnome/sources/glib-networking/2.56/glib-networking-%(version)s.tar.xz' + meson_options = {'ca_certificates_path': '', 'libproxy_support': 'false', + 'gnome_proxy_support': 'false', 'pkcs11_support': 'false'} deps = ['glib', 'gnutls'] - patches = ['glib-networking/0001-Add-support-for-static-modules.patch', - 'glib-networking/0002-Get-the-CA-certificate-path-from-the-environment-var.patch', - 'glib-networking/0003-gnutls-Use-db-relative-to-libglib-2.0-if-needed.patch', - 'glib-networking/0004-gtlsbackend-gnutls-Get-anchor-file-relative-to-libgi.patch'] + patches = [name + '/0001-Fix-building-tls-plugin-without-pkcs11.patch', + # XXX: This patch may require changes to gnutls's system trust + # since we can no longer set the certificate path in glib-networking + name + '/0001-Use-the-GnuTLS-system-trust-by-default.patch', + name + '/0006-meson-Only-run-gio-querymodules-if-it-s-found.patch'] files_misc = ['lib/gio/modules/libgiognutls%(mext)s'] files_lang = ['glib-networking'] def prepare(self): - querymodule_path = os.path.join(self.config.prefix, 'bin', 'gio-querymodules') - if self.config.target_platform in [Platform.DARWIN, Platform.IOS]: - # For the universal build we need to use the right gio-querymodules - arch = self.config.target_arch - arch_path = os.path.join(self.config.prefix, arch, 'bin', 'gio-querymodules') - # Only for the universal builds - if os.path.exists(arch_path): - querymodule_path = arch_path - - if self.config.cross_compiling(): - querymodule_path = which('true') - - if self.config.target_platform in [Platform.ANDROID]: - self.append_env['CFLAGS'] = ' -DGST_CA_CERTIFICATES_FROM_ENV' - - self.config_sh = 'GIO_QUERYMODULES=%s %s' % (querymodule_path, self.config_sh) + if self.config.target_platform in [Platform.ANDROID, Platform.IOS]: + self.meson_options.update({'static_modules': 'true'}) diff --git a/recipes/glib-networking/0001-Add-support-for-static-modules.patch b/recipes/glib-networking/0001-Add-support-for-static-modules.patch deleted file mode 100644 index 82f403b9..00000000 --- a/recipes/glib-networking/0001-Add-support-for-static-modules.patch +++ /dev/null @@ -1,180 +0,0 @@ -From b09cd11cc3339fe89fbb944e253e6bba70f7b5fd Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= <sebastian@centricular.com> -Date: Fri, 7 Mar 2014 12:50:24 +0100 -Subject: [PATCH 1/2] Add support for static modules - -Other than the previous approach this now doesn't go via -dlopen() and stuff but just registers the module directly. - -Also does not require any GLib changes. ---- - configure.ac | 20 ++++++++++++++++++++ - glib-networking.mk | 5 ++++- - tls/gnutls/gnutls-module.c | 12 +++++++++++- - tls/gnutls/gtlsbackend-gnutls.c | 27 ++++++++++++++++++++++----- - tls/gnutls/gtlsbackend-gnutls.h | 7 ++++++- - 5 files changed, 63 insertions(+), 8 deletions(-) - -diff --git a/configure.ac b/configure.ac -index 84ceb68..a5521a0 100644 ---- a/configure.ac -+++ b/configure.ac -@@ -233,6 +233,26 @@ if test "$GCC" = "yes" -a "$set_more_warnings" != "no"; then - -Werror=declaration-after-statement" - fi - -+dnl **************************************************** -+dnl *** Check for GIO static modules *** -+dnl **************************************************** -+AC_MSG_CHECKING([whether to build static modules or not]) -+AC_ARG_ENABLE( -+ static-modules, -+ AC_HELP_STRING( -+ [--enable-static-modules], -+ [build static modules @<:@default=no@:>@]), -+ [AS_CASE( -+ [$enableval], [no], [], [yes], [], -+ [AC_MSG_ERROR([bad value "$enableval" for --enable-static-modules])])], -+ [enable_static_modules=no]) -+AC_MSG_RESULT([$enable_static_modules]) -+if test "x$enable_static_modules" = xyes; then -+ AC_DEFINE(G_IO_MODULE_BUILD_STATIC, 1, -+ [Define if static modules should be built]) -+fi -+AM_CONDITIONAL(G_IO_MODULE_BUILD_STATIC, [test "x$enable_static_modules" = "xyes"]) -+ - dnl ***************************** - dnl *** done *** - dnl ***************************** -diff --git a/glib-networking.mk b/glib-networking.mk -index 29b6a6a..5231766 100644 ---- a/glib-networking.mk -+++ b/glib-networking.mk -@@ -1,6 +1,9 @@ - ### glib-networking declarations - --module_flags = -export_dynamic -avoid-version -module -no-undefined -export-symbols-regex '^g_io_module_(load|unload|query)' -+module_flags = -export_dynamic -avoid-version -module -no-undefined -+if !G_IO_MODULE_BUILD_STATIC -+module_flags += -export-symbols-regex '^g_io_module_(load|unload|query)' -+endif - - giomoduledir = $(GIO_MODULE_DIR) - -diff --git a/tls/gnutls/gnutls-module.c b/tls/gnutls/gnutls-module.c -index a725f9b..8da3c2b 100644 ---- a/tls/gnutls/gnutls-module.c -+++ b/tls/gnutls/gnutls-module.c -@@ -24,7 +24,16 @@ - #include "gtlsbackend-gnutls.h" - #include "gtlsbackend-gnutls-pkcs11.h" - -- -+#ifdef G_IO_MODULE_BUILD_STATIC -+void -+g_io_module_gnutls_register (void) -+{ -+ g_io_module_gnutls_load_static (); -+#ifdef HAVE_PKCS11 -+ g_io_module_gnutls_pkcs11_load_static (); -+#endif -+} -+#else - void - g_io_module_load (GIOModule *module) - { -@@ -48,3 +57,4 @@ g_io_module_query (void) - }; - return g_strdupv (eps); - } -+#endif -diff --git a/tls/gnutls/gtlsbackend-gnutls.c b/tls/gnutls/gtlsbackend-gnutls.c -index 55ec1a5..277fff2 100644 ---- a/tls/gnutls/gtlsbackend-gnutls.c -+++ b/tls/gnutls/gtlsbackend-gnutls.c -@@ -39,10 +39,22 @@ struct _GTlsBackendGnutlsPrivate - - static void g_tls_backend_gnutls_interface_init (GTlsBackendInterface *iface); - -+#ifdef G_IO_MODULE_BUILD_STATIC -+G_DEFINE_TYPE_EXTENDED (GTlsBackendGnutls, g_tls_backend_gnutls, G_TYPE_OBJECT, 0, -+ G_IMPLEMENT_INTERFACE (G_TYPE_TLS_BACKEND, -+ g_tls_backend_gnutls_interface_init);) -+void _g_io_modules_ensure_extension_points_registered (void); -+#else - G_DEFINE_DYNAMIC_TYPE_EXTENDED (GTlsBackendGnutls, g_tls_backend_gnutls, G_TYPE_OBJECT, 0, - G_IMPLEMENT_INTERFACE_DYNAMIC (G_TYPE_TLS_BACKEND, - g_tls_backend_gnutls_interface_init);) - -+static void -+g_tls_backend_gnutls_class_finalize (GTlsBackendGnutlsClass *backend_class) -+{ -+} -+#endif -+ - #ifdef GTLS_GNUTLS_DEBUG - static void - gtls_log_func (int level, const char *msg) -@@ -61,8 +73,11 @@ gtls_gnutls_init (gpointer data) - gnutls_global_set_log_level (9); - #endif - -+#ifndef G_IO_MODULE_BUILD_STATIC - /* Leak the module to keep it from being unloaded. */ - g_type_plugin_use (g_type_get_plugin (G_TYPE_TLS_BACKEND_GNUTLS)); -+#endif -+ - return NULL; - } - -@@ -116,11 +131,6 @@ g_tls_backend_gnutls_class_init (GTlsBackendGnutlsClass *backend_class) - g_type_class_add_private (backend_class, sizeof (GTlsBackendGnutlsPrivate)); - } - --static void --g_tls_backend_gnutls_class_finalize (GTlsBackendGnutlsClass *backend_class) --{ --} -- - static GTlsDatabase* - g_tls_backend_gnutls_get_default_database (GTlsBackend *backend) - { -@@ -303,10 +313,17 @@ g_tls_backend_gnutls_lookup_session (unsigned int type, - return session_data; - } - -+#ifdef G_IO_MODULE_BUILD_STATIC -+void -+g_io_module_gnutls_load_static (void) -+{ -+ _g_io_modules_ensure_extension_points_registered (); -+#else - void - g_tls_backend_gnutls_register (GIOModule *module) - { - g_tls_backend_gnutls_register_type (G_TYPE_MODULE (module)); -+#endif - g_io_extension_point_implement (G_TLS_BACKEND_EXTENSION_POINT_NAME, - g_tls_backend_gnutls_get_type(), - "gnutls", -diff --git a/tls/gnutls/gtlsbackend-gnutls.h b/tls/gnutls/gtlsbackend-gnutls.h -index 22caa00..24e139b 100644 ---- a/tls/gnutls/gtlsbackend-gnutls.h -+++ b/tls/gnutls/gtlsbackend-gnutls.h -@@ -44,7 +44,12 @@ struct _GTlsBackendGnutls - }; - - GType g_tls_backend_gnutls_get_type (void) G_GNUC_CONST; --void g_tls_backend_gnutls_register (GIOModule *module); -+ -+#ifdef G_IO_MODULE_BUILD_STATIC -+void g_io_module_gnutls_load_static (void); -+#else -+void g_tls_backend_gnutls_register (GIOModule *module); -+#endif - - void g_tls_backend_gnutls_store_session (unsigned int type, - GBytes *session_id, --- -1.9.0 - diff --git a/recipes/glib-networking/0001-Fix-building-tls-plugin-without-pkcs11.patch b/recipes/glib-networking/0001-Fix-building-tls-plugin-without-pkcs11.patch new file mode 100644 index 00000000..e81be5d2 --- /dev/null +++ b/recipes/glib-networking/0001-Fix-building-tls-plugin-without-pkcs11.patch @@ -0,0 +1,57 @@ +From 4be630b1769a0827b093435ff3f45287d4e8b77a Mon Sep 17 00:00:00 2001 +From: Tom Schoonjans <Tom.Schoonjans@diamond.ac.uk> +Date: Tue, 13 Mar 2018 16:57:03 +0000 +Subject: [PATCH] Fix building tls plugin without pkcs11 + +https://bugzilla.gnome.org/show_bug.cgi?id=794292 +--- + meson.build | 3 +-- + tls/tests/meson.build | 7 ++++--- + 2 files changed, 5 insertions(+), 5 deletions(-) + +diff --git a/meson.build b/meson.build +index ee2bd9d..130d517 100644 +--- a/meson.build ++++ b/meson.build +@@ -85,6 +85,7 @@ pkg = import('pkgconfig') + po_dir = join_paths(meson.source_root(), 'po') + + top_inc = include_directories('.') ++tls_inc = include_directories('tls') + + subdir('po') + +@@ -106,8 +107,6 @@ if enable_libproxy_support or enable_gnome_proxy_support + endif + + if enable_pkcs11_support +- tls_inc = include_directories('tls') +- + subdir('tls/pkcs11') + endif + +diff --git a/tls/tests/meson.build b/tls/tests/meson.build +index 7e1ae13..d3611c1 100644 +--- a/tls/tests/meson.build ++++ b/tls/tests/meson.build +@@ -1,4 +1,7 @@ +-incs = [top_inc] ++incs = [ ++ top_inc, ++ tls_inc ++] + + deps = [ + gio_dep, +@@ -25,8 +28,6 @@ test_programs = [ + ] + + if enable_pkcs11_support +- incs += tls_inc +- + pkcs11_deps = deps + [ + libgiopkcs11_dep, + pkcs11_dep +-- +2.17.0 + diff --git a/recipes/glib-networking/0001-Use-the-GnuTLS-system-trust-by-default.patch b/recipes/glib-networking/0001-Use-the-GnuTLS-system-trust-by-default.patch new file mode 100644 index 00000000..9cc7ea43 --- /dev/null +++ b/recipes/glib-networking/0001-Use-the-GnuTLS-system-trust-by-default.patch @@ -0,0 +1,348 @@ +From f1c8feee014007cc913b71357acb609f8d1200df Mon Sep 17 00:00:00 2001 +From: Michael Catanzaro <mcatanzaro@igalia.com> +Date: Thu, 8 Feb 2018 22:02:06 -0600 +Subject: [PATCH] Use the GnuTLS system trust by default + +Get rid of the ca_certificates_path build flag. The default GTlsDatabase +will now use the GnuTLS system trust. GTlsFileDatabase now builds its +internal hash tables by iterating its gnutls_x509_trust_list_t, rather +than by parsing its certificate file manually. + +The find-ca-certificates script is removed, since it's no longer needed. + +There are some potential compatibility risks here: + + * The minimum required GnuTLS version is increased from 3.3.5 to 3.4. + + * If GnuTLS is not configured with a system trust, all certificate + verification using the default GTlsDatabase will fail. I noticed that + GNOME's flatpak runtime does not configure a system trust, so this + breaks HTTPS there. This is sad for Epiphany Technology Preview, but + we should do this anyway, and separately fix the GNOME runtime. + + * It was previously possible to configure glib-networking using + --without-ca-certificates to ensure the default GTlsDatabase is + empty (GNOME #727282). Apparently this was desirable on some embedded + systems, though I'm not sure why. Such configuration is still + possible by configuring GnuTLS with no system trust. Presumably, + anybody relying on this behavior will notice that the + --without-ca-certificates flag has disappeared during the build + system change and investigate, so this seems unproblematic. + + * The default GTlsDatabase is a GTlsFileDatabase, but it might not + actually correspond to a file anymore. This will be fixed in the next + commit. + + * If the anchors property of a GTlsFileDatabase is NULL, that + previously indicated an empty GTlsFileDatabase, but now indicates + that the system trust is used. This will also be fixed in the next + commit. + + * Certificate handles created using the default GTlsDatabase will be + different before and after this commit. This seems unlikely to cause + problems in practice, since a quick Debian codesearch reveals zero + applications using our certificate handles. But, if an application + were to rely on handles generated by previous versions of + glib-networking being valid in the new version, it would break. + +None of the above seem likely to cause practical issues, once +distributors ensure that GnuTLS is built properly, so I think we can +proceed. + +https://bugzilla.gnome.org/show_bug.cgi?id=753260 +--- + find-ca-certificates | 20 ----- + meson.build | 10 +-- + meson_options.txt | 1 - + tls/gnutls/gtlsbackend-gnutls.c | 6 +- + tls/gnutls/gtlsfiledatabase-gnutls.c | 117 +++++++++++++++------------ + 5 files changed, 66 insertions(+), 88 deletions(-) + delete mode 100755 find-ca-certificates + +diff --git a/find-ca-certificates b/find-ca-certificates +deleted file mode 100755 +index 4c5fd8f..0000000 +--- a/find-ca-certificates ++++ /dev/null +@@ -1,20 +0,0 @@ +-#!/usr/bin/env python3 +- +-import errno +-import os +-import sys +- +-locations = [ '/etc/pki/tls/certs/ca-bundle.crt', +- '/etc/ssl/certs/ca-certificates.crt', +- '/etc/ssl/ca-bundle.pem' +-] +- +-if len(sys.argv) > 1: +- locations.insert(0, sys.argv[1]) +- +-for location in locations: +- if os.path.isfile(location): +- sys.stdout.write(location) +- sys.exit(0) +- +-sys.exit(errno.ENOENT) +diff --git a/meson.build b/meson.build +index cf6782c..ee2bd9d 100644 +--- a/meson.build ++++ b/meson.build +@@ -62,14 +62,7 @@ if enable_gnome_proxy_support + endif + + # *** Checks for GnuTLS *** +-gnutls_dep = dependency('gnutls', version: '>= 3.3.5', required: true) +- +-msg = 'location of system Certificate Authority list: ' +-res = run_command(join_paths(meson.source_root(), 'find-ca-certificates'), get_option('ca_certificates_path')) +-assert(res.returncode() == 0, msg + ' could not find any CA certificate store. Use -Dca_certificates_path=PATH to set') +-ca_certificates_path = res.stdout().strip() +-message(msg + ca_certificates_path) +-config_h.set_quoted('GTLS_SYSTEM_CA_FILE', ca_certificates_path, description: 'The system CA list') ++gnutls_dep = dependency('gnutls', version: '>= 3.4', required: true) + + # *** Checks for p11-kit *** + enable_pkcs11_support = get_option('pkcs11_support') +@@ -126,5 +119,4 @@ meson.add_install_script('meson_post_install.py', gio_module_dir) + output = '\n\n libproxy support: ' + enable_libproxy_support.to_string() + '\n' + output += ' GNOME proxy support: ' + enable_gnome_proxy_support.to_string() + '\n' + output += ' PKCS#11 support: ' + enable_pkcs11_support.to_string() + '\n' +-output += ' TLS CA file: ' + ca_certificates_path + '\n' + message(output) +diff --git a/meson_options.txt b/meson_options.txt +index 8cf58ed..1e04d19 100644 +--- a/meson_options.txt ++++ b/meson_options.txt +@@ -1,6 +1,5 @@ + option('libproxy_support', type: 'boolean', value: true, description: 'support for libproxy proxy configration') + option('gnome_proxy_support', type: 'boolean', value: true, description: 'support for GNOME desktop proxy configuration') +-option('ca_certificates_path', type: 'string', value: '', description: 'path to system Certificate Authority list') + option('pkcs11_support', type: 'boolean', value: true, description: 'support for PKCS#11 using p11-kit') + option('installed_tests', type: 'boolean', value: false, description: 'enable installed tests') + option('static_modules', type: 'boolean', value: false, description: 'build static modules') +diff --git a/tls/gnutls/gtlsbackend-gnutls.c b/tls/gnutls/gtlsbackend-gnutls.c +index 0a6b5d4..97502d3 100644 +--- a/tls/gnutls/gtlsbackend-gnutls.c ++++ b/tls/gnutls/gtlsbackend-gnutls.c +@@ -114,11 +114,7 @@ static GTlsDatabase* + g_tls_backend_gnutls_real_create_database (GTlsBackendGnutls *self, + GError **error) + { +- const gchar *anchor_file = NULL; +-#ifdef GTLS_SYSTEM_CA_FILE +- anchor_file = GTLS_SYSTEM_CA_FILE; +-#endif +- return g_tls_file_database_new (anchor_file, error); ++ return g_tls_file_database_new (NULL, error); + } + + static void +diff --git a/tls/gnutls/gtlsfiledatabase-gnutls.c b/tls/gnutls/gtlsfiledatabase-gnutls.c +index 5a5c965..3fb7b4a 100644 +--- a/tls/gnutls/gtlsfiledatabase-gnutls.c ++++ b/tls/gnutls/gtlsfiledatabase-gnutls.c +@@ -149,13 +149,24 @@ create_handle_for_certificate (const gchar *filename, + gchar *uri; + + /* +- * Here we create a URI that looks like: ++ * Here we create a URI that looks like + * file:///etc/ssl/certs/ca-certificates.crt#11b2641821252596420e468c275771f5e51022c121a17bd7a89a2f37b6336c8f ++ * or system-trust:#11b2641821252596420e468c275771f5e51022c121a17bd7a89a2f37b6336c8f. ++ * ++ * system-trust is a meaningless URI scheme; we just need some stable way to ++ * uniquely identify these certificates. + */ + +- uri_part = g_filename_to_uri (filename, NULL, NULL); +- if (!uri_part) +- return NULL; ++ if (filename) ++ { ++ uri_part = g_filename_to_uri (filename, NULL, NULL); ++ if (!uri_part) ++ return NULL; ++ } ++ else ++ { ++ uri_part = g_strdup ("system-trust:"); ++ } + + bookmark = g_compute_checksum_for_bytes (G_CHECKSUM_SHA256, der); + uri = g_strconcat (uri_part, "#", bookmark, NULL); +@@ -189,40 +200,29 @@ create_handles_array_unlocked (const gchar *filename, + return handles; + } + +-static gboolean +-load_anchor_file (const gchar *filename, +- GHashTable *subjects, +- GHashTable *issuers, +- GHashTable *complete, +- GError **error) ++static void ++initialize_tables (gnutls_x509_trust_list_t trust_list, ++ GHashTable *subjects, ++ GHashTable *issuers, ++ GHashTable *complete) + { +- GList *list, *l; +- gnutls_x509_crt_t cert; ++ gnutls_x509_trust_list_iter_t iter = NULL; ++ gnutls_x509_crt_t cert = NULL; + gnutls_datum_t dn; +- GBytes *der; +- GBytes *subject; +- GBytes *issuer; ++ GBytes *der = NULL; ++ GBytes *subject = NULL; ++ GBytes *issuer = NULL; + gint gerr; +- GError *my_error = NULL; +- +- list = g_tls_certificate_list_new_from_file (filename, &my_error); +- if (my_error) +- { +- g_propagate_error (error, my_error); +- return FALSE; +- } + +- for (l = list; l; l = l->next) ++ while ((gerr = gnutls_x509_trust_list_iter_get_ca (trust_list, &iter, &cert)) == 0) + { +- cert = g_tls_certificate_gnutls_get_cert (l->data); + gerr = gnutls_x509_crt_get_raw_dn (cert, &dn); + if (gerr < 0) + { + g_warning ("failed to get subject of anchor certificate: %s", + gnutls_strerror (gerr)); +- continue; ++ goto next; + } +- + subject = g_bytes_new_with_free_func (dn.data, dn.size, gnutls_free, dn.data); + + gerr = gnutls_x509_crt_get_raw_issuer_dn (cert, &dn); +@@ -230,13 +230,18 @@ load_anchor_file (const gchar *filename, + { + g_warning ("failed to get issuer of anchor certificate: %s", + gnutls_strerror (gerr)); +- continue; ++ goto next; + } +- + issuer = g_bytes_new_with_free_func (dn.data, dn.size, gnutls_free, dn.data); + +- der = g_tls_certificate_gnutls_get_bytes (l->data); +- g_return_val_if_fail (der != NULL, FALSE); ++ gerr = gnutls_x509_crt_export2 (cert, GNUTLS_X509_FMT_DER, &dn); ++ if (gerr < 0) ++ { ++ g_warning ("failed to get certificate DER: %s", ++ gnutls_strerror (gerr)); ++ goto next; ++ } ++ der = g_bytes_new_with_free_func (dn.data, dn.size, gnutls_free, dn.data); + + /* Three different ways of looking up same certificate */ + bytes_multi_table_insert (subjects, subject, der); +@@ -245,15 +250,12 @@ load_anchor_file (const gchar *filename, + g_hash_table_insert (complete, g_bytes_ref (der), + g_bytes_ref (der)); + +- g_bytes_unref (der); +- g_bytes_unref (subject); +- g_bytes_unref (issuer); +- +- g_object_unref (l->data); ++next: ++ g_clear_pointer (&der, g_bytes_unref); ++ g_clear_pointer (&subject, g_bytes_unref); ++ g_clear_pointer (&issuer, g_bytes_unref); ++ g_clear_pointer (&cert, gnutls_x509_crt_deinit); + } +- g_list_free (list); +- +- return TRUE; + } + + +@@ -267,11 +269,10 @@ g_tls_file_database_gnutls_finalize (GObject *object) + g_clear_pointer (&self->issuers, g_hash_table_destroy); + g_clear_pointer (&self->complete, g_hash_table_destroy); + g_clear_pointer (&self->handles, g_hash_table_destroy); +- if (self->anchor_filename) +- { +- g_free (self->anchor_filename); +- gnutls_x509_trust_list_deinit (self->trust_list, 1); +- } ++ g_clear_pointer (&self->anchor_filename, g_free); ++ ++ gnutls_x509_trust_list_deinit (self->trust_list, 1); ++ + g_mutex_clear (&self->mutex); + + G_OBJECT_CLASS (g_tls_file_database_gnutls_parent_class)->finalize (object); +@@ -303,6 +304,7 @@ g_tls_file_database_gnutls_set_property (GObject *object, + { + GTlsFileDatabaseGnutls *self = G_TLS_FILE_DATABASE_GNUTLS (object); + const char *anchor_path; ++ int gerr; + + switch (prop_id) + { +@@ -320,11 +322,24 @@ g_tls_file_database_gnutls_set_property (GObject *object, + g_free (self->anchor_filename); + gnutls_x509_trust_list_deinit (self->trust_list, 1); + } ++ + self->anchor_filename = g_strdup (anchor_path); + gnutls_x509_trust_list_init (&self->trust_list, 0); +- gnutls_x509_trust_list_add_trust_file (self->trust_list, +- anchor_path, NULL, +- GNUTLS_X509_FMT_PEM, 0, 0); ++ ++ if (self->anchor_filename) ++ { ++ gnutls_x509_trust_list_add_trust_file (self->trust_list, ++ anchor_path, NULL, ++ GNUTLS_X509_FMT_PEM, 0, 0); ++ } ++ else ++ { ++ gerr = gnutls_x509_trust_list_add_system_trust (self->trust_list, 0, 0); ++ if (gerr == GNUTLS_E_UNIMPLEMENTED_FEATURE) ++ g_warning ("Failed to load system trust store: gnutls_x509_trust_list_add_system_trust is not implemented for this platform"); ++ else if (gerr < 0) ++ g_warning ("Failed to load system trust store: %s", gnutls_strerror (gerr)); ++ } + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); +@@ -641,7 +656,7 @@ g_tls_file_database_gnutls_initable_init (GInitable *initable, + { + GTlsFileDatabaseGnutls *self = G_TLS_FILE_DATABASE_GNUTLS (initable); + GHashTable *subjects, *issuers, *complete; +- gboolean result; ++ gboolean result = TRUE; + + if (g_cancellable_set_error_if_cancelled (cancellable, error)) + return FALSE; +@@ -653,11 +668,7 @@ g_tls_file_database_gnutls_initable_init (GInitable *initable, + (GDestroyNotify)g_bytes_unref, + (GDestroyNotify)g_bytes_unref); + +- if (self->anchor_filename) +- result = load_anchor_file (self->anchor_filename, subjects, issuers, +- complete, error); +- else +- result = TRUE; ++ initialize_tables (self->trust_list, subjects, issuers, complete); + + if (g_cancellable_set_error_if_cancelled (cancellable, error)) + result = FALSE; +-- +2.17.0 + diff --git a/recipes/glib-networking/0002-Get-the-CA-certificate-path-from-the-environment-var.patch b/recipes/glib-networking/0002-Get-the-CA-certificate-path-from-the-environment-var.patch deleted file mode 100644 index 455daac1..00000000 --- a/recipes/glib-networking/0002-Get-the-CA-certificate-path-from-the-environment-var.patch +++ /dev/null @@ -1,27 +0,0 @@ -From e03efc825a091b704a57d497afaa2492bb707066 Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= <sebastian@centricular.com> -Date: Wed, 12 Mar 2014 14:27:36 +0100 -Subject: [PATCH 2/2] Get the CA certificate path from the environment - variables on Android and iOS - ---- - tls/gnutls/gtlsbackend-gnutls.c | 3 +++ - 1 file changed, 3 insertions(+) - -diff --git a/tls/gnutls/gtlsbackend-gnutls.c b/tls/gnutls/gtlsbackend-gnutls.c -index 277fff2..7b11f8c 100644 ---- a/tls/gnutls/gtlsbackend-gnutls.c -+++ b/tls/gnutls/gtlsbackend-gnutls.c -@@ -119,6 +119,9 @@ g_tls_backend_gnutls_real_create_database (GTlsBackendGnutls *self, - #ifdef GTLS_SYSTEM_CA_FILE - anchor_file = GTLS_SYSTEM_CA_FILE; - #endif -+#ifdef GST_CA_CERTIFICATES_FROM_ENV -+ anchor_file = g_getenv ("CA_CERTIFICATES"); -+#endif - return g_tls_file_database_new (anchor_file, error); - } - --- -1.9.0 - diff --git a/recipes/glib-networking/0003-gnutls-Use-db-relative-to-libglib-2.0-if-needed.patch b/recipes/glib-networking/0003-gnutls-Use-db-relative-to-libglib-2.0-if-needed.patch deleted file mode 100644 index df9f08af..00000000 --- a/recipes/glib-networking/0003-gnutls-Use-db-relative-to-libglib-2.0-if-needed.patch +++ /dev/null @@ -1,90 +0,0 @@ -From b2fe6ee5aca711efe156091fe3d4903a29d75509 Mon Sep 17 00:00:00 2001 -From: Olivier Crete <olivier.crete@collabora.com> -Date: Tue, 4 Oct 2016 15:44:51 -0400 -Subject: [PATCH 3/3] gnutls: Use db relative to libglib-2.0 if needed - ---- - configure.ac | 3 +++ - tls/gnutls/gtlsbackend-gnutls.c | 39 ++++++++++++++++++++++++++++++++++++++- - 2 files changed, 41 insertions(+), 1 deletion(-) - -diff --git a/configure.ac b/configure.ac -index a1bb166..59209a5 100644 ---- a/configure.ac -+++ b/configure.ac -@@ -127,6 +127,9 @@ if test "$with_gnutls" = "yes"; then - AC_MSG_RESULT($with_ca_certificates) - AC_DEFINE_UNQUOTED(GTLS_SYSTEM_CA_FILE, ["$with_ca_certificates"], [The system TLS CA list]) - fi -+ -+ AC_CHECK_FUNCS(dladdr) -+ AC_CHECK_HEADERS([dlfcn.h]) - fi - - dnl ***************************** -diff --git a/tls/gnutls/gtlsbackend-gnutls.c b/tls/gnutls/gtlsbackend-gnutls.c -index 8f2437a..1cf9127 100644 ---- a/tls/gnutls/gtlsbackend-gnutls.c -+++ b/tls/gnutls/gtlsbackend-gnutls.c -@@ -34,6 +34,10 @@ - #include "gtlsfiledatabase-gnutls.h" - #include "gtlsserverconnection-gnutls.h" - -+#if defined(HAVE_DLFCN_H) && defined (HAVE_DLADDR) -+#include <dlfcn.h> -+#endif -+ - struct _GTlsBackendGnutlsPrivate - { - GMutex mutex; -@@ -119,13 +123,46 @@ g_tls_backend_gnutls_real_create_database (GTlsBackendGnutls *self, - GError **error) - { - const gchar *anchor_file = NULL; -+ GTlsDatabase *db = NULL; -+#ifdef HAVE_DLADDR -+ gchar *free_me = NULL; -+#endif -+ - #ifdef GTLS_SYSTEM_CA_FILE - anchor_file = GTLS_SYSTEM_CA_FILE; - #endif -+ -+#ifdef HAVE_DLADDR -+ if (!anchor_file || !g_file_test (anchor_file, G_FILE_TEST_IS_REGULAR)) -+ { -+ Dl_info info; -+ if (dladdr (g_tls_file_database_new, &info)) -+ { -+ GFile *file = g_file_new_for_path (info.dli_fname); -+ GFile *parent = g_file_get_parent (file); -+ -+ if (parent) -+ { -+ GFile *rel = g_file_resolve_relative_path (parent, -+ "../etc/ssl/certs/ca-certificates.crt"); -+ if (rel) -+ anchor_file = free_me = g_file_get_path (rel); -+ g_object_unref (parent); -+ } -+ g_object_unref (file); -+ } -+ } -+#endif -+ - #ifdef GST_CA_CERTIFICATES_FROM_ENV - anchor_file = g_getenv ("CA_CERTIFICATES"); - #endif -- return g_tls_file_database_new (anchor_file, error); -+ db = g_tls_file_database_new (anchor_file, error); -+ -+#ifdef HAVE_DLADDR -+ g_free (free_me); -+#endif -+ return db; - } - - static void --- -2.8.4 (Apple Git-73) - diff --git a/recipes/glib-networking/0004-gtlsbackend-gnutls-Get-anchor-file-relative-to-libgi.patch b/recipes/glib-networking/0004-gtlsbackend-gnutls-Get-anchor-file-relative-to-libgi.patch deleted file mode 100644 index 5eb5d786..00000000 --- a/recipes/glib-networking/0004-gtlsbackend-gnutls-Get-anchor-file-relative-to-libgi.patch +++ /dev/null @@ -1,67 +0,0 @@ -From 6f3db1bb19c5f06dda25f13aa1e1a381233f3fd2 Mon Sep 17 00:00:00 2001 -From: Sebastian Droege <sebastian@centricular.com> -Date: Tue, 1 Nov 2016 19:48:12 +0000 -Subject: [PATCH 4/4] gtlsbackend-gnutls: Get anchor file relative to libgio on - Windows - ---- - tls/gnutls/gtlsbackend-gnutls.c | 24 ++++++++++++++++++++++-- - 1 file changed, 22 insertions(+), 2 deletions(-) - -diff --git a/tls/gnutls/gtlsbackend-gnutls.c b/tls/gnutls/gtlsbackend-gnutls.c -index 1cf9127..8b281e5 100644 ---- a/tls/gnutls/gtlsbackend-gnutls.c -+++ b/tls/gnutls/gtlsbackend-gnutls.c -@@ -38,6 +38,10 @@ - #include <dlfcn.h> - #endif - -+#ifdef G_OS_WIN32 -+#include <windows.h> -+#endif -+ - struct _GTlsBackendGnutlsPrivate - { - GMutex mutex; -@@ -124,7 +128,7 @@ g_tls_backend_gnutls_real_create_database (GTlsBackendGnutls *self, - { - const gchar *anchor_file = NULL; - GTlsDatabase *db = NULL; --#ifdef HAVE_DLADDR -+#if defined(HAVE_DLADDR) || defined(G_OS_WIN32) - gchar *free_me = NULL; - #endif - -@@ -154,12 +158,28 @@ g_tls_backend_gnutls_real_create_database (GTlsBackendGnutls *self, - } - #endif - -+#ifdef G_OS_WIN32 -+ if (!anchor_file || !g_file_test (anchor_file, G_FILE_TEST_IS_REGULAR)) -+ { -+ HMODULE module; -+ gchar *module_path; -+ module = GetModuleHandle ("libgio-2.0-0.dll"); -+ if (module) -+ { -+ module_path = g_win32_get_package_installation_directory_of_module (module); -+ if (module_path) -+ anchor_file = free_me = g_build_filename (module_path, "etc", "ssl", "certs", "ca-certificates.crt", NULL); -+ g_free (module_path); -+ } -+ } -+#endif -+ - #ifdef GST_CA_CERTIFICATES_FROM_ENV - anchor_file = g_getenv ("CA_CERTIFICATES"); - #endif - db = g_tls_file_database_new (anchor_file, error); - --#ifdef HAVE_DLADDR -+#if defined(HAVE_DLADDR) || defined(G_OS_WIN32) - g_free (free_me); - #endif - return db; --- -2.10.2 - diff --git a/recipes/glib-networking/0006-meson-Only-run-gio-querymodules-if-it-s-found.patch b/recipes/glib-networking/0006-meson-Only-run-gio-querymodules-if-it-s-found.patch new file mode 100644 index 00000000..d6bc736d --- /dev/null +++ b/recipes/glib-networking/0006-meson-Only-run-gio-querymodules-if-it-s-found.patch @@ -0,0 +1,41 @@ +From dc607d8e1c44a9a6eb796c1946f7e5e4a7c74cdd Mon Sep 17 00:00:00 2001 +From: Nirbheek Chauhan <nirbheek@centricular.com> +Date: Wed, 9 May 2018 20:03:00 +0530 +Subject: [PATCH 6/6] meson: Only run gio-querymodules if it's found + +And run the correct one if it's found +--- + meson.build | 6 +++++- + meson_post_install.py | 2 +- + 2 files changed, 6 insertions(+), 2 deletions(-) + +diff --git a/meson.build b/meson.build +index f8e0e41..7dd53b9 100644 +--- a/meson.build ++++ b/meson.build +@@ -126,7 +126,11 @@ endif + subdir('tls/gnutls') + subdir('tls/tests') + +-meson.add_install_script('meson_post_install.py', gio_module_dir) ++# Will automatically pick it up from the cross file if defined ++gio_querymodules = find_program('gio-querymodules', required : false) ++if gio_querymodules.found() ++ meson.add_install_script('meson_post_install.py', gio_querymodules.path(), gio_module_dir) ++endif + + output = '\n\n libproxy support: ' + enable_libproxy_support.to_string() + '\n' + output += ' GNOME proxy support: ' + enable_gnome_proxy_support.to_string() + '\n' +diff --git a/meson_post_install.py b/meson_post_install.py +index 3082d42..8960540 100644 +--- a/meson_post_install.py ++++ b/meson_post_install.py +@@ -6,4 +6,4 @@ import sys + + if not os.environ.get('DESTDIR'): + print('GIO module cache creation...') +- subprocess.call(['gio-querymodules', sys.argv[1]]) ++ subprocess.call([sys.argv[1], sys.argv[2]]) +-- +2.17.0 + diff --git a/recipes/glib.recipe b/recipes/glib.recipe index 6707f0e1..c84c8094 100644 --- a/recipes/glib.recipe +++ b/recipes/glib.recipe @@ -1,6 +1,6 @@ # -*- Mode: Python -*- vi:si:et:sw=4:sts=4:ts=4:syntax=python import shutil -from cerbero.utils import needs_xcode8_sdk_workaround +from cerbero.errors import FatalError GLIB_CONFIG_UNVERSAL='''\ #ifdef __i386__ @@ -20,26 +20,25 @@ GLIB_CONFIG_UNVERSAL='''\ class Recipe(recipe.Recipe): name = 'glib' - version = '2.54.3' + version = '2.56.1' stype = SourceType.TARBALL - url = 'http://ftp.acc.umu.se/pub/GNOME/sources/glib/2.54/glib-%(version)s.tar.xz' + url = 'http://ftp.acc.umu.se/pub/GNOME/sources/glib/2.56/glib-%(version)s.tar.xz' licenses = [License.LGPLv2Plus] - config_sh = 'sh autogen.sh' - configure_options = '--with-pcre=internal --disable-libmount --enable-dtrace=no ' + btype = BuildType.MESON + meson_options = {'gtk_doc': 'false', 'internal_pcre': 'true', 'libmount': 'false', + 'dtrace': 'false'} deps = ['libffi', 'zlib'] - can_use_configure_cache = False - patches = ["glib/0001-Let-user-disable-Cocoa-and-Carbon-support-on-demand.patch", - "glib/0002-Optionally-revert-to-the-old-pre-2.28-URI-handler-co.patch", - "glib/0003-Add-support-for-loading-GIO-modules-from-the-distro-.patch", + + patches = ["glib/0003-Add-support-for-loading-GIO-modules-from-the-distro-.patch", "glib/0004-Allow-for-a-second-distro-GIO-module-path-as-used-on.patch", "glib/0005-Blacklist-the-bamf-GIO-module.patch", "glib/0006-giomodule-do-not-try-to-load-modules-from-gio-module.patch", "glib/0008-Unhide-_g_io_modules_ensure_extension_points_registe.patch", 'glib/0009-Implementation-of-Cocoa-event-loop-integration-in-GM.patch', - 'glib/0010-GSocket-Fix-race-conditions-on-Win32-if-multiple-thr.patch', 'glib/0013-gmain-Fix-erroneous-if-condition-when-dtrace-is-disa.patch', - 'glib/0001-gmodule-Use-RTLD_DEFAULT-if-defined-__BIONIC__.patch', - 'glib/0001-configure.ac-add-enable-proxy-libintl.patch' + 'glib/glib-2.57-meson-backported-fixes.patch', + 'glib/0001-meson-Add-exception-for-atomic-ops-test-for-Android.patch', + 'glib/0001-DO-NOT-UPSTREAM-Prototypes-missing-in-Cerbero-s-anci.patch', ] files_libs = [ @@ -98,33 +97,44 @@ class Recipe(recipe.Recipe): return flags def prepare(self): - if needs_xcode8_sdk_workaround(self.config): - self.append_env['ac_cv_func_mkostemp'] = 'no' if self.config.target_platform != Platform.WINDOWS: - self.configure_options += ' --enable-static' + #self.meson_options.update({'default_library': 'both'}) + pass if self.config.target_platform != Platform.LINUX: - self.configure_options += ' --disable-gtk-doc ' # Disable valgrind code on non-Linux, in the best case it just # gives us compiler errors :) self.append_env['CFLAGS'] = ' -DNVALGRIND=1 ' + self.meson_options.update({'xattr': 'false'}) + self.deps.append('proxy-libintl') + + # macOS provides libiconv as a separate library + if self.config.target_platform == Platform.DARWIN: + self.meson_options.update({'iconv': 'native'}) + # linux and BSD provide iconv as a part of libc + elif self.config.target_platform == Platform.LINUX: + self.meson_options.update({'iconv': 'libc'}) + # On Windows, glib uses an internal copy of libiconv + elif self.config.target_platform == Platform.WINDOWS: + self.meson_options.update({'iconv': 'native'}) + # Other platforms don't provide libiconv, so we build it + else: + self.deps.append('libiconv') + self.meson_options.update({'iconv': 'gnu'}) + if self.config.target_platform == Platform.ANDROID: - self.deps += ['proxy-libintl'] - self.configure_options += ' --enable-proxy-libintl' - # Hack to fix building of the glib/tests/private test - self.make = '%s private_LDFLAGS=""' % self.make v = DistroVersion.get_android_api_version(self.config.target_distro_version) if self.config.target_arch in [Architecture.ARM, Architecture.ARMv7, Architecture.X86] and v < 21: # FIXME: HACK to make projects using mmap compile with NDK 16 # we fail to compile with -D_FILE_OFFSET_BITS=64 # because we don't use clang and we use a platform < 21 (Lollipop) # See $NDK_ROOT/sysroot/usr/include/sys/mman.h as one example - self.new_env['ac_cv_func_mmap'] = 'no' + self.meson_cross_properties['c_args'] = ['-U_FILE_OFFSET_BITS'] elif self.config.target_platform == Platform.WINDOWS: - self.configure_options += ' --with-libiconv=gnu' - self.append_env['CFLAGS'] = ' -DMINGW_HAS_SECURE_API=1 ' + # Want secure versions of stdlib functions. Glib already defines + # _WIN32_WINNT, so undefine it on the cmdline to avoid warnings + self.append_env['CFLAGS'] = ' -DMINGW_HAS_SECURE_API=1 -U_WIN32_WINNT ' elif self.config.target_platform in [Platform.DARWIN, Platform.IOS]: self.files_devel.append(os.path.join('lib', 'glib-2.0', 'include', '*', 'glibconfig.h')) - arch = self.config.target_arch if arch == Architecture.X86: arch = 'i386' @@ -134,20 +144,17 @@ class Recipe(recipe.Recipe): arch = 'arm' extra_flags = '' if self.config.target_platform == Platform.IOS: - self.deps += ['proxy-libintl'] - self.configure_options += ' --enable-proxy-libintl' - # Disable mac OS X specifics extra_flags = '-DGST_SDK_IOS=1' - self.configure_options += ' --disable-carbon --disable-modular-tests --disable-cocoa' - - self.append_env['CFLAGS']="-DHAVE_STRNDUP %s" % extra_flags + # XXX: Why did we disable these for iOS? + #self.configure_options += ' --disable-carbon --disable-modular-tests --disable-cocoa' + self.append_env['CFLAGS'] = extra_flags elif self.config.target_platform == Platform.LINUX: path1 = '/usr/lib/gio/modules' path2 = None use_old_uri_scheme = False - self.configure_options += ' --disable-selinux' + self.meson_options.update({'selinux': 'false'}) # Old Debian/Ubuntu if self.config.target_distro_version in [DistroVersion.DEBIAN_SQUEEZE, DistroVersion.UBUNTU_LUCID, @@ -188,11 +195,7 @@ class Recipe(recipe.Recipe): self._set_gio_flags(path1, path2, use_old_uri_scheme) def post_install(self): - if self.config.target_platform == Platform.WINDOWS: - shutil.copy(os.path.join(self.build_dir, 'glib', 'glibconfig.h.win32'), - os.path.join(self.config.prefix, 'lib', 'glib-2.0', - 'include', 'glibconfig.h')) - if self.config.target_platform in [Platform.DARWIN, Platform.IOS]: + if self.config.target_platform in [Platform.IOS, Platform.DARWIN]: # For the universal build we need to ship glibconfig.h of both # architectures in a subfolder and include the correct one depending # on the compiler architecture @@ -208,7 +211,7 @@ class Recipe(recipe.Recipe): 'include', arch) if not os.path.exists(arch_dir): os.makedirs(arch_dir) - shutil.copyfile(os.path.join(self.build_dir, 'glib', 'glibconfig.h'), + shutil.copyfile(os.path.join(self.meson_dir, 'glib', 'glibconfig.h'), os.path.join(arch_dir, 'glibconfig.h')) with open(os.path.join(self.config.prefix, 'lib', 'glib-2.0', 'include', 'glibconfig.h'), 'w+') as f: diff --git a/recipes/glib/0001-DO-NOT-UPSTREAM-Prototypes-missing-in-Cerbero-s-anci.patch b/recipes/glib/0001-DO-NOT-UPSTREAM-Prototypes-missing-in-Cerbero-s-anci.patch new file mode 100644 index 00000000..00dc4f1d --- /dev/null +++ b/recipes/glib/0001-DO-NOT-UPSTREAM-Prototypes-missing-in-Cerbero-s-anci.patch @@ -0,0 +1,81 @@ +From c4e79cb2456d7018c05a9480bcb42994060e8cda Mon Sep 17 00:00:00 2001 +From: Nirbheek Chauhan <nirbheek@centricular.com> +Date: Sun, 6 May 2018 16:06:13 +0530 +Subject: [PATCH] DO NOT UPSTREAM: Prototypes missing in Cerbero's ancient + MinGW + +--- + gio/ginetaddress.c | 3 ++- + glib/grand.c | 4 ++++ + gmodule/gmodule-win32.c | 13 +++++++++++++ + 3 files changed, 19 insertions(+), 1 deletion(-) + +diff --git a/gio/ginetaddress.c b/gio/ginetaddress.c +index 0a0a85a48..4fc8119ff 100644 +--- a/gio/ginetaddress.c ++++ b/gio/ginetaddress.c +@@ -381,7 +381,8 @@ g_inet_address_init (GInetAddress *address) + * on Windows XP/Server 2003. We can drop this portion when we drop support for + * XP/Server 2003. + */ +-#if defined(G_OS_WIN32) && _WIN32_WINNT < 0x0600 ++/* XXX: Cerbero's MinGW is too ancient to have InetPton/InetNtop */ ++#if defined(G_OS_WIN32) && (_WIN32_WINNT < 0x0600 || defined(__MINGW32__)) + static gint + inet_pton (gint family, + const gchar *addr_string, +diff --git a/glib/grand.c b/glib/grand.c +index 610fc69c6..5a72af12a 100644 +--- a/glib/grand.c ++++ b/glib/grand.c +@@ -57,6 +57,10 @@ + #ifdef G_OS_WIN32 + #include <stdlib.h> + #include <process.h> /* For getpid() */ ++/* XXX: Cerbero MinGW is too ancient to have this */ ++#ifdef __MINGW32__ ++errno_t __cdecl rand_s(unsigned int *randomValue); ++#endif + #endif + + /** +diff --git a/gmodule/gmodule-win32.c b/gmodule/gmodule-win32.c +index 20459f372..c9d854434 100644 +--- a/gmodule/gmodule-win32.c ++++ b/gmodule/gmodule-win32.c +@@ -39,6 +39,10 @@ + #include <sys/cygwin.h> + #endif + ++#ifdef __MINGW32__ ++WINBASEAPI WINBOOL WINAPI SetThreadErrorMode (DWORD dwNewMode, LPDWORD lpOldMode); ++#endif ++ + static void + set_error (const gchar *format, + ...) +@@ -81,12 +85,21 @@ _g_module_open (const gchar *file_name, + wfilename = g_utf8_to_utf16 (file_name, -1, NULL, NULL, NULL); + + /* suppress error dialog */ ++#ifdef __MINGW32__ ++ /* XXX: Cerbero MinGW is too ancient to have SetThreadErrorMode */ ++ SetErrorMode (SEM_NOOPENFILEERRORBOX | SEM_FAILCRITICALERRORS); ++#else + success = SetThreadErrorMode (SEM_NOOPENFILEERRORBOX | SEM_FAILCRITICALERRORS, &old_mode); + if (!success) + set_error (""); ++#endif + handle = LoadLibraryW (wfilename); ++#ifdef __MINGW32__ ++ SetErrorMode (0); ++#else + if (success) + SetThreadErrorMode (old_mode, NULL); ++#endif + g_free (wfilename); + + if (!handle) +-- +2.17.0 + diff --git a/recipes/glib/0001-Let-user-disable-Cocoa-and-Carbon-support-on-demand.patch b/recipes/glib/0001-Let-user-disable-Cocoa-and-Carbon-support-on-demand.patch deleted file mode 100644 index 7d076097..00000000 --- a/recipes/glib/0001-Let-user-disable-Cocoa-and-Carbon-support-on-demand.patch +++ /dev/null @@ -1,120 +0,0 @@ -From 58179cc8fbdbae4116b02cc1c419a969c92bce76 Mon Sep 17 00:00:00 2001 -From: Nirbheek Chauhan <nirbheek@centricular.com> -Date: Thu, 13 Nov 2014 17:22:59 +0530 -Subject: [PATCH 01/13] Let user disable Cocoa and Carbon support on demand - -Also always AC_SUBST COCOA_LIBS and CARBON_LIBS since these are used in the -pkg-config file, etc. ---- - configure.ac | 71 ++++++++++++++++++++++++++++++++++++++---------------------- - 1 file changed, 45 insertions(+), 26 deletions(-) - -diff --git a/configure.ac b/configure.ac -index 58cd3f2..e9419f6 100644 ---- a/configure.ac -+++ b/configure.ac -@@ -174,32 +174,10 @@ AC_MSG_RESULT([$glib_native_android]) - - AC_SUBST(LIB_EXE_MACHINE_FLAG) - --glib_have_carbon=no --AC_MSG_CHECKING([for Mac OS X Carbon support]) --AC_TRY_CPP([ --#include <Carbon/Carbon.h> --#include <CoreServices/CoreServices.h> --], glib_have_carbon=yes) -- --AC_MSG_RESULT([$glib_have_carbon]) -- --glib_have_cocoa=no --AC_MSG_CHECKING([for Mac OS X Cocoa support]) --AC_TRY_CPP([ --#include <Cocoa/Cocoa.h> --#ifdef GNUSTEP_BASE_VERSION --#error "Detected GNUstep, not Cocoa" --#endif --], glib_have_cocoa=yes) -- --AC_MSG_RESULT([$glib_have_cocoa]) -- - AM_CONDITIONAL(OS_WIN32, [test "$glib_native_win32" = "yes"]) - AM_CONDITIONAL(OS_WIN32_X64, [test "$LIB_EXE_MACHINE_FLAG" = "X64"]) - AM_CONDITIONAL(OS_UNIX, [test "$glib_native_win32" != "yes"]) - AM_CONDITIONAL(OS_LINUX, [test "$glib_os_linux" = "yes"]) --AM_CONDITIONAL(OS_CARBON, [test "$glib_have_carbon" = "yes"]) --AM_CONDITIONAL(OS_COCOA, [test "$glib_have_cocoa" = "yes"]) - - AS_IF([test "$glib_native_win32" = "yes"], [ - AC_CHECK_TOOL(WINDRES, windres, no) -@@ -216,15 +194,56 @@ AS_IF([test "$glib_native_win32" = "yes"], [ - ]) - AM_CONDITIONAL(MS_LIB_AVAILABLE, [test x$ms_librarian = xyes]) - --AS_IF([test "x$glib_have_carbon" = "xyes"], [ -+AC_ARG_ENABLE(carbon, -+ [AC_HELP_STRING([--disable-carbon], -+ [disable Max OS X Carbon support])],, -+ [enable_carbon=yes]) -+ -+glib_have_carbon=no -+if test "x${enable_carbon}" = "xyes"; then -+ AC_MSG_RESULT([yes]) -+ AC_MSG_CHECKING([for Mac OS X Carbon support]) -+ AC_TRY_CPP([ -+#include <Carbon/Carbon.h> -+#include <CoreServices/CoreServices.h> -+ ], glib_have_carbon=yes) -+ AC_MSG_RESULT([$glib_have_carbon]) -+else -+ AC_MSG_RESULT([no]) -+fi -+AM_CONDITIONAL(OS_CARBON, [test "$glib_have_carbon" = "yes"]) -+ -+if test "x$glib_have_carbon" = "xyes"; then - AC_DEFINE(HAVE_CARBON, 1, [define to 1 if Carbon is available]) - CARBON_LIBS="-Wl,-framework,Carbon" - LDFLAGS="$LDFLAGS $CARBON_LIBS" --], [CARBON_LIBS=""]) -+fi - - AC_SUBST([CARBON_LIBS]) - ac_cv_have_os_x_9_or_later="no" --AS_IF([test "x$glib_have_cocoa" = "xyes"], [ -+dnl Check cocoa -+AC_ARG_ENABLE(cocoa, -+ [AC_HELP_STRING([--disable-cocoa], -+ [disable Max OS X Cocoa support])],, -+ [enable_cocoa=yes]) -+ -+glib_have_cocoa=no -+if test "x${enable_cocoa}" = "xyes"; then -+ AC_MSG_RESULT([yes]) -+ AC_MSG_CHECKING([for Mac OS X Carbon support]) -+ AC_TRY_CPP([ -+#include <Cocoa/Cocoa.h> -+#ifdef GNUSTEP_BASE_VERSION -+#error "Detected GNUstep, not Cocoa" -+#endif -+ ], glib_have_cocoa=yes) -+ AC_MSG_RESULT([$glib_have_cocoa]) -+else -+ AC_MSG_RESULT([no]) -+fi -+AM_CONDITIONAL(OS_COCOA, [test "$glib_have_cocoa" = "yes"]) -+ -+if test "x$glib_have_cocoa" = "xyes"; then - AC_DEFINE(HAVE_COCOA, 1, [define to 1 if Cocoa is available]) - COCOA_LIBS="-Wl,-framework,Foundation" - LDFLAGS="$LDFLAGS $COCOA_LIBS" -@@ -234,7 +253,7 @@ AS_IF([test "x$glib_have_cocoa" = "xyes"], [ - #error Compiling for minimum OS X version before 10.9 - #endif - ]])],[ac_cv_have_os_x_9_or_later="yes"]) --], [COCOA_LIBS=""]) -+fi - AM_CONDITIONAL([MAC_OS_X_9], [test "x$ac_cv_have_os_x_9_or_later" = xyes]) - AC_SUBST([COCOA_LIBS]) - --- -2.7.4 - diff --git a/recipes/glib/0001-configure.ac-add-enable-proxy-libintl.patch b/recipes/glib/0001-configure.ac-add-enable-proxy-libintl.patch deleted file mode 100644 index 04e7f97b..00000000 --- a/recipes/glib/0001-configure.ac-add-enable-proxy-libintl.patch +++ /dev/null @@ -1,61 +0,0 @@ -From 941a8a5432ef70fdf257eae33cf3f2254447fe76 Mon Sep 17 00:00:00 2001 -From: Justin Kim <justin.kim@collabora.com> -Date: Wed, 8 Nov 2017 15:14:40 +0900 -Subject: [PATCH] configure.ac: add --enable-proxy-libintl - ---- - Makefile.am | 4 ++++ - configure.ac | 14 ++++++++++++++ - 2 files changed, 18 insertions(+) - -diff --git a/Makefile.am b/Makefile.am -index b9accad..fdd4e34 100644 ---- a/Makefile.am -+++ b/Makefile.am -@@ -6,7 +6,11 @@ include $(top_srcdir)/glib.mk - - ACLOCAL_AMFLAGS = -I m4macros ${ACLOCAL_FLAGS} - -+if PROXY_LIBINTL -+SUBDIRS = . m4macros glib gmodule gthread gobject gio docs tests -+else - SUBDIRS = . m4macros glib gmodule gthread gobject gio po docs tests -+endif - DIST_SUBDIRS = $(SUBDIRS) build win32 - - bin_SCRIPTS = glib-gettextize -diff --git a/configure.ac b/configure.ac -index 2cf402c..d73c254 100644 ---- a/configure.ac -+++ b/configure.ac -@@ -478,6 +478,17 @@ dnl - dnl gettext support - dnl - -+AC_ARG_ENABLE(proxy-libintl, -+ [AS_HELP_STRING([--enable-proxy-libintl], -+ [build with proxy-libintl])],, -+ [enable_proxy_libintl=no]) -+ -+AS_IF([ test "x$enable_proxy_libintl" = "xyes"], [ -+ AC_DEFINE(HAVE_GETTEXT,1, "") -+ AC_DEFINE(ENABLE_NLS,1, "") -+ INTLLIBS="-lintl" -+],[ -+ - ALL_LINGUAS="`grep -v '^#' "$srcdir/po/LINGUAS" | tr '\n' ' '`" - AC_SUBST([CONFIG_STATUS_DEPENDENCIES],['$(top_srcdir)/po/LINGUAS']) - GLIB_GNU_GETTEXT -@@ -489,6 +500,9 @@ if test "$gt_cv_have_gettext" != "yes" ; then - ]) - fi - -+]) -+AM_CONDITIONAL(PROXY_LIBINTL, [test "$enable_proxy_libintl" = "yes"]) -+ - LIBS="$INTLLIBS $LIBS" - - GETTEXT_PACKAGE=glib20 --- -2.14.3 (Apple Git-98) - diff --git a/recipes/glib/0001-gmodule-Use-RTLD_DEFAULT-if-defined-__BIONIC__.patch b/recipes/glib/0001-gmodule-Use-RTLD_DEFAULT-if-defined-__BIONIC__.patch deleted file mode 100644 index ea51e8c6..00000000 --- a/recipes/glib/0001-gmodule-Use-RTLD_DEFAULT-if-defined-__BIONIC__.patch +++ /dev/null @@ -1,67 +0,0 @@ -From 635d5628a86fb9118c0e98e37e2545649bcfd093 Mon Sep 17 00:00:00 2001 -From: Justin Kim <justin.kim@collabora.com> -Date: Thu, 28 Sep 2017 16:10:05 +0900 -Subject: [PATCH] gmodule: Use RTLD_DEFAULT if defined __BIONIC__ - -This is a partial change of the previous work[0]. -On 64 bit Android since android-23, 'handle = dlopen(NULL); dlsym(handle)' -doesn't work. Instead, only 'dlsym(RTLD_DEFAULT)' returns a valid pointer. - -However, RTLD_DEFAULT is defined as '(void *) 0x0' on 64bit Android which -is usually used for invalid value so this patch allows the specific case. - -[0] 0d81bb4e318b97780c70a55605cacf7e5b3fcaf7 - -Signed-off-by: Justin Kim <justin.kim@collabora.com> ---- - gmodule/gmodule-dl.c | 9 +++++---- - gmodule/gmodule.c | 4 ++++ - 2 files changed, 9 insertions(+), 4 deletions(-) - -diff --git a/gmodule/gmodule-dl.c b/gmodule/gmodule-dl.c -index 42363aac5..5d0200c9d 100644 ---- a/gmodule/gmodule-dl.c -+++ b/gmodule/gmodule-dl.c -@@ -115,10 +115,11 @@ _g_module_self (void) - /* On Android 32 bit (i.e. not __LP64__), dlopen(NULL) - * does not work reliable and generally no symbols are found - * at all. RTLD_DEFAULT works though. -- * On Android 64 bit, dlopen(NULL) seems to work but RTLD_DEFAULT -- * is NULL, which is considered an invalid module. -+ * On Android 64 bit, dlopen(NULL) seems to work but dlsym(handle) -+ * always returns 'undefined symbol'. Only if RTLD_DEFAULT or -+ * NULL is given, dlsym returns an appropriate pointer. - */ --#if defined(__BIONIC__) && !defined(__LP64__) -+#if defined(__BIONIC__) - handle = RTLD_DEFAULT; - #else - handle = dlopen (NULL, RTLD_GLOBAL | RTLD_LAZY); -@@ -138,7 +139,7 @@ _g_module_close (gpointer handle, - * - * See above for the Android special case - */ --#if defined(__BIONIC__) && !defined(__LP64__) -+#if defined(__BIONIC__) - is_unref = (handle != RTLD_DEFAULT); - #else - is_unref |= 1; -diff --git a/gmodule/gmodule.c b/gmodule/gmodule.c -index c55fc762e..886eb85b0 100644 ---- a/gmodule/gmodule.c -+++ b/gmodule/gmodule.c -@@ -510,7 +510,11 @@ g_module_open (const gchar *file_name, - if (!main_module) - { - handle = _g_module_self (); -+/* On Android 64 bit, RTLD_DEFAULT is (void *)0x0 -+ * so it always fails to create main_module if file_name is NULL */ -+#if !defined(__BIONIC__) || !defined(__LP64__) - if (handle) -+#endif - { - main_module = g_new (GModule, 1); - main_module->file_name = NULL; --- -2.14.1 - diff --git a/recipes/glib/0001-meson-Add-exception-for-atomic-ops-test-for-Android.patch b/recipes/glib/0001-meson-Add-exception-for-atomic-ops-test-for-Android.patch new file mode 100644 index 00000000..9087a91b --- /dev/null +++ b/recipes/glib/0001-meson-Add-exception-for-atomic-ops-test-for-Android.patch @@ -0,0 +1,54 @@ +From 9c704bc1381610ddcb6c01ff136bee861fe83526 Mon Sep 17 00:00:00 2001 +From: Nirbheek Chauhan <nirbheek@centricular.com> +Date: Tue, 22 May 2018 11:45:37 +0530 +Subject: [PATCH] meson: Add exception for atomic ops test for Android + +Some compilers, particularly Android on armv5 and old versions of Clang +provide atomic ops, but don't define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 +so we need to define it ourselves. + +This matches what configure does, with the exception that now it's only +done for Android since clang defines __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 +now. + +https://bugzilla.gnome.org/show_bug.cgi?id=796325 +--- + meson.build | 16 ++++++++++++++-- + 1 file changed, 14 insertions(+), 2 deletions(-) + +diff --git a/meson.build b/meson.build +index 11ae73919..b8b1e353c 100644 +--- a/meson.build ++++ b/meson.build +@@ -1375,14 +1375,26 @@ atomictest = '''int main() { + return 0; + } + ''' ++atomicdefine = ''' ++#ifndef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 ++#error "compiler has atomic ops, but doesn't define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4" ++#endif ++''' + if cc.links(atomictest, name : 'atomic ops') +- glibconfig_conf.set('G_ATOMIC_LOCK_FREE', true) ++ have_atomic_lock_free = true ++ if host_system == 'android' and not cc.compiles(atomicdefine, name : 'atomic ops define') ++ # When building for armv5 on Android, gcc 4.9 provides ++ # __sync_bool_compare_and_swap but doesn't define ++ # __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 ++ glib_conf.set('__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4', true) ++ endif + else ++ have_atomic_lock_free = false + if host_machine.cpu_family() == 'x86' and cc.links(atomictest, args : '-march=i486') + error('GLib must be built with -march=i486 or later.') + endif +- glibconfig_conf.set('G_ATOMIC_LOCK_FREE', false) + endif ++glibconfig_conf.set('G_ATOMIC_LOCK_FREE', have_atomic_lock_free) + + # === Threads === + +-- +2.17.0 + diff --git a/recipes/glib/0002-Optionally-revert-to-the-old-pre-2.28-URI-handler-co.patch b/recipes/glib/0002-Optionally-revert-to-the-old-pre-2.28-URI-handler-co.patch deleted file mode 100644 index c1cd1fcd..00000000 --- a/recipes/glib/0002-Optionally-revert-to-the-old-pre-2.28-URI-handler-co.patch +++ /dev/null @@ -1,84 +0,0 @@ -From 91744bf811e9337a85e08843bbdb77ebf9cc89e0 Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= <sebastian.droege@collabora.co.uk> -Date: Fri, 9 Mar 2012 08:44:13 +0100 -Subject: [PATCH 02/13] Optionally revert to the old (pre-2.28) URI handler - code - -This is required to work with the GVfs distributed on Linux distributions -that ship with GLib 2.24 (e.g. Ubuntu Lucid and Debian Squeeze). ---- - gio/gdesktopappinfo.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ - 1 file changed, 51 insertions(+) - -diff --git a/gio/gdesktopappinfo.c b/gio/gdesktopappinfo.c -index 35896b8..6fcd12f 100644 ---- a/gio/gdesktopappinfo.c -+++ b/gio/gdesktopappinfo.c -@@ -4116,6 +4116,7 @@ out: - GAppInfo * - g_app_info_get_default_for_uri_scheme (const char *uri_scheme) - { -+#ifndef GST_SDK_GLIB_GIO_OLD_URI_SCHEME_HANDLERS - GAppInfo *app_info; - char *content_type, *scheme_down; - -@@ -4126,6 +4127,56 @@ g_app_info_get_default_for_uri_scheme (const char *uri_scheme) - g_free (content_type); - - return app_info; -+#else -+ static gsize lookup = 0; -+ -+ if (g_once_init_enter (&lookup)) -+ { -+ gsize setup_value = 1; -+ GDesktopAppInfoLookup *lookup_instance; -+ const char *use_this; -+ GIOExtensionPoint *ep; -+ GIOExtension *extension; -+ GList *l; -+ -+ use_this = g_getenv ("GIO_USE_URI_ASSOCIATION"); -+ -+ /* Ensure vfs in modules loaded */ -+ _g_io_modules_ensure_loaded (); -+ -+ ep = g_io_extension_point_lookup (G_DESKTOP_APP_INFO_LOOKUP_EXTENSION_POINT_NAME); -+ -+ lookup_instance = NULL; -+ if (use_this) -+ { -+ extension = g_io_extension_point_get_extension_by_name (ep, use_this); -+ if (extension) -+ lookup_instance = g_object_new (g_io_extension_get_type (extension), NULL); -+ } -+ -+ if (lookup_instance == NULL) -+ { -+ for (l = g_io_extension_point_get_extensions (ep); l != NULL; l = l->next) -+ { -+ extension = l->data; -+ lookup_instance = g_object_new (g_io_extension_get_type (extension), NULL); -+ if (lookup_instance != NULL) -+ break; -+ } -+ } -+ -+ if (lookup_instance != NULL) -+ setup_value = (gsize)lookup_instance; -+ -+ g_once_init_leave (&lookup, setup_value); -+ } -+ -+ if (lookup == 1) -+ return NULL; -+ -+ return g_desktop_app_info_lookup_get_default_for_uri_scheme (G_DESKTOP_APP_INFO_LOOKUP (lookup), -+ uri_scheme); -+#endif - } - - /* "Get all" API {{{2 */ --- -2.7.4 - diff --git a/recipes/glib/0009-Implementation-of-Cocoa-event-loop-integration-in-GM.patch b/recipes/glib/0009-Implementation-of-Cocoa-event-loop-integration-in-GM.patch index 1aea34db..de0b366c 100644 --- a/recipes/glib/0009-Implementation-of-Cocoa-event-loop-integration-in-GM.patch +++ b/recipes/glib/0009-Implementation-of-Cocoa-event-loop-integration-in-GM.patch @@ -10,19 +10,6 @@ Subject: [PATCH 09/13] Implementation of Cocoa event loop integration in glib/gmain.c | 985 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 991 insertions(+), 2 deletions(-) -diff --git a/configure.ac b/configure.ac -index e9419f6..285d405 100644 ---- a/configure.ac -+++ b/configure.ac -@@ -245,7 +245,7 @@ AM_CONDITIONAL(OS_COCOA, [test "$glib_have_cocoa" = "yes"]) - - if test "x$glib_have_cocoa" = "xyes"; then - AC_DEFINE(HAVE_COCOA, 1, [define to 1 if Cocoa is available]) -- COCOA_LIBS="-Wl,-framework,Foundation" -+ COCOA_LIBS="-Wl,-framework,Foundation -Wl,-framework,AppKit" - LDFLAGS="$LDFLAGS $COCOA_LIBS" - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ - #include <AvailabilityMacros.h> diff --git a/glib/Makefile.am b/glib/Makefile.am index d755853..611eb5b 100644 --- a/glib/Makefile.am diff --git a/recipes/glib/0010-GSocket-Fix-race-conditions-on-Win32-if-multiple-thr.patch b/recipes/glib/0010-GSocket-Fix-race-conditions-on-Win32-if-multiple-thr.patch deleted file mode 100644 index e013ae96..00000000 --- a/recipes/glib/0010-GSocket-Fix-race-conditions-on-Win32-if-multiple-thr.patch +++ /dev/null @@ -1,309 +0,0 @@ -From 3235f26bdf88a9423bbb44c56870ff7df284c7bf Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= <sebastian@centricular.com> -Date: Mon, 5 Dec 2016 12:28:57 +0200 -Subject: [PATCH 10/13] GSocket: Fix race conditions on Win32 if multiple - threads are waiting on conditions for the same socket - -WSAWaitForMultipleEvents() only returns for one of the waiting threads, and -that one might not even be the one waiting for the condition that changed. As -such, only let a single thread wait on the event and use a GCond for all other -threads. - -With this it is possible to e.g. have an UDP socket that is written to from -one thread and read from in another thread on Win32 too. On POSIX systems this -was working before already. - -https://bugzilla.gnome.org/show_bug.cgi?id=762283 ---- - gio/gsocket.c | 94 ++++++++++++++++++++++++++++++++++++++++++----------------- - 1 file changed, 68 insertions(+), 26 deletions(-) - -diff --git a/gio/gsocket.c b/gio/gsocket.c -index f69b565..c5fc855 100644 ---- a/gio/gsocket.c -+++ b/gio/gsocket.c -@@ -249,11 +249,14 @@ struct _GSocketPrivate - guint connect_pending : 1; - #ifdef G_OS_WIN32 - WSAEVENT event; -+ gboolean waiting; -+ DWORD waiting_result; - int current_events; - int current_errors; - int selected_events; - GList *requested_conditions; /* list of requested GIOCondition * */ - GMutex win32_source_lock; -+ GCond win32_source_cond; - #endif - - struct { -@@ -333,8 +336,10 @@ socket_strerror (int err) - static void - _win32_unset_event_mask (GSocket *socket, int mask) - { -+ g_mutex_lock (&socket->priv->win32_source_lock); - socket->priv->current_events &= ~mask; - socket->priv->current_errors &= ~mask; -+ g_mutex_unlock (&socket->priv->win32_source_lock); - } - #else - #define win32_unset_event_mask(_socket, _mask) -@@ -831,6 +836,7 @@ g_socket_finalize (GObject *object) - - g_assert (socket->priv->requested_conditions == NULL); - g_mutex_clear (&socket->priv->win32_source_lock); -+ g_cond_clear (&socket->priv->win32_source_cond); - #endif - - for (i = 0; i < RECV_ADDR_CACHE_SIZE; i++) -@@ -1058,6 +1064,7 @@ g_socket_init (GSocket *socket) - #ifdef G_OS_WIN32 - socket->priv->event = WSA_INVALID_EVENT; - g_mutex_init (&socket->priv->win32_source_lock); -+ g_cond_init (&socket->priv->win32_source_cond); - #endif - } - -@@ -2441,6 +2448,8 @@ g_socket_accept (GSocket *socket, - - while (TRUE) - { -+ win32_unset_event_mask (socket, FD_ACCEPT); -+ - if ((ret = accept (socket->priv->fd, NULL, 0)) < 0) - { - int errsv = get_socket_errno (); -@@ -2455,8 +2464,6 @@ g_socket_accept (GSocket *socket, - errsv == EAGAIN) - #endif - { -- win32_unset_event_mask (socket, FD_ACCEPT); -- - if (socket->priv->blocking) - { - if (!g_socket_condition_wait (socket, -@@ -2473,8 +2480,6 @@ g_socket_accept (GSocket *socket, - break; - } - -- win32_unset_event_mask (socket, FD_ACCEPT); -- - #ifdef G_OS_WIN32 - { - /* The socket inherits the accepting sockets event mask and even object, -@@ -2563,6 +2568,8 @@ g_socket_connect (GSocket *socket, - - while (1) - { -+ win32_unset_event_mask (socket, FD_CONNECT); -+ - if (connect (socket->priv->fd, (struct sockaddr *) &buffer, - g_socket_address_get_native_size (address)) < 0) - { -@@ -2577,8 +2584,6 @@ g_socket_connect (GSocket *socket, - if (errsv == WSAEWOULDBLOCK) - #endif - { -- win32_unset_event_mask (socket, FD_CONNECT); -- - if (socket->priv->blocking) - { - if (g_socket_condition_wait (socket, G_IO_OUT, cancellable, error)) -@@ -2604,8 +2609,6 @@ g_socket_connect (GSocket *socket, - break; - } - -- win32_unset_event_mask (socket, FD_CONNECT); -- - socket->priv->connected_read = TRUE; - socket->priv->connected_write = TRUE; - -@@ -2785,6 +2788,8 @@ g_socket_receive_with_timeout (GSocket *socket, - - while (1) - { -+ win32_unset_event_mask (socket, FD_READ); -+ - if ((ret = recv (socket->priv->fd, buffer, size, 0)) < 0) - { - int errsv = get_socket_errno (); -@@ -2799,8 +2804,6 @@ g_socket_receive_with_timeout (GSocket *socket, - errsv == EAGAIN) - #endif - { -- win32_unset_event_mask (socket, FD_READ); -- - if (timeout != 0) - { - if (!block_on_timeout (socket, G_IO_IN, timeout, start_time, -@@ -2811,14 +2814,10 @@ g_socket_receive_with_timeout (GSocket *socket, - } - } - -- win32_unset_event_mask (socket, FD_READ); -- - socket_set_error_lazy (error, errsv, _("Error receiving data: %s")); - return -1; - } - -- win32_unset_event_mask (socket, FD_READ); -- - break; - } - -@@ -2984,6 +2983,8 @@ g_socket_send_with_timeout (GSocket *socket, - - while (1) - { -+ win32_unset_event_mask (socket, FD_WRITE); -+ - if ((ret = send (socket->priv->fd, buffer, size, G_SOCKET_DEFAULT_SEND_FLAGS)) < 0) - { - int errsv = get_socket_errno (); -@@ -2998,8 +2999,6 @@ g_socket_send_with_timeout (GSocket *socket, - errsv == EAGAIN) - #endif - { -- win32_unset_event_mask (socket, FD_WRITE); -- - if (timeout != 0) - { - if (!block_on_timeout (socket, G_IO_OUT, timeout, start_time, -@@ -3414,7 +3413,7 @@ remove_condition_watch (GSocket *socket, - } - - static GIOCondition --update_condition (GSocket *socket) -+update_condition_unlocked (GSocket *socket) - { - WSANETWORKEVENTS events; - GIOCondition condition; -@@ -3481,6 +3480,16 @@ update_condition (GSocket *socket) - - return condition; - } -+ -+static GIOCondition -+update_condition (GSocket *socket) -+{ -+ GIOCondition res; -+ g_mutex_lock (&socket->priv->win32_source_lock); -+ res = update_condition_unlocked (socket); -+ g_mutex_unlock (&socket->priv->win32_source_lock); -+ return res; -+} - #endif - - typedef struct { -@@ -3876,11 +3885,44 @@ g_socket_condition_timed_wait (GSocket *socket, - if (timeout == -1) - timeout = WSA_INFINITE; - -- current_condition = update_condition (socket); -+ g_mutex_lock (&socket->priv->win32_source_lock); -+ current_condition = update_condition_unlocked (socket); - while ((condition & current_condition) == 0) - { -- res = WSAWaitForMultipleEvents (num_events, events, -- FALSE, timeout, FALSE); -+ if (!socket->priv->waiting) -+ { -+ socket->priv->waiting = TRUE; -+ socket->priv->waiting_result = 0; -+ g_mutex_unlock (&socket->priv->win32_source_lock); -+ -+ res = WSAWaitForMultipleEvents (num_events, events, FALSE, timeout, FALSE); -+ -+ g_mutex_lock (&socket->priv->win32_source_lock); -+ socket->priv->waiting = FALSE; -+ socket->priv->waiting_result = res; -+ g_cond_broadcast (&socket->priv->win32_source_cond); -+ } -+ else -+ { -+ if (timeout != WSA_INFINITE) -+ { -+ if (!g_cond_wait_until (&socket->priv->win32_source_cond, &socket->priv->win32_source_lock, timeout)) -+ { -+ res = WSA_WAIT_TIMEOUT; -+ break; -+ } -+ else -+ { -+ res = socket->priv->waiting_result; -+ } -+ } -+ else -+ { -+ g_cond_wait (&socket->priv->win32_source_cond, &socket->priv->win32_source_lock); -+ res = socket->priv->waiting_result; -+ } -+ } -+ - if (res == WSA_WAIT_FAILED) - { - int errsv = get_socket_errno (); -@@ -3901,7 +3943,7 @@ g_socket_condition_timed_wait (GSocket *socket, - if (g_cancellable_set_error_if_cancelled (cancellable, error)) - break; - -- current_condition = update_condition (socket); -+ current_condition = update_condition_unlocked (socket); - - if (timeout != WSA_INFINITE) - { -@@ -3910,6 +3952,7 @@ g_socket_condition_timed_wait (GSocket *socket, - timeout = 0; - } - } -+ g_mutex_unlock (&socket->priv->win32_source_lock); - remove_condition_watch (socket, &condition); - if (num_events > 1) - g_cancellable_release_fd (cancellable); -@@ -4405,6 +4448,8 @@ g_socket_send_message_with_timeout (GSocket *socket, - - while (1) - { -+ win32_unset_event_mask (socket, FD_WRITE); -+ - if (address) - result = WSASendTo (socket->priv->fd, - bufs, num_vectors, -@@ -4426,8 +4471,6 @@ g_socket_send_message_with_timeout (GSocket *socket, - - if (errsv == WSAEWOULDBLOCK) - { -- win32_unset_event_mask (socket, FD_WRITE); -- - if (timeout != 0) - { - if (!block_on_timeout (socket, G_IO_OUT, timeout, -@@ -4875,6 +4918,8 @@ g_socket_receive_message_with_timeout (GSocket *socket, - /* do it */ - while (1) - { -+ win32_unset_event_mask (socket, FD_READ); -+ - addrlen = sizeof addr; - if (address) - result = WSARecvFrom (socket->priv->fd, -@@ -4896,8 +4941,6 @@ g_socket_receive_message_with_timeout (GSocket *socket, - - if (errsv == WSAEWOULDBLOCK) - { -- win32_unset_event_mask (socket, FD_READ); -- - if (timeout != 0) - { - if (!block_on_timeout (socket, G_IO_IN, timeout, -@@ -4911,7 +4954,6 @@ g_socket_receive_message_with_timeout (GSocket *socket, - socket_set_error_lazy (error, errsv, _("Error receiving message: %s")); - return -1; - } -- win32_unset_event_mask (socket, FD_READ); - break; - } - --- -2.7.4 - diff --git a/recipes/glib/glib-2.57-meson-backported-fixes.patch b/recipes/glib/glib-2.57-meson-backported-fixes.patch new file mode 100644 index 00000000..012f53b8 --- /dev/null +++ b/recipes/glib/glib-2.57-meson-backported-fixes.patch @@ -0,0 +1,1881 @@ +From 07d2a2de8a67131d31dfe1093abc8920334c7f8b Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?=D0=A0=D1=83=D1=81=D0=BB=D0=B0=D0=BD=20=D0=98=D0=B6=D0=B1?= + =?UTF-8?q?=D1=83=D0=BB=D0=B0=D1=82=D0=BE=D0=B2?= <lrn1986@gmail.com> +Date: Wed, 11 Apr 2018 11:11:24 +0000 +Subject: [PATCH 01/24] W32 gstdio: Don't try to get reparse tag + unconditionally + +We do not need to use FindFirstFileW() to get a reparse tag if the +file that is being examined is not a reparse point. + +This is a quick and relatively painless fix for the fact that +FindFirstFileW() fails on root directories. Since root directories +are unlikely to be reparse points (is it even possible?), not using +this function on non-reparse-points just sidesteps the issue. + +https://bugzilla.gnome.org/show_bug.cgi?id=795153 +--- + glib/gstdio.c | 23 ++++++++++++++--------- + 1 file changed, 14 insertions(+), 9 deletions(-) + +diff --git a/glib/gstdio.c b/glib/gstdio.c +index 858d56999..faaa1bafd 100644 +--- a/glib/gstdio.c ++++ b/glib/gstdio.c +@@ -209,18 +209,23 @@ _g_win32_stat_utf16_no_trailing_slashes (const gunichar2 *filename, + */ + if (fd < 0) + { +- HANDLE tmp = FindFirstFileW (filename, +- &finddata); ++ memset (&finddata, 0, sizeof (finddata)); + +- if (tmp == INVALID_HANDLE_VALUE) ++ if (handle_info.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) + { +- error_code = GetLastError (); +- errno = w32_error_to_errno (error_code); +- CloseHandle (file_handle); +- return -1; +- } ++ HANDLE tmp = FindFirstFileW (filename, ++ &finddata); + +- FindClose (tmp); ++ if (tmp == INVALID_HANDLE_VALUE) ++ { ++ error_code = GetLastError (); ++ errno = w32_error_to_errno (error_code); ++ CloseHandle (file_handle); ++ return -1; ++ } ++ ++ FindClose (tmp); ++ } + + if (is_symlink && !for_symlink) + { +-- +2.17.0 + + +From 0a6ccdccb5078024ddc5aca72e4d5113ee851792 Mon Sep 17 00:00:00 2001 +From: Fabrice Fontaine <fontaine.fabrice@gmail.com> +Date: Tue, 10 Apr 2018 18:55:11 +0200 +Subject: [PATCH 02/24] gio: fix compilation without F_{S,G}ETPIPE_SZ + +Commit a5778ef7c51044147fe470ea1707dd297f44f880 broke compilation on +architectures without F_SETPIPE_SZ and F_GETPIPE_SZ such as or1k. +If those variables are undefined, put back previous behavior, buffer +size set to 1024 * 64 + +Fixes: + - http://autobuild.buildroot.net/results/398490e07343a931b25ca6ab5c90a75d7a073e9f + +(Modified by Philip Withnall <withnall@endlessm.com> to add an +explanatory comment.) + +Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com> + +https://bugzilla.gnome.org/show_bug.cgi?id=795133 +--- + gio/gfile.c | 8 ++++++++ + 1 file changed, 8 insertions(+) + +diff --git a/gio/gfile.c b/gio/gfile.c +index 334ad8ec3..a67aad383 100644 +--- a/gio/gfile.c ++++ b/gio/gfile.c +@@ -3012,6 +3012,7 @@ splice_stream_with_progress (GInputStream *in, + if (!g_unix_open_pipe (buffer, FD_CLOEXEC, error)) + return FALSE; + ++#if defined(F_SETPIPE_SZ) && defined(F_GETPIPE_SZ) + /* Try a 1MiB buffer for improved throughput. If that fails, use the default + * pipe size. See: https://bugzilla.gnome.org/791457 */ + buffer_size = fcntl (buffer[1], F_SETPIPE_SZ, 1024 * 1024); +@@ -3029,6 +3030,13 @@ splice_stream_with_progress (GInputStream *in, + goto out; + } + } ++#else ++ /* If #F_GETPIPE_SZ isn’t available, assume we’re on Linux < 2.6.35, ++ * but ≥ 2.6.11, meaning the pipe capacity is 64KiB. Ignore the possibility of ++ * running on Linux < 2.6.11 (where the capacity was the system page size, ++ * typically 4KiB) because it’s ancient. See pipe(7). */ ++ buffer_size = 1024 * 64; ++#endif + + g_assert (buffer_size > 0); + +-- +2.17.0 + + +From e2939d5fa86f51d638051a76ab07e7d6d87cba68 Mon Sep 17 00:00:00 2001 +From: Fabrice Fontaine <fontaine.fabrice@gmail.com> +Date: Tue, 10 Apr 2018 19:18:57 +0200 +Subject: [PATCH 03/24] gobject: fix compilation with gcc <= 4.7 + +On gcc 4.7, we got the following error: + +i686-nptl-linux-gnu-gcc --version +> i686-nptl-linux-gnu-gcc (crosstool-NG 1.20.0) 4.7.4 +> $ echo '#include <glib-object.h>' | i686-nptl-linux-gnu-gcc -x c -I +staging/usr/include/glib-2.0 -I staging/usr/lib/glib-2.0/include -Wall +-Werror -c - -o /tmp/foo.o +> In file included from +staging/usr/include/glib-2.0/gobject/gbinding.h:29:0, +> from staging/usr/include/glib-2.0/glib-object.h:23, +> from <stdin>:1: +> staging/usr/include/glib-2.0/gobject/gobject.h: In function +'g_set_object': +> staging/usr/include/glib-2.0/gobject/gobject.h:725:5: error: value +computed is not used [-Werror=unused-value] +> cc1: all warnings being treated as errors + +This error has been added by commit 3fae39a5d742afe73741f5fd7aa24e3ae8182f06 +So enable the new g_set_object definition only if gcc >= 4.8 + +Fixes: + - http://autobuild.buildroot.net/results/b29a2f868438a2210873ea72f491db63175848be + +Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com> + +https://bugzilla.gnome.org/show_bug.cgi?id=795138 +--- + gobject/gobject.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/gobject/gobject.h b/gobject/gobject.h +index 9830663ce..838046fe0 100644 +--- a/gobject/gobject.h ++++ b/gobject/gobject.h +@@ -507,7 +507,7 @@ GLIB_AVAILABLE_IN_ALL + void g_object_remove_weak_pointer (GObject *object, + gpointer *weak_pointer_location); + +-#if defined(__GNUC__) && !defined(__cplusplus) && GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_56 ++#if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)) && !defined(__cplusplus) && GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_56 + /* Make reference APIs type safe with macros */ + #define g_object_ref(Obj) ((__typeof__(Obj)) (g_object_ref) (Obj)) + #define g_object_ref_sink(Obj) ((__typeof__(Obj)) (g_object_ref_sink) (Obj)) +-- +2.17.0 + + +From 1c6c488d519bccec1f723330e90a98c0ae095b84 Mon Sep 17 00:00:00 2001 +From: Xavier Claessens <xavier.claessens@collabora.com> +Date: Mon, 23 Apr 2018 11:47:17 -0400 +Subject: [PATCH 04/24] struct ip_mreq_source definition is broken on Android + NDK <= r16 + +This fix the build on Android r16 and older, see: +https://issuetracker.google.com/issues/36987220 + +https://bugzilla.gnome.org/show_bug.cgi?id=740791 +--- + config.h.meson | 3 +++ + configure.ac | 15 +++++++++++++++ + gio/gsocket.c | 16 +++++++++++++--- + gio/meson.build | 10 ++++++++++ + 4 files changed, 41 insertions(+), 3 deletions(-) + +diff --git a/config.h.meson b/config.h.meson +index d540cb801..8c3f3132e 100644 +--- a/config.h.meson ++++ b/config.h.meson +@@ -15,6 +15,9 @@ + /* poll doesn't work on devices */ + #mesondefine BROKEN_POLL + ++/* struct ip_mreq_source definition is broken on Android NDK <= r16 */ ++#mesondefine BROKEN_IP_MREQ_SOURCE_STRUCT ++ + /* Whether we're building a DLL and hence need symbols exported for a DLL */ + #mesondefine DLL_EXPORT + +diff --git a/configure.ac b/configure.ac +index 2013d198e..627022ef2 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -961,6 +961,21 @@ AC_COMPILE_IFELSE([AC_LANG_PROGRAM( + AC_MSG_RESULT(no) + ]) + ++AC_MSG_CHECKING([if ip_mreq_source.imr_interface has s_addr member]) ++AC_COMPILE_IFELSE([AC_LANG_PROGRAM( ++ [[ ++ #include <netinet/in.h> ++ ]], ++ [[ ++ struct ip_mreq_source mc_req_src; ++ mc_req_src.imr_interface.s_addr = 0; ++ ]])], [ ++ AC_MSG_RESULT(yes) ++ ], [ ++ AC_MSG_RESULT(no) ++ AC_DEFINE(BROKEN_IP_MREQ_SOURCE_STRUCT, 1, [struct ip_mreq_source definition is broken on Android NDK <= r16]) ++]) ++ + AS_IF([test $glib_native_win32 = yes], [ + # <wspiapi.h> in the Windows SDK and in mingw-w64 has wrappers for + # inline workarounds for getaddrinfo, getnameinfo and freeaddrinfo if +diff --git a/gio/gsocket.c b/gio/gsocket.c +index 06042d8a8..b4a941eb1 100644 +--- a/gio/gsocket.c ++++ b/gio/gsocket.c +@@ -2380,6 +2380,13 @@ g_socket_multicast_group_operation_ssm (GSocket *socket, + case G_SOCKET_FAMILY_IPV4: + { + #ifdef IP_ADD_SOURCE_MEMBERSHIP ++ ++#ifdef BROKEN_IP_MREQ_SOURCE_STRUCT ++#define S_ADDR_FIELD(src) src.imr_interface ++#else ++#define S_ADDR_FIELD(src) src.imr_interface.s_addr ++#endif ++ + gint optname; + struct ip_mreq_source mc_req_src; + +@@ -2397,7 +2404,7 @@ g_socket_multicast_group_operation_ssm (GSocket *socket, + memset (&mc_req_src, 0, sizeof (mc_req_src)); + + /* By default use the default IPv4 multicast interface. */ +- mc_req_src.imr_interface.s_addr = g_htonl (INADDR_ANY); ++ S_ADDR_FIELD(mc_req_src) = g_htonl (INADDR_ANY); + + if (iface) + { +@@ -2412,7 +2419,7 @@ g_socket_multicast_group_operation_ssm (GSocket *socket, + return FALSE; + } + /* (0.0.0.iface_index) only works on Windows. */ +- mc_req_src.imr_interface.s_addr = g_htonl (iface_index); ++ S_ADDR_FIELD(mc_req_src) = g_htonl (iface_index); + #elif defined (HAVE_SIOCGIFADDR) + int ret; + struct ifreq ifr; +@@ -2442,7 +2449,7 @@ g_socket_multicast_group_operation_ssm (GSocket *socket, + } + + iface_addr = (struct sockaddr_in *) &ifr.ifr_addr; +- mc_req_src.imr_interface.s_addr = iface_addr->sin_addr.s_addr; ++ S_ADDR_FIELD(mc_req_src) = iface_addr->sin_addr.s_addr; + #endif /* defined(G_OS_WIN32) && defined (HAVE_IF_NAMETOINDEX) */ + } + memcpy (&mc_req_src.imr_multiaddr, g_inet_address_to_bytes (group), +@@ -2455,6 +2462,9 @@ g_socket_multicast_group_operation_ssm (GSocket *socket, + join_group ? IP_ADD_SOURCE_MEMBERSHIP : IP_DROP_SOURCE_MEMBERSHIP; + result = setsockopt (socket->priv->fd, IPPROTO_IP, optname, + &mc_req_src, sizeof (mc_req_src)); ++ ++#undef S_ADDR_FIELD ++ + #else + g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED, + join_group ? +diff --git a/gio/meson.build b/gio/meson.build +index 7817a4797..c83d8405f 100644 +--- a/gio/meson.build ++++ b/gio/meson.build +@@ -154,6 +154,16 @@ if host_system != 'windows' + glib_conf.set('HAVE_SIOCGIFADDR', '/**/') + endif + ++ if not cc.compiles('''#include <netinet/in.h> ++ int main(int argc, char ** argv) { ++ struct ip_mreq_source mc_req_src; ++ mc_req_src.imr_interface.s_addr = 0; ++ return 0; ++ }''', ++ name : 'ip_mreq_source.imr_interface has s_addr member') ++ glib_conf.set('BROKEN_IP_MREQ_SOURCE_STRUCT', 1) ++ endif ++ + endif + + network_args_string = '' +-- +2.17.0 + + +From 73ad4e4669620a82350f2195b68e5b9d6ca67967 Mon Sep 17 00:00:00 2001 +From: Xavier Claessens <xavier.claessens@collabora.com> +Date: Fri, 20 Apr 2018 12:09:32 -0400 +Subject: [PATCH 05/24] Meson: Add missing link on libintl in tests + +This fix undefined symbol link error when building for non-glibc +platform. Applications must link on libintl, it is not a public +dependency of libglib. + +On glibc platforms libintl is a not found dependency and is just ignored +by meson, so it doesn't hurt to always have it. + +https://bugzilla.gnome.org/show_bug.cgi?id=795406 +--- + gio/tests/meson.build | 12 +++++++----- + 1 file changed, 7 insertions(+), 5 deletions(-) + +diff --git a/gio/tests/meson.build b/gio/tests/meson.build +index 668839402..5aceb7c26 100644 +--- a/gio/tests/meson.build ++++ b/gio/tests/meson.build +@@ -1,8 +1,10 @@ +-common_gio_tests_deps = [libglib_dep, libgmodule_dep, libgobject_dep, libgio_dep] +- +-if host_system == 'darwin' +-common_gio_tests_deps += [libintl] +-endif ++common_gio_tests_deps = [ ++ libglib_dep, ++ libgmodule_dep, ++ libgobject_dep, ++ libgio_dep, ++ libintl ++] + + subdir('gdbus-object-manager-example') + +-- +2.17.0 + + +From 42a091755f8faaed96d2a07ca57eecdb483d606c Mon Sep 17 00:00:00 2001 +From: Xavier Claessens <xavier.claessens@collabora.com> +Date: Mon, 23 Apr 2018 10:33:44 -0400 +Subject: [PATCH 06/24] Fix build when pthread_getname_np is not available + +On Android _setname_ is always available but _getname_ is available only +with API level >= 26. + +https://bugzilla.gnome.org/show_bug.cgi?id=795406 +--- + config.h.meson | 3 +++ + configure.ac | 9 +++++++++ + glib/tests/thread.c | 2 +- + meson.build | 18 ++++++++++-------- + 4 files changed, 23 insertions(+), 9 deletions(-) + +diff --git a/config.h.meson b/config.h.meson +index 8c3f3132e..57e1ef5fb 100644 +--- a/config.h.meson ++++ b/config.h.meson +@@ -337,6 +337,9 @@ + /* Have function pthread_setname_np with TID as argument */ + #mesondefine HAVE_PTHREAD_SETNAME_NP_WITH_TID + ++/* Have function pthread_getname_np */ ++#mesondefine HAVE_PTHREAD_GETNAME_NP ++ + /* Define to 1 if the system has the type `ptrdiff_t'. */ + #mesondefine HAVE_PTRDIFF_T + +diff --git a/configure.ac b/configure.ac +index 627022ef2..61d0544a6 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -2245,6 +2245,15 @@ AS_IF([ test x"$have_threads" = xposix], [ + AC_DEFINE(HAVE_PTHREAD_SETNAME_NP_WITH_TID,1, + [Have function pthread_setname_np(pthread_t, const char*)])], + [AC_MSG_RESULT(no)]) ++ AC_MSG_CHECKING(for pthread_getname_np(pthread_t, name, len)) ++ AC_LINK_IFELSE( ++ [AC_LANG_PROGRAM( ++ [#include <pthread.h>], ++ [[char name[16]; pthread_getname_np(pthread_self(), name, 16);]])], ++ [AC_MSG_RESULT(yes) ++ AC_DEFINE(HAVE_PTHREAD_GETNAME_NP,1, ++ [Have function pthread_getname_np(pthread_t, name, len)])], ++ [AC_MSG_RESULT(no)]) + CPPFLAGS="$glib_save_CPPFLAGS" + ]) + +diff --git a/glib/tests/thread.c b/glib/tests/thread.c +index 544783692..a79b9513f 100644 +--- a/glib/tests/thread.c ++++ b/glib/tests/thread.c +@@ -174,7 +174,7 @@ test_thread5 (void) + static gpointer + thread6_func (gpointer data) + { +-#ifdef HAVE_PTHREAD_SETNAME_NP_WITH_TID ++#if defined (HAVE_PTHREAD_SETNAME_NP_WITH_TID) && defined (HAVE_PTHREAD_GETNAME_NP) + char name[16]; + + pthread_getname_np (pthread_self(), name, 16); +diff --git a/meson.build b/meson.build +index d9bf2c46a..84fa5a18e 100644 +--- a/meson.build ++++ b/meson.build +@@ -1400,6 +1400,11 @@ if host_system == 'windows' + glibconfig_conf.set('g_threads_impl_def', 'WIN32') + glib_conf.set('THREADS_WIN32', 1) + else ++ pthread_prefix = ''' ++ #ifndef _GNU_SOURCE ++ # define _GNU_SOURCE ++ #endif ++ #include <pthread.h>''' + glibconfig_conf.set('g_threads_impl_def', 'POSIX') + glib_conf.set('THREADS_POSIX', 1) + if cc.has_header_symbol('pthread.h', 'pthread_attr_setstacksize') +@@ -1411,11 +1416,11 @@ else + if cc.has_header_symbol('pthread.h', 'pthread_cond_timedwait_relative_np') + glib_conf.set('HAVE_PTHREAD_COND_TIMEDWAIT_RELATIVE_NP', 1) + endif ++ if cc.has_header_symbol('pthread.h', 'pthread_getname_np', prefix : pthread_prefix) ++ glib_conf.set('HAVE_PTHREAD_GETNAME_NP', 1) ++ endif + # Assume that pthread_setname_np is available in some form; same as configure +- if cc.links('''#ifndef _GNU_SOURCE +- # define _GNU_SOURCE +- #endif +- #include <pthread.h> ++ if cc.links(pthread_prefix + ''' + int main() { + pthread_setname_np("example"); + }''', +@@ -1423,10 +1428,7 @@ else + dependencies : thread_dep) + # macOS and iOS + glib_conf.set('HAVE_PTHREAD_SETNAME_NP_WITHOUT_TID', 1) +- elif cc.links('''#ifndef _GNU_SOURCE +- # define _GNU_SOURCE +- #endif +- #include <pthread.h> ++ elif cc.links(pthread_prefix + ''' + int main() { + pthread_setname_np(pthread_self(), "example"); + }''', +-- +2.17.0 + + +From 5f59824d257b4f128a6ddc3c9405b252c5cd0e02 Mon Sep 17 00:00:00 2001 +From: Nirbheek Chauhan <nirbheek@centricular.com> +Date: Sat, 5 May 2018 03:19:54 +0530 +Subject: [PATCH 07/24] meson: Update glib version + +--- + meson.build | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/meson.build b/meson.build +index 84fa5a18e..8f3cb91a1 100644 +--- a/meson.build ++++ b/meson.build +@@ -1,5 +1,5 @@ + project('glib', 'c', 'cpp', +- version : '2.56.0', ++ version : '2.56.1', + meson_version : '>= 0.44.0', + default_options : [ + 'warning_level=1', +-- +2.17.0 + + +From 6330d09f07833bbea75b9bbe821d431891628c30 Mon Sep 17 00:00:00 2001 +From: Xavier Claessens <xavier.claessens@collabora.com> +Date: Mon, 11 Dec 2017 14:47:04 -0500 +Subject: [PATCH 08/24] Meson: Use pkgconfig module to generate all pc files + +This requires improved pc file generator from meson 0.45. + +https://bugzilla.gnome.org/show_bug.cgi?id=788773 +--- + gio/meson.build | 39 +++++++++++++++++++++++++++++++++++++++ + glib/meson.build | 14 ++++++++++++++ + gmodule/meson.build | 32 ++++++++++++++++++++++++++++++++ + gobject/meson.build | 9 +++++++++ + gthread/meson.build | 9 +++++++++ + meson.build | 31 ++++--------------------------- + 6 files changed, 107 insertions(+), 27 deletions(-) + +diff --git a/gio/meson.build b/gio/meson.build +index c83d8405f..ca544d93c 100644 +--- a/gio/meson.build ++++ b/gio/meson.build +@@ -804,6 +804,45 @@ libgio = library('gio-2.0', + link_args : noseh_link_args, + ) + ++giomodulesdir = get_option('gio_module_dir') ++if giomodulesdir == '' ++ giomodulesdir = join_paths('${libdir}', 'gio', 'modules') ++endif ++ ++pkg.generate(libraries : libgio, ++ requires : ['glib-2.0', 'gobject-2.0'], ++ variables : ['bindir=' + join_paths('${prefix}', get_option('bindir')), ++ 'giomoduledir=' + giomodulesdir, ++ 'glib_compile_schemas=' + join_paths('${bindir}', 'glib-compile-schemas'), ++ 'glib_compile_resources=' + join_paths('${bindir}', 'glib-compile-resources'), ++ 'gdbus_codegen=' + join_paths('${bindir}', 'gdbus-codegen')], ++ version : glib_version, ++ install_dir : glib_pkgconfigreldir, ++ filebase : 'gio-2.0', ++ name : 'GIO', ++ description : 'glib I/O library', ++) ++ ++if host_system == 'windows' ++ pkg.generate(requires : ['gobject-2.0', 'gmodule-no-export-2.0', 'gio-2.0'], ++ subdirs : ['gio-win32-2.0'], ++ version : glib_version, ++ install_dir : glib_pkgconfigreldir, ++ filebase : 'gio-windows-2.0', ++ name : 'GIO Windows specific APIs', ++ description : 'Windows specific headers for glib I/O library', ++ ) ++else ++ pkg.generate(requires : ['gobject-2.0', 'gio-2.0'], ++ subdirs : ['gio-unix-2.0'], ++ version : glib_version, ++ install_dir : glib_pkgconfigreldir, ++ filebase : 'gio-unix-2.0', ++ name : 'GIO unix specific APIs', ++ description : 'unix specific headers for glib I/O library', ++ ) ++endif ++ + libgio_dep = declare_dependency(link_with : libgio, + dependencies : [gioenumtypes_dep], + # We sadly need to export configinc here because everyone includes <gio/*.h> +diff --git a/glib/meson.build b/glib/meson.build +index 9df77b6f9..3b4caf8ce 100644 +--- a/glib/meson.build ++++ b/glib/meson.build +@@ -249,6 +249,20 @@ libglib_dep = declare_dependency( + # We sadly need to export configinc here because everyone includes <glib/*.h> + include_directories : [configinc, glibinc]) + ++pkg.generate(libraries : libglib, ++ subdirs : ['glib-2.0'], ++ extra_cflags : ['-I${libdir}/glib-2.0/include'], ++ variables : ['bindir=' + join_paths('${prefix}', get_option('bindir')), ++ 'glib_genmarshal=' + join_paths('${bindir}', 'glib-genmarshal'), ++ 'gobject_query=' + join_paths('${bindir}', 'gobject-query'), ++ 'glib_mkenums=' + join_paths('${bindir}', 'glib-mkenums')], ++ version : glib_version, ++ install_dir : glib_pkgconfigreldir, ++ filebase : 'glib-2.0', ++ name : 'GLib', ++ description : 'C Utility Library', ++) ++ + # On Windows, glib needs a spawn helper for g_spawn* API + if host_system == 'windows' + if host_machine.cpu_family() == 'x86' +diff --git a/gmodule/meson.build b/gmodule/meson.build +index 03c689e3a..3b57fb477 100644 +--- a/gmodule/meson.build ++++ b/gmodule/meson.build +@@ -104,5 +104,37 @@ libgmodule = library('gmodule-2.0', + dependencies : [libdl_dep, libglib_dep], + c_args : ['-DG_LOG_DOMAIN="GModule"', '-DG_DISABLE_DEPRECATED'] + glib_hidden_visibility_args) + ++supported_var = 'gmodule_supported=@0@'.format(g_module_impl != '0') ++ ++pkg.generate(libraries : [libgmodule, thread_dep], ++ requires : ['glib-2.0'], ++ version : glib_version, ++ variables : [supported_var], ++ install_dir : glib_pkgconfigreldir, ++ filebase : 'gmodule-no-export-2.0', ++ name : 'GModule', ++ description : 'Dynamic module loader for GLib', ++) ++ ++pkg.generate(libraries : [libgmodule], ++ requires : ['glib-2.0'], ++ version : glib_version, ++ variables : [supported_var], ++ install_dir : glib_pkgconfigreldir, ++ filebase : 'gmodule-export-2.0', ++ name : 'GModule', ++ description : 'Dynamic module loader for GLib', ++) ++ ++pkg.generate(libraries : [libgmodule], ++ requires : ['glib-2.0'], ++ version : glib_version, ++ variables : [supported_var], ++ install_dir : glib_pkgconfigreldir, ++ filebase : 'gmodule-2.0', ++ name : 'GModule', ++ description : 'Dynamic module loader for GLib', ++) ++ + libgmodule_dep = declare_dependency(link_with : libgmodule, + include_directories : gmoduleinc) +diff --git a/gobject/meson.build b/gobject/meson.build +index f1ab8fd46..98e306d7f 100644 +--- a/gobject/meson.build ++++ b/gobject/meson.build +@@ -71,6 +71,15 @@ libgobject = library('gobject-2.0', + dependencies : [libintl, libffi_dep, libglib_dep], + c_args : ['-DG_LOG_DOMAIN="GLib-GObject"', '-DGOBJECT_COMPILATION'] + glib_hidden_visibility_args) + ++pkg.generate(libraries : libgobject, ++ requires : ['glib-2.0'], ++ version : glib_version, ++ install_dir : glib_pkgconfigreldir, ++ filebase : 'gobject-2.0', ++ name : 'GObject', ++ description : 'GLib Type, Object, Parameter and Signal Library', ++) ++ + libgobject_dep = declare_dependency(link_with : libgobject, + include_directories : gobjectinc) + +diff --git a/gthread/meson.build b/gthread/meson.build +index 8d4696d29..3787dba3b 100644 +--- a/gthread/meson.build ++++ b/gthread/meson.build +@@ -19,3 +19,12 @@ libgthread = library('gthread-2.0', + install : true, + dependencies : [libglib_dep], + c_args : ['-DG_LOG_DOMAIN="GThread"' ] + glib_hidden_visibility_args) ++ ++pkg.generate(libraries : [libgthread, thread_dep], ++ requires : ['glib-2.0'], ++ version : glib_version, ++ install_dir : glib_pkgconfigreldir, ++ filebase : 'gthread-2.0', ++ name : 'GThread', ++ description : 'Thread support for GLib', ++) +diff --git a/meson.build b/meson.build +index 8f3cb91a1..543f91704 100644 +--- a/meson.build ++++ b/meson.build +@@ -1,6 +1,6 @@ + project('glib', 'c', 'cpp', + version : '2.56.1', +- meson_version : '>= 0.44.0', ++ meson_version : '>= 0.45.0', + default_options : [ + 'warning_level=1', + 'c_std=gnu89' +@@ -1679,8 +1679,8 @@ if libmount_dep.length() != 0 + endif + glib_conf.set('GIO_MODULE_DIR', glib_giomodulesdir) + # FIXME: Missing: +-# @G_MODULE_LIBS@ @COCOA_LIBS@ @CARBON_LIBS@ @G_LIBS_EXTRA@ +-# @PCRE_REQUIRES@ @GLIB_EXTRA_CFLAGS@ @G_THREAD_CFLAGS@ ++# @COCOA_LIBS@ @CARBON_LIBS@ @G_LIBS_EXTRA@ @GLIB_EXTRA_CFLAGS@ ++# @G_MODULE_LDFLAGS@ + + # Tracing: dtrace + want_dtrace = get_option('dtrace') +@@ -1726,6 +1726,7 @@ if want_systemtap and enable_dtrace + endif + + ++pkg = import('pkgconfig') + windows = import('windows') + subdir('glib') + subdir('gobject') +@@ -1737,30 +1738,6 @@ if xgettext.found() + endif + subdir('tests') + +-# Configure and install pkg-config files +-pc_files = [ +- 'gobject-2.0.pc', +- 'glib-2.0.pc', +- 'gthread-2.0.pc', +- 'gmodule-2.0.pc', +- 'gmodule-export-2.0.pc', +- 'gmodule-no-export-2.0.pc', +- 'gio-2.0.pc', +-] +-if host_system == 'windows' +- pc_files += ['gio-windows-2.0.pc'] +-else +- pc_files += ['gio-unix-2.0.pc'] +-endif +- +-foreach pc : pc_files +- configure_file(input : pc + '.in', +- install : true, +- install_dir : glib_pkgconfigreldir, +- output : pc, +- configuration : glib_conf) +-endforeach +- + # NOTE: We skip glib-zip.in because the filenames it assumes don't match ours + + # Install glib-gettextize executable, if a UNIX-style shell is found +-- +2.17.0 + + +From 31427ef282de6700e8a4aec354048a77f98b0c53 Mon Sep 17 00:00:00 2001 +From: Xavier Claessens <xavier.claessens@collabora.com> +Date: Thu, 4 Jan 2018 15:55:59 -0500 +Subject: [PATCH 09/24] Meson: Add carbon and cocoa flags into glib and gio pc + files + +https://bugzilla.gnome.org/show_bug.cgi?id=788773 +--- + gio/meson.build | 1 + + glib/meson.build | 3 ++- + meson.build | 14 +++++--------- + 3 files changed, 8 insertions(+), 10 deletions(-) + +diff --git a/gio/meson.build b/gio/meson.build +index ca544d93c..9e663d6ef 100644 +--- a/gio/meson.build ++++ b/gio/meson.build +@@ -810,6 +810,7 @@ if giomodulesdir == '' + endif + + pkg.generate(libraries : libgio, ++ libraries_private : [osx_ldflags], + requires : ['glib-2.0', 'gobject-2.0'], + variables : ['bindir=' + join_paths('${prefix}', get_option('bindir')), + 'giomoduledir=' + giomodulesdir, +diff --git a/glib/meson.build b/glib/meson.build +index 3b4caf8ce..9d186201d 100644 +--- a/glib/meson.build ++++ b/glib/meson.build +@@ -234,7 +234,7 @@ libglib = library('glib-2.0', + soversion : soversion, + install : true, + # intl.lib is not compatible with SAFESEH +- link_args : platform_ldflags + noseh_link_args, ++ link_args : noseh_link_args, + include_directories : configinc, + link_with : [charset_lib, gnulib_lib], + dependencies : [pcre, thread_dep, libintl, librt] + libiconv + platform_deps, +@@ -250,6 +250,7 @@ libglib_dep = declare_dependency( + include_directories : [configinc, glibinc]) + + pkg.generate(libraries : libglib, ++ libraries_private : [osx_ldflags], + subdirs : ['glib-2.0'], + extra_cflags : ['-I${libdir}/glib-2.0/include'], + variables : ['bindir=' + join_paths('${prefix}', get_option('bindir')), +diff --git a/meson.build b/meson.build +index 543f91704..357dd0322 100644 +--- a/meson.build ++++ b/meson.build +@@ -494,7 +494,7 @@ if host_system == 'linux' + endif + endif + +-platform_ldflags=[] ++osx_ldflags = [] + + # Mac OS X Carbon support + glib_have_carbon = cc.compiles('''#include <Carbon/Carbon.h> +@@ -505,14 +505,11 @@ glib_have_os_x_9_or_later = false + + if glib_have_carbon + glib_conf.set('HAVE_CARBON', true) +- CARBON_LIBS='-Wl,-framework,Carbon' # FIXME: propagate to .pc files as well +- platform_ldflags += [CARBON_LIBS] ++ osx_ldflags += '-Wl,-framework,Carbon' + glib_have_os_x_9_or_later = cc.compiles('''#include <AvailabilityMacros.h> + #if MAC_OS_X_VERSION_MIN_REQUIRED < 1090 + #error Compiling for minimum OS X version before 10.9 + #endif''', name : 'OS X 9 or later') +-else +- CARBON_LIBS='' + endif + + # Mac OS X Cocoa support +@@ -524,12 +521,11 @@ glib_have_cocoa = cc.compiles('''#include <Cocoa/Cocoa.h> + + if glib_have_cocoa + glib_conf.set('HAVE_COCOA', true) +- COCOA_LIBS='-Wl,-framework,Foundation -Wl,-framework,AppKit' # FIXME: propagate to .pc files as well +- platform_ldflags += [COCOA_LIBS] +-else +- COCOA_LIBS='' ++ osx_ldflags += '-Wl,-framework,Foundation -Wl,-framework,AppKit' + endif + ++add_project_link_arguments(osx_ldflags, language : 'c') ++ + # Check for futex(2) + if cc.links('''#include <linux/futex.h> + #include <sys/syscall.h> +-- +2.17.0 + + +From 6bb223ea27ec7a2d5e9dfd041e0b0489ef492770 Mon Sep 17 00:00:00 2001 +From: Xavier Claessens <xavier.claessens@collabora.com> +Date: Fri, 6 Apr 2018 13:46:15 -0400 +Subject: [PATCH 10/24] Meson: Use cc.compute_int() instead of running our own + code + +When cross compiling we cannot run code, and meson has code to compute +int values without executing code. + +https://bugzilla.gnome.org/show_bug.cgi?id=794898 +--- + meson.build | 73 +++++++++++++++++++---------------------------------- + 1 file changed, 26 insertions(+), 47 deletions(-) + +diff --git a/meson.build b/meson.build +index 357dd0322..f9af7070e 100644 +--- a/meson.build ++++ b/meson.build +@@ -1281,54 +1281,43 @@ endif + has_winsock2 = cc.has_header('winsock2.h') + + if has_syspoll and has_systypes +- templ = '''#include<sys/poll.h> +-#include<sys/types.h> +-#include<stdio.h> +-int main(int argc, char **argv) { +- printf("%d\n", (int)@0@); +- return 0; +-}''' ++ poll_includes = ''' ++ #include<sys/poll.h> ++ #include<sys/types.h>''' + elif has_winsock2 +- templ = '''#define _WIN32_WINNT 0x0600 +-#include <stdio.h> +-#include <winsock2.h> +-int main(int argc, char **argv) { +- printf("%d\n", (int)@0@); +- return 0; +-}''' ++ poll_includes = ''' ++ #define _WIN32_WINNT 0x0600 ++ #include <winsock2.h>''' + else + # FIXME? + error('FIX POLL* defines') + endif + +-value_POLLIN = cc.run(templ.format('POLLIN'), name : 'POLLIN value').stdout().strip() +-value_POLLOUT = cc.run(templ.format('POLLOUT'), name : 'POLLOUT value').stdout().strip() +-value_POLLPRI = cc.run(templ.format('POLLPRI'), name : 'POLLPRI value').stdout().strip() +-value_POLLERR = cc.run(templ.format('POLLERR'), name : 'POLLERR value').stdout().strip() +-value_POLLHUP = cc.run(templ.format('POLLHUP'), name : 'POLLHUP value').stdout().strip() +-value_POLLNVAL = cc.run(templ.format('POLLNVAL'), name : 'POLLNVAL value').stdout().strip() +- +-glibconfig_conf.set('g_pollin', value_POLLIN) +-glibconfig_conf.set('g_pollout', value_POLLOUT) +-glibconfig_conf.set('g_pollpri', value_POLLPRI) +-glibconfig_conf.set('g_pollerr', value_POLLERR) +-glibconfig_conf.set('g_pollhup', value_POLLHUP) +-glibconfig_conf.set('g_pollnval', value_POLLNVAL) ++poll_defines = [ ++ [ 'POLLIN', 'g_pollin' ], ++ [ 'POLLOUT', 'g_pollout' ], ++ [ 'POLLPRI', 'g_pollpri' ], ++ [ 'POLLERR', 'g_pollerr' ], ++ [ 'POLLHUP', 'g_pollhup' ], ++ [ 'POLLNVAL', 'g_pollnval' ], ++] ++foreach d : poll_defines ++ val = cc.compute_int(d[0], prefix: poll_includes) ++ glibconfig_conf.set(d[1], val) ++endforeach + + # Internet address families + # FIXME: what about Cygwin (G_WITH_CYGWIN) + if host_system == 'windows' +- glib_inet_includes= ''' +-#include <winsock2.h> +-''' ++ inet_includes = ''' ++ #include <winsock2.h>''' + else +- glib_inet_includes=''' +-#include <sys/types.h> +-#include <sys/socket.h> +-''' ++ inet_includes = ''' ++ #include <sys/types.h> ++ #include <sys/socket.h>''' + endif + +-net_defines = [ ++inet_defines = [ + [ 'AF_UNIX', 'g_af_unix' ], + [ 'AF_INET', 'g_af_inet' ], + [ 'AF_INET6', 'g_af_inet6' ], +@@ -1336,18 +1325,8 @@ net_defines = [ + [ 'MSG_PEEK', 'g_msg_peek' ], + [ 'MSG_DONTROUTE', 'g_msg_dontroute' ], + ] +-foreach d : net_defines +- templ = '''@0@ +-#include <stdio.h> +-int main(int argc, char **argv) { +- printf("%d\n", (int)@1@); +- return 0; +-}''' +- # FIXME: fix for cross-compilation +- if not meson.has_exe_wrapper() +- error('Fix sys define detection for cross build') +- endif +- val = cc.run(templ.format(glib_inet_includes, d[0]), name : d[0] + ' value').stdout().strip() ++foreach d : inet_defines ++ val = cc.compute_int(d[0], prefix: inet_includes) + glibconfig_conf.set(d[1], val) + endforeach + +-- +2.17.0 + + +From fea853d2b1f0a31f486314a31f969d5e37f2cc0b Mon Sep 17 00:00:00 2001 +From: Xavier Claessens <xavier.claessens@collabora.com> +Date: Mon, 2 Apr 2018 23:01:25 -0400 +Subject: [PATCH 11/24] Meson: Get results from cross file properties if cannot + run code + +When cross compiling and not exe wrapper has been defined cc.run() raise +an exception. Avoid this by taking the value from [properties] in the +cross file and provide sensible default if the variable is not defined. + +https://bugzilla.gnome.org/show_bug.cgi?id=794898 +--- + meson.build | 53 ++++++++++++++++++++++++++++++++--------------------- + 1 file changed, 32 insertions(+), 21 deletions(-) + +diff --git a/meson.build b/meson.build +index f9af7070e..44ebf5ca6 100644 +--- a/meson.build ++++ b/meson.build +@@ -10,6 +10,8 @@ project('glib', 'c', 'cpp', + cc = meson.get_compiler('c') + cxx = meson.get_compiler('cpp') + ++cc_can_run = not meson.is_cross_build() or meson.has_exe_wrapper() ++ + if cc.get_id() == 'msvc' + # Ignore several spurious warnings for things glib does very commonly + # If a warning is completely useless and spammy, use '/wdXXXX' to suppress it +@@ -673,10 +675,15 @@ main(void) + exit(1); + }''' + +- rres = cc.run(vsnprintf_c99_test_code, name : 'C99 vsnprintf') +- if rres.compiled() and rres.returncode() == 0 +- glib_conf.set('HAVE_C99_VSNPRINTF', 1) +- have_good_vsnprintf = true ++ if cc_can_run ++ rres = cc.run(vsnprintf_c99_test_code, name : 'C99 vsnprintf') ++ if rres.compiled() and rres.returncode() == 0 ++ glib_conf.set('HAVE_C99_VSNPRINTF', 1) ++ have_good_vsnprintf = true ++ endif ++ else ++ have_good_vsnprintf = meson.get_cross_property('have_c99_vsnprintf', false) ++ glib_conf.set('HAVE_C99_VSNPRINTF', have_good_vsnprintf) + endif + + snprintf_c99_test_code = ''' +@@ -715,10 +722,15 @@ main(void) + exit(1); + }''' + +- rres = cc.run(snprintf_c99_test_code, name : 'C99 snprintf') +- if rres.compiled() and rres.returncode() == 0 +- glib_conf.set('HAVE_C99_SNPRINTF', 1) +- have_good_snprintf = true ++ if cc_can_run ++ rres = cc.run(snprintf_c99_test_code, name : 'C99 snprintf') ++ if rres.compiled() and rres.returncode() == 0 ++ glib_conf.set('HAVE_C99_SNPRINTF', 1) ++ have_good_snprintf = true ++ endif ++ else ++ have_good_snprintf = meson.get_cross_property('have_c99_snprintf', false) ++ glib_conf.set('HAVE_C99_SNPRINTF', have_good_snprintf) + endif + endif + +@@ -1219,16 +1231,13 @@ va_list_val_copy_prog = ''' + return 0; + }''' + +-# We do this in two steps so if compilation fails already it looks less alarming +-glib_va_val_copy = false +-if cc.compiles(va_list_val_copy_prog, name : 'va_lists can be copied as values') +- # FIXME: what to do when cross-compiling? +- if cc.run(va_list_val_copy_prog, name : 'va_lists can be copied as values').returncode() == 0 +- glib_va_val_copy = true +- endif ++if cc_can_run ++ rres = cc.run(va_list_val_copy_prog, name : 'va_lists can be copied as values') ++ glib_va_val_copy = rres.returncode() == 0 ++else ++ glib_va_val_copy = meson.get_cross_property('va_val_copy', true) + endif + if not glib_va_val_copy +- glib_va_val_copy = false + glib_vacopy = glib_vacopy + '\n#define G_VA_COPY_AS_ARRAY 1' + glib_conf.set('G_VA_COPY_AS_ARRAY', 1) + endif +@@ -1414,7 +1423,6 @@ else + endif + endif + +-# FIXME: how to do this when cross-compiling? + # FIXME: we should make it print the result and always return 0, so that + # the output in meson shows up as green + stack_grows_check_prog = ''' +@@ -1432,13 +1440,16 @@ stack_grows_check_prog = ''' + f (100); + return b > a ? 0 : 1; + }''' +-stack_grows_run_result = cc.run(stack_grows_check_prog, name : 'stack grows check') +-if stack_grows_run_result.compiled() and stack_grows_run_result.returncode() == 0 +- glibconfig_conf.set('G_HAVE_GROWING_STACK', 1) ++ ++if cc_can_run ++ rres = cc.run(stack_grows_check_prog, name : 'stack grows check') ++ growing_stack = rres.returncode() == 0 + else +- glibconfig_conf.set('G_HAVE_GROWING_STACK', 0) ++ growing_stack = meson.get_cross_property('growing_stack', false) + endif + ++glibconfig_conf.set('G_HAVE_GROWING_STACK', growing_stack) ++ + # Tests for iconv + # + # USE_LIBICONV_GNU: Using GNU libiconv +-- +2.17.0 + + +From bbdf3549b708135595e9ebd5e37368f8e898dc89 Mon Sep 17 00:00:00 2001 +From: Xavier Claessens <xavier.claessens@collabora.com> +Date: Wed, 28 Mar 2018 21:37:38 -0400 +Subject: [PATCH 12/24] Meson: Define G_ENABLE_DEBUG and friends + +https://bugzilla.gnome.org/show_bug.cgi?id=794790 +--- + meson.build | 10 ++++++++++ + 1 file changed, 10 insertions(+) + +diff --git a/meson.build b/meson.build +index 44ebf5ca6..0f43cb6b9 100644 +--- a/meson.build ++++ b/meson.build +@@ -2,6 +2,7 @@ project('glib', 'c', 'cpp', + version : '2.56.1', + meson_version : '>= 0.45.0', + default_options : [ ++ 'buildtype=debugoptimized', + 'warning_level=1', + 'c_std=gnu89' + ] +@@ -149,6 +150,15 @@ glibconfig_conf.set('glib_os', glib_os) + # for dependencies that don't normally come with pkg-config files for Visual Studio builds + buildtype = get_option('buildtype') + ++glib_debug_cflags = [] ++if buildtype.startswith('debug') ++ glib_debug_cflags += ['-DG_ENABLE_DEBUG'] ++elif buildtype == 'release' ++ glib_debug_cflags += ['-DG_DISABLE_CAST_CHECKS'] ++endif ++ ++add_project_arguments(glib_debug_cflags, language: 'c') ++ + # check for header files + + headers = [ +-- +2.17.0 + + +From 78f517328bc7646ab9d4d71584f1ba832b127fa3 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?=D0=A0=D1=83=D1=81=D0=BB=D0=B0=D0=BD=20=D0=98=D0=B6=D0=B1?= + =?UTF-8?q?=D1=83=D0=BB=D0=B0=D1=82=D0=BE=D0=B2?= <lrn1986@gmail.com> +Date: Sat, 31 Mar 2018 13:59:55 +0000 +Subject: [PATCH 13/24] Force W32-specific POLL* constant values in meson + +The winsock2-using test does work perfectly, however this is a new +thing that didn't exist in autotools-based builds of glib in the past. +Autotools builds used the generic case where values were just defined +to some agreed-upon numbers, and this is what all autotools-glib +binaries and binaries built against autotools-glib (since these +values go into public glibconfig.h header) use. At least one value, +G_POLLIN, is different, thus breaking ABI if some binaries are +built with autotools and the others are built with meson. + +Force meson buildscript to use the same G_POLL* constant values +for Windows builds that autotools builds use. + +https://bugzilla.gnome.org/show_bug.cgi?id=794687 +--- + meson.build | 33 +++++++++++++++++++++++---------- + 1 file changed, 23 insertions(+), 10 deletions(-) + +diff --git a/meson.build b/meson.build +index 0f43cb6b9..375537afc 100644 +--- a/meson.build ++++ b/meson.build +@@ -1313,17 +1313,30 @@ else + endif + + poll_defines = [ +- [ 'POLLIN', 'g_pollin' ], +- [ 'POLLOUT', 'g_pollout' ], +- [ 'POLLPRI', 'g_pollpri' ], +- [ 'POLLERR', 'g_pollerr' ], +- [ 'POLLHUP', 'g_pollhup' ], +- [ 'POLLNVAL', 'g_pollnval' ], ++ [ 'POLLIN', 'g_pollin', 1 ], ++ [ 'POLLOUT', 'g_pollout', 4 ], ++ [ 'POLLPRI', 'g_pollpri', 2 ], ++ [ 'POLLERR', 'g_pollerr', 8 ], ++ [ 'POLLHUP', 'g_pollhup', 16 ], ++ [ 'POLLNVAL', 'g_pollnval', 32 ], + ] +-foreach d : poll_defines +- val = cc.compute_int(d[0], prefix: poll_includes) +- glibconfig_conf.set(d[1], val) +-endforeach ++ ++if has_syspoll and has_systypes ++ foreach d : poll_defines ++ val = cc.compute_int(d[0], prefix: poll_includes) ++ glibconfig_conf.set(d[1], val) ++ endforeach ++elif has_winsock2 ++ # Due to a missed bug in configure.ac the poll test ++ # never succeeded on Windows and used some pre-defined ++ # values as a fallback. Keep using them to maintain ++ # ABI compatibility with autotools builds of glibs ++ # and with *any* glib-using code compiled against them, ++ # since these values end up in a public header glibconfig.h. ++ foreach d : poll_defines ++ glibconfig_conf.set(d[1], d[2]) ++ endforeach ++endif + + # Internet address families + # FIXME: what about Cygwin (G_WITH_CYGWIN) +-- +2.17.0 + + +From 41cbd73be8a00863d083415f1f210f934ce86c38 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?=D0=A0=D1=83=D1=81=D0=BB=D0=B0=D0=BD=20=D0=98=D0=B6=D0=B1?= + =?UTF-8?q?=D1=83=D0=BB=D0=B0=D1=82=D0=BE=D0=B2?= <lrn1986@gmail.com> +Date: Tue, 10 Apr 2018 22:46:53 +0000 +Subject: [PATCH 14/24] Link gdatetime test to libintl + +gdatetime testcase uses glib (which uses libintl), but *alsi* calls +libintl functions on its own, as part of the testing process. +Therefore it must be linked to libintl like any other program that +uses it. + +https://bugzilla.gnome.org/show_bug.cgi?id=794556 +--- + glib/tests/meson.build | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/glib/tests/meson.build b/glib/tests/meson.build +index 4ac3620b8..7df9b23ee 100644 +--- a/glib/tests/meson.build ++++ b/glib/tests/meson.build +@@ -110,6 +110,9 @@ foreach test_name : glib_tests + if test_name == 'regex' + deps += [pcre] + endif ++ if test_name == 'gdatetime' ++ deps += [libintl] ++ endif + exe = executable(test_name, '@0@.c'.format(test_name), + c_args : ['-DPCRE_STATIC'] + test_cargs, + dependencies : deps, +-- +2.17.0 + + +From 0cfaf08db805f225af44f0cd0631402e23dd697d Mon Sep 17 00:00:00 2001 +From: Nirbheek Chauhan <nirbheek@centricular.com> +Date: Mon, 7 May 2018 15:07:47 +0530 +Subject: [PATCH 15/24] config.h.meson: Add some missing #mesondefines + +The compiler checks were being completely ignored. +--- + config.h.meson | 9 +++++++++ + 1 file changed, 9 insertions(+) + +diff --git a/config.h.meson b/config.h.meson +index 57e1ef5fb..b780a3e36 100644 +--- a/config.h.meson ++++ b/config.h.meson +@@ -226,6 +226,12 @@ + /* Define to 1 if you have the `kqueue' function. */ + #mesondefine HAVE_KQUEUE + ++/* Check for nl_langinfo and abbreviated alternative month names */ ++#mesondefine HAVE_LANGINFO_ABALTMON ++ ++/* Check for nl_langinfo and alternative month names */ ++#mesondefine HAVE_LANGINFO_ALTMON ++ + /* Define if you have <langinfo.h> and nl_langinfo(CODESET). */ + #mesondefine HAVE_LANGINFO_CODESET + +@@ -629,6 +635,9 @@ + /* Define if you have the 'wchar_t' type. */ + #mesondefine HAVE_WCHAR_T + ++/* Define if you Have wcrtomb() */ ++#mesondefine HAVE_WCRTOMB ++ + /* Define to 1 if you have the `wcslen' function. */ + #mesondefine HAVE_WCSLEN + +-- +2.17.0 + + +From 984a843463efd75aa5afb4f3f74c342e55a7f94a Mon Sep 17 00:00:00 2001 +From: Nirbheek Chauhan <nirbheek@centricular.com> +Date: Mon, 7 May 2018 15:08:51 +0530 +Subject: [PATCH 16/24] meson: Add name for atomic test so it shows up in + configure + +--- + meson.build | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/meson.build b/meson.build +index 375537afc..39e5f33ed 100644 +--- a/meson.build ++++ b/meson.build +@@ -1387,7 +1387,7 @@ atomictest = '''void func() { + __sync_bool_compare_and_swap (&atomic, 2, 3); + } + ''' +-if cc.compiles(atomictest) ++if cc.compiles(atomictest, name : 'atomic ops') + glibconfig_conf.set('G_ATOMIC_LOCK_FREE', true) + else + if host_machine.cpu_family() == 'x86' and cc.compiles(atomictest, args : '-march=i486') +-- +2.17.0 + + +From 8d826d1e9bcb8bd21ef34e532191df39365a1e01 Mon Sep 17 00:00:00 2001 +From: Nirbheek Chauhan <nirbheek@centricular.com> +Date: Mon, 7 May 2018 15:19:36 +0530 +Subject: [PATCH 17/24] meson: Fix checks for posix_memalign and stpcpy + +The 'no-builtin' checks were just plain wrong. For accurate detection of +functions, use has_function with a header in the prefix. This fixes +posix_memalign detection on Android and on MinGW. + +This also allows cross-files to override the result by setting +`has_function_stpcpy = false`, etc in [extra properties] +--- + meson.build | 12 ++++++++++-- + 1 file changed, 10 insertions(+), 2 deletions(-) + +diff --git a/meson.build b/meson.build +index 39e5f33ed..f4bf5b89b 100644 +--- a/meson.build ++++ b/meson.build +@@ -310,7 +310,6 @@ endif + functions = [ + 'alloca', + 'mmap', +- 'posix_memalign', + 'memalign', + 'valloc', + 'fsync', +@@ -322,7 +321,6 @@ functions = [ + 'lstat', + 'strsignal', + 'vsnprintf', +- 'stpcpy', + 'poll', + 'vasprintf', + 'setenv', +@@ -413,6 +411,16 @@ foreach f : functions + endif + endforeach + ++# Check that stpcpy() is usable; must use header ++if cc.has_function('stpcpy', prefix : '#include <string.h>') ++ glib_conf.set('HAVE_STPCPY', 1) ++endif ++ ++# Check that posix_memalign() is usable; must use header ++if cc.has_function('posix_memalign', prefix : '#include <stdlib.h>') ++ glib_conf.set('HAVE_POSIX_MEMALIGN', 1) ++endif ++ + # Check whether strerror_r returns char * + if have_func_strerror_r + if cc.compiles('''#define _GNU_SOURCE +-- +2.17.0 + + +From 299cfad74bb6114984a7b546eced45665e1f905f Mon Sep 17 00:00:00 2001 +From: Nirbheek Chauhan <nirbheek@centricular.com> +Date: Wed, 9 May 2018 17:13:34 +0530 +Subject: [PATCH 18/24] meson: Fix atomic ops check + +It should link, not just compile. This is what configure does too. +--- + meson.build | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/meson.build b/meson.build +index f4bf5b89b..1fc8f339d 100644 +--- a/meson.build ++++ b/meson.build +@@ -1395,10 +1395,10 @@ atomictest = '''void func() { + __sync_bool_compare_and_swap (&atomic, 2, 3); + } + ''' +-if cc.compiles(atomictest, name : 'atomic ops') ++if cc.links(atomictest, name : 'atomic ops') + glibconfig_conf.set('G_ATOMIC_LOCK_FREE', true) + else +- if host_machine.cpu_family() == 'x86' and cc.compiles(atomictest, args : '-march=i486') ++ if host_machine.cpu_family() == 'x86' and cc.links(atomictest, args : '-march=i486') + error('GLib must be built with -march=i486 or later.') + endif + glibconfig_conf.set('G_ATOMIC_LOCK_FREE', false) +-- +2.17.0 + + +From c44d4eaa205797751c75f2c87433ce97647b3b5c Mon Sep 17 00:00:00 2001 +From: Xavier Claessens <xavier.claessens@collabora.com> +Date: Sun, 13 May 2018 19:22:51 -0400 +Subject: [PATCH 19/24] Meson: libintl is a public dependency of glib-2.0 + +On non-glibc platforms gettext is provided by extra libintl dependency. +We wrongly thought libintl is an internal dependency and applications +needs to explicitly link on it, but turns out that breaks many +applications and with autotools the .pc generated actually has -lintl in +public "Libs:". + +https://bugzilla.gnome.org/show_bug.cgi?id=796085 +--- + gio/meson.build | 16 ++++++++-------- + gio/tests/meson.build | 1 - + glib/meson.build | 12 ++++++------ + gobject/meson.build | 5 +++-- + 4 files changed, 17 insertions(+), 17 deletions(-) + +diff --git a/gio/meson.build b/gio/meson.build +index 9e663d6ef..c02170eaf 100644 +--- a/gio/meson.build ++++ b/gio/meson.build +@@ -796,7 +796,7 @@ libgio = library('gio-2.0', + link_with : internal_deps, + #libgio_2_0_la_LDFLAGS = $(GLIB_LINK_FLAGS)', + # '$(gio_win32_res_ldflag)', +- dependencies : [libintl, libz_dep, libdl_dep, libmount_dep, libglib_dep, ++ dependencies : [libz_dep, libdl_dep, libmount_dep, libglib_dep, + libgobject_dep, libgmodule_dep, selinux_dep, xattr_dep, + platform_deps, network_libs], + c_args : gio_c_args, +@@ -896,13 +896,13 @@ executable('gio', gio_tool_sources, + c_args : gio_c_args, + # intl.lib is not compatible with SAFESEH + link_args : noseh_link_args, +- dependencies : [libintl, libgio_dep, libgobject_dep, libgmodule_dep, libglib_dep]) ++ dependencies : [libgio_dep, libgobject_dep, libgmodule_dep, libglib_dep]) + + executable('gresource', 'gresource-tool.c', + install : true, + # intl.lib is not compatible with SAFESEH + link_args : noseh_link_args, +- dependencies : [libelf, libintl, libgio_dep, libgobject_dep, libgmodule_dep, libglib_dep]) ++ dependencies : [libelf, libgio_dep, libgobject_dep, libgmodule_dep, libglib_dep]) + + executable('gio-querymodules', 'gio-querymodules.c', 'giomodule-priv.c', + install : true, +@@ -916,7 +916,7 @@ glib_compile_schemas = executable('glib-compile-schemas', + install : true, + # intl.lib is not compatible with SAFESEH + link_args : noseh_link_args, +- dependencies : [libintl, libgio_dep, libgobject_dep, libgmodule_dep, libglib_dep]) ++ dependencies : [libgio_dep, libgobject_dep, libgmodule_dep, libglib_dep]) + + glib_compile_resources = executable('glib-compile-resources', + [gconstructor_as_data_h, 'gvdb/gvdb-builder.c', 'glib-compile-resources.c'], +@@ -924,14 +924,14 @@ glib_compile_resources = executable('glib-compile-resources', + c_args : gio_c_args, + # intl.lib is not compatible with SAFESEH + link_args : noseh_link_args, +- dependencies : [libintl, libgio_dep, libgobject_dep, libgmodule_dep, libglib_dep]) ++ dependencies : [libgio_dep, libgobject_dep, libgmodule_dep, libglib_dep]) + + executable('gsettings', 'gsettings-tool.c', + install : true, + c_args : gio_c_args, + # intl.lib is not compatible with SAFESEH + link_args : noseh_link_args, +- dependencies : [libintl, libgio_dep, libgobject_dep, libgmodule_dep, libglib_dep]) ++ dependencies : [libgio_dep, libgobject_dep, libgmodule_dep, libglib_dep]) + install_data('gschema.dtd', + install_dir : join_paths(get_option('datadir'), 'glib-2.0/schemas')) + +@@ -943,7 +943,7 @@ executable('gdbus', 'gdbus-tool.c', + c_args : gio_c_args, + # intl.lib is not compatible with SAFESEH + link_args : noseh_link_args, +- dependencies : [libintl, libgio_dep, libgobject_dep, libgmodule_dep, libglib_dep]) ++ dependencies : [libgio_dep, libgobject_dep, libgmodule_dep, libglib_dep]) + + if host_system != 'windows' + executable('gapplication', 'gapplication-tool.c', +@@ -951,7 +951,7 @@ if host_system != 'windows' + c_args : gio_c_args, + # intl.lib is not compatible with SAFESEH + link_args : noseh_link_args, +- dependencies : [libintl, libgio_dep, libgobject_dep, libgmodule_dep, libglib_dep]) ++ dependencies : [libgio_dep, libgobject_dep, libgmodule_dep, libglib_dep]) + endif + + if enable_systemtap +diff --git a/gio/tests/meson.build b/gio/tests/meson.build +index 5aceb7c26..f66b9ed22 100644 +--- a/gio/tests/meson.build ++++ b/gio/tests/meson.build +@@ -3,7 +3,6 @@ common_gio_tests_deps = [ + libgmodule_dep, + libgobject_dep, + libgio_dep, +- libintl + ] + + subdir('gdbus-object-manager-example') +diff --git a/glib/meson.build b/glib/meson.build +index 9d186201d..ea9bf41ce 100644 +--- a/glib/meson.build ++++ b/glib/meson.build +@@ -245,11 +245,11 @@ libglib_dep = declare_dependency( + link_with : libglib, + # thread_dep doesn't get pulled in from libglib atm, + # see https://github.com/mesonbuild/meson/issues/1426 +- dependencies : [thread_dep], ++ dependencies : [thread_dep, libintl], + # We sadly need to export configinc here because everyone includes <glib/*.h> + include_directories : [configinc, glibinc]) + +-pkg.generate(libraries : libglib, ++pkg.generate(libraries : [libglib, libintl], + libraries_private : [osx_ldflags], + subdirs : ['glib-2.0'], + extra_cflags : ['-I${libdir}/glib-2.0/include'], +@@ -271,23 +271,23 @@ if host_system == 'windows' + install : true, + gui_app : true, + include_directories : configinc, +- dependencies : [libintl, libglib_dep]) ++ dependencies : [libglib_dep]) + executable('gspawn-win32-helper-console', 'gspawn-win32-helper.c', + install : true, + c_args : ['-DHELPER_CONSOLE'], + include_directories : configinc, +- dependencies : [libintl, libglib_dep]) ++ dependencies : [libglib_dep]) + else + executable('gspawn-win64-helper', 'gspawn-win32-helper.c', + install : true, + gui_app : true, + include_directories : configinc, +- dependencies : [libintl, libglib_dep]) ++ dependencies : [libglib_dep]) + executable('gspawn-win64-helper-console', 'gspawn-win32-helper.c', + install : true, + c_args : ['-DHELPER_CONSOLE'], + include_directories : configinc, +- dependencies : [libintl, libglib_dep]) ++ dependencies : [libglib_dep]) + endif + else + gtester = executable('gtester', 'gtester.c', +diff --git a/gobject/meson.build b/gobject/meson.build +index 98e306d7f..1bf0e005d 100644 +--- a/gobject/meson.build ++++ b/gobject/meson.build +@@ -68,8 +68,9 @@ libgobject = library('gobject-2.0', + soversion : soversion, + install : true, + include_directories : [configinc], +- dependencies : [libintl, libffi_dep, libglib_dep], +- c_args : ['-DG_LOG_DOMAIN="GLib-GObject"', '-DGOBJECT_COMPILATION'] + glib_hidden_visibility_args) ++ dependencies : [libffi_dep, libglib_dep], ++ c_args : ['-DG_LOG_DOMAIN="GLib-GObject"', '-DGOBJECT_COMPILATION'] + glib_hidden_visibility_args, ++) + + pkg.generate(libraries : libgobject, + requires : ['glib-2.0'], +-- +2.17.0 + + +From a40fc3d549736d35d2af354e16f50ef85aee0304 Mon Sep 17 00:00:00 2001 +From: Nirbheek Chauhan <nirbheek@centricular.com> +Date: Wed, 16 May 2018 14:38:20 +0530 +Subject: [PATCH 20/24] Revert "build: meson: add warning flags" + +This reverts commit 9d24c8b223ec4253e3c6a2e14001de61fa993dbb. + +Breaks build with clang on macOS +--- + meson.build | 21 --------------------- + 1 file changed, 21 deletions(-) + +diff --git a/meson.build b/meson.build +index 1fc8f339d..4c2daede2 100644 +--- a/meson.build ++++ b/meson.build +@@ -281,27 +281,6 @@ foreach m : struct_members + endif + endforeach + +-# Compiler flags +-if cc.get_id() == 'gcc' or cc.get_id() == 'clang' +- test_c_args = [ +- '-Wall', +- '-Wduplicated-branches', +- '-Wstrict-prototypes', +- '-Werror=declaration-after-statement', +- '-Werror=format=2', +- '-Werror=format-security', +- '-Werror=implicit-function-declaration', +- '-Werror=init-self', +- '-Werror=missing-include-dirs', +- '-Werror=missing-prototypes', +- '-Werror=pointer-arith', +- ] +-else +- test_c_args = [] +-endif +- +-add_project_arguments(cc.get_supported_arguments(test_c_args), language: 'c') +- + # Windows Support (Vista+) + if host_system == 'windows' + glib_conf.set('_WIN32_WINNT', '0x0601') +-- +2.17.0 + + +From 6e522714ba2f08fd3705d6cb5302f5e6d56c4868 Mon Sep 17 00:00:00 2001 +From: Philip Withnall <withnall@endlessm.com> +Date: Wed, 16 May 2018 12:16:17 +0100 +Subject: [PATCH 21/24] build: Fix test for G_ATOMIC_LOCK_FREE in meson.build + +Commit 3e96523e6b did not entirely fix the test, as the compiled test +code did not have a main() function, so failed to link with: + + /usr/lib/gcc/x86_64-redhat-linux/7/../../../../lib64/crt1.o: In function `_start': +(.text+0x20): undefined reference to `main' +collect2: error: ld returned 1 exit status + +This caused an invalid mixtures of builtin and non-builtin atomics/locks +to be used, which caused deadlocks in a number of tests. + +Fix the atomic ops test in meson.build, and the unit tests all start +working again. + +Signed-off-by: Philip Withnall <withnall@endlessm.com> + +https://bugzilla.gnome.org/show_bug.cgi?id=796164 +--- + meson.build | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/meson.build b/meson.build +index 4c2daede2..608d2c426 100644 +--- a/meson.build ++++ b/meson.build +@@ -1369,9 +1369,10 @@ glibconfig_conf.set('G_ATOMIC_OP_MEMORY_BARRIER_NEEDED', glib_memory_barrier_nee + # to abort and advise the user to fix their CFLAGS. It's better to do + # that then to silently fall back on emulated atomic ops just because + # the user had the wrong build environment. +-atomictest = '''void func() { ++atomictest = '''int main() { + volatile int atomic = 2; + __sync_bool_compare_and_swap (&atomic, 2, 3); ++ return 0; + } + ''' + if cc.links(atomictest, name : 'atomic ops') +-- +2.17.0 + + +From 979a5635a5fa2cd4066230d81e226a8dccc4df4c Mon Sep 17 00:00:00 2001 +From: Nirbheek Chauhan <nirbheek@centricular.com> +Date: Wed, 16 May 2018 14:26:11 +0530 +Subject: [PATCH 22/24] meson: Fix error message for iconv detection + +--- + meson.build | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/meson.build b/meson.build +index 608d2c426..11ae73919 100644 +--- a/meson.build ++++ b/meson.build +@@ -1496,7 +1496,7 @@ else + endif + + if not found_iconv +- error('No iconv() implementation found in C library or libiconv') ++ error('iconv implementation "@0@" not found'.format(iconv_opt)) + endif + + endif +-- +2.17.0 + + +From 8ce9fd057fe865115c46ee27bdc239989ffc274e Mon Sep 17 00:00:00 2001 +From: Nirbheek Chauhan <nirbheek@centricular.com> +Date: Sun, 6 May 2018 15:29:09 +0530 +Subject: [PATCH 23/24] gwin32: Fix detection of MinGW32 vs MinGW-w64 + +__MINGW32__ is defined on all MinGW variants including MinGW-w64. +__MINGW64_VERSION_MAJOR is only defined on MinGW-w64. + +This difference is important because on MinGW-w64 we must #include +winternl.h because including ntdef.h results in compiler errors +about symbol redefinition, and the header warns that it is deprecated +and may be removed in the future. + +https://bugzilla.gnome.org/show_bug.cgi?id=795849 +--- + glib/gwin32.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/glib/gwin32.c b/glib/gwin32.c +index cc6da5f99..a176514b1 100644 +--- a/glib/gwin32.c ++++ b/glib/gwin32.c +@@ -59,8 +59,8 @@ + #ifdef _MSC_VER + #pragma comment (lib, "ntoskrnl.lib") + #endif +-#elif defined (__MINGW32__) +-/* mingw-w64, not MinGW, has winternl.h */ ++#elif defined(__MINGW32__) && !defined(__MINGW64_VERSION_MAJOR) ++/* mingw-w64 must use winternl.h, but not MinGW */ + #include <ntdef.h> + #else + #include <winternl.h> +-- +2.17.0 + + +From 66c34c6ec2dcf60dab876659e0019b3f153fa1ea Mon Sep 17 00:00:00 2001 +From: Xavier Claessens <xavier.claessens@collabora.com> +Date: Fri, 20 Apr 2018 12:10:18 -0400 +Subject: [PATCH 24/24] Tests: gsubprocess: Do not use stdin/stdout variables + +https://bugzilla.gnome.org/show_bug.cgi?id=795406 +--- + gio/tests/gsubprocess.c | 54 ++++++++++++++++++++--------------------- + 1 file changed, 27 insertions(+), 27 deletions(-) + +diff --git a/gio/tests/gsubprocess.c b/gio/tests/gsubprocess.c +index ad65a1df7..ac7051d6d 100644 +--- a/gio/tests/gsubprocess.c ++++ b/gio/tests/gsubprocess.c +@@ -333,7 +333,7 @@ test_echo1 (void) + GError **error = &local_error; + GSubprocess *proc; + GPtrArray *args; +- GInputStream *stdout; ++ GInputStream *stdout_stream; + gchar *result; + + args = get_test_subprocess_args ("echo", "hello", "world!", NULL); +@@ -341,9 +341,9 @@ test_echo1 (void) + g_ptr_array_free (args, TRUE); + g_assert_no_error (local_error); + +- stdout = g_subprocess_get_stdout_pipe (proc); ++ stdout_stream = g_subprocess_get_stdout_pipe (proc); + +- result = splice_to_string (stdout, error); ++ result = splice_to_string (stdout_stream, error); + g_assert_no_error (local_error); + + g_assert_cmpstr (result, ==, "hello" LINEEND "world!" LINEEND); +@@ -360,7 +360,7 @@ test_echo_merged (void) + GError **error = &local_error; + GSubprocess *proc; + GPtrArray *args; +- GInputStream *stdout; ++ GInputStream *stdout_stream; + gchar *result; + + args = get_test_subprocess_args ("echo-stdout-and-stderr", "merge", "this", NULL); +@@ -370,8 +370,8 @@ test_echo_merged (void) + g_ptr_array_free (args, TRUE); + g_assert_no_error (local_error); + +- stdout = g_subprocess_get_stdout_pipe (proc); +- result = splice_to_string (stdout, error); ++ stdout_stream = g_subprocess_get_stdout_pipe (proc); ++ result = splice_to_string (stdout_stream, error); + g_assert_no_error (local_error); + + g_assert_cmpstr (result, ==, "merge\nmerge\nthis\nthis\n"); +@@ -1087,7 +1087,7 @@ test_env (void) + GSubprocessLauncher *launcher; + GSubprocess *proc; + GPtrArray *args; +- GInputStream *stdout; ++ GInputStream *stdout_stream; + gchar *result; + gchar *envp[] = { "ONE=1", "TWO=1", "THREE=3", "FOUR=1", NULL }; + gchar **split; +@@ -1106,9 +1106,9 @@ test_env (void) + g_ptr_array_free (args, TRUE); + g_assert_no_error (local_error); + +- stdout = g_subprocess_get_stdout_pipe (proc); ++ stdout_stream = g_subprocess_get_stdout_pipe (proc); + +- result = splice_to_string (stdout, error); ++ result = splice_to_string (stdout_stream, error); + split = g_strsplit (result, "\n", -1); + g_assert_cmpstr (g_environ_getenv (split, "ONE"), ==, "1"); + g_assert_cmpstr (g_environ_getenv (split, "TWO"), ==, "2"); +@@ -1131,7 +1131,7 @@ test_env_inherit (void) + GSubprocessLauncher *launcher; + GSubprocess *proc; + GPtrArray *args; +- GInputStream *stdout; ++ GInputStream *stdout_stream; + gchar *result; + gchar **split; + +@@ -1153,9 +1153,9 @@ test_env_inherit (void) + g_ptr_array_free (args, TRUE); + g_assert_no_error (local_error); + +- stdout = g_subprocess_get_stdout_pipe (proc); ++ stdout_stream = g_subprocess_get_stdout_pipe (proc); + +- result = splice_to_string (stdout, error); ++ result = splice_to_string (stdout_stream, error); + split = g_strsplit (result, "\n", -1); + g_assert_null (g_environ_getenv (split, "TEST_ENV_INHERIT1")); + g_assert_cmpstr (g_environ_getenv (split, "TEST_ENV_INHERIT2"), ==, "2"); +@@ -1175,7 +1175,7 @@ test_cwd (void) + GSubprocessLauncher *launcher; + GSubprocess *proc; + GPtrArray *args; +- GInputStream *stdout; ++ GInputStream *stdout_stream; + gchar *result; + const char *basename; + +@@ -1188,9 +1188,9 @@ test_cwd (void) + g_ptr_array_free (args, TRUE); + g_assert_no_error (local_error); + +- stdout = g_subprocess_get_stdout_pipe (proc); ++ stdout_stream = g_subprocess_get_stdout_pipe (proc); + +- result = splice_to_string (stdout, error); ++ result = splice_to_string (stdout_stream, error); + + basename = g_strrstr (result, "/"); + g_assert (basename != NULL); +@@ -1211,7 +1211,7 @@ test_stdout_file (void) + GPtrArray *args; + GFile *tmpfile; + GFileIOStream *iostream; +- GOutputStream *stdin; ++ GOutputStream *stdin_stream; + const char *test_data = "this is some test data\n"; + char *tmp_contents; + char *tmp_file_path; +@@ -1229,12 +1229,12 @@ test_stdout_file (void) + g_ptr_array_free (args, TRUE); + g_assert_no_error (local_error); + +- stdin = g_subprocess_get_stdin_pipe (proc); ++ stdin_stream = g_subprocess_get_stdin_pipe (proc); + +- g_output_stream_write_all (stdin, test_data, strlen (test_data), NULL, NULL, error); ++ g_output_stream_write_all (stdin_stream, test_data, strlen (test_data), NULL, NULL, error); + g_assert_no_error (local_error); + +- g_output_stream_close (stdin, NULL, error); ++ g_output_stream_close (stdin_stream, NULL, error); + g_assert_no_error (local_error); + + g_subprocess_wait_check (proc, NULL, error); +@@ -1264,7 +1264,7 @@ test_stdout_fd (void) + GFile *tmpfile; + GFileIOStream *iostream; + GFileDescriptorBased *descriptor_stream; +- GOutputStream *stdin; ++ GOutputStream *stdin_stream; + const char *test_data = "this is some test data\n"; + char *tmp_contents; + +@@ -1281,12 +1281,12 @@ test_stdout_fd (void) + + g_clear_object (&iostream); + +- stdin = g_subprocess_get_stdin_pipe (proc); ++ stdin_stream = g_subprocess_get_stdin_pipe (proc); + +- g_output_stream_write_all (stdin, test_data, strlen (test_data), NULL, NULL, error); ++ g_output_stream_write_all (stdin_stream, test_data, strlen (test_data), NULL, NULL, error); + g_assert_no_error (local_error); + +- g_output_stream_close (stdin, NULL, error); ++ g_output_stream_close (stdin_stream, NULL, error); + g_assert_no_error (local_error); + + g_subprocess_wait_check (proc, NULL, error); +@@ -1320,7 +1320,7 @@ test_child_setup (void) + GPtrArray *args; + GFile *tmpfile; + GFileIOStream *iostream; +- GOutputStream *stdin; ++ GOutputStream *stdin_stream; + const char *test_data = "this is some test data\n"; + char *tmp_contents; + int fd; +@@ -1339,12 +1339,12 @@ test_child_setup (void) + + g_clear_object (&iostream); + +- stdin = g_subprocess_get_stdin_pipe (proc); ++ stdin_stream = g_subprocess_get_stdin_pipe (proc); + +- g_output_stream_write_all (stdin, test_data, strlen (test_data), NULL, NULL, error); ++ g_output_stream_write_all (stdin_stream, test_data, strlen (test_data), NULL, NULL, error); + g_assert_no_error (local_error); + +- g_output_stream_close (stdin, NULL, error); ++ g_output_stream_close (stdin_stream, NULL, error); + g_assert_no_error (local_error); + + g_subprocess_wait_check (proc, NULL, error); +-- +2.17.0 + |