From 04da3756b616c3bdbced49e74c312f1c3b6c6622 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89rico=20Rolim?= Date: Wed, 13 Jan 2021 17:37:28 -0300 Subject: [PATCH 1/4] Revert "build-style/meson.sh: drop unneeded AR export" This reverts commit 2163ca2d033f0165990cb66af88ed216e9b17046. Removing `export AR=gcc-ar` was apparently done based on the assumption that the linked issue (https://github.com/mesonbuild/meson/issues/1646) had been solved completely on meson's side. Instead, their solution, seen in https://github.com/void-linux/void-packages/pull/2815, had been to force gcc-ar for linking static libraries; by exporting `AR=ar`, we were accidentally breaking static libraries when LTO is enabled. This was noticed by leah while we were trying to build qemu-user-static using the normal libglib-devel package (built with meson, which for us defaults to enabling LTO). Unfortunately, while correct, this change wasn't enough to fix the static glib build, which had to resort to disabling LTO. --- common/build-style/meson.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/common/build-style/meson.sh b/common/build-style/meson.sh index 6eb2dc530da..b1eddda36e7 100644 --- a/common/build-style/meson.sh +++ b/common/build-style/meson.sh @@ -92,6 +92,14 @@ do_configure() { configure_args+=" --cross-file=${meson_crossfile}" fi + # binutils ar needs a plugin when LTO is used on static libraries, so we + # have to use the gcc-ar wrapper that calls the correct plugin. + # As seen in https://github.com/mesonbuild/meson/issues/1646 (and its + # solution, https://github.com/mesonbuild/meson/pull/1649), meson fixed + # issues with static libraries + LTO by defaulting to gcc-ar themselves. + # We also force gcc-ar usage in the crossfile above. + export AR="gcc-ar" + ${meson_cmd} \ --prefix=/usr \ --libdir=/usr/lib${XBPS_TARGET_WORDSIZE} \ From 66a005d425a4d16f4497a78c635757e9a07361b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89rico=20Rolim?= Date: Wed, 13 Jan 2021 11:36:06 -0300 Subject: [PATCH 2/4] qemu-user-static: update to 5.2.0. Also, move from libglib-static to libglib-devel, which now includes static versions of each library. Pick up tricks from qemu for cross compilation. --- srcpkgs/qemu-user-static/template | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/srcpkgs/qemu-user-static/template b/srcpkgs/qemu-user-static/template index 608dc27d982..f2c0d6a1d91 100644 --- a/srcpkgs/qemu-user-static/template +++ b/srcpkgs/qemu-user-static/template @@ -1,16 +1,18 @@ # Template file for 'qemu-user-static' +# This package should be updated together with qemu pkgname=qemu-user-static -version=5.1.0 +version=5.2.0 revision=1 wrksrc="qemu-${version}" -hostmakedepends="pkg-config automake python3" -makedepends="dtc-devel libglib-static pixman-devel libuuid-devel" +build_style=configure +hostmakedepends="pkg-config automake python3 ninja" +makedepends="dtc-devel libglib-devel pixman-devel libuuid-devel" short_desc="QEMU User-mode emulators (statically compiled)" maintainer="Orphaned " license="GPL-2.0-or-later, LGPL-2.1-or-later" homepage="https://www.qemu.org" distfiles="https://wiki.qemu.org/download/qemu-${version}.tar.bz2" -checksum=8314b6e5fcc7bf9fa3915d504de6586a69cba30ffa27cbe9ba85d2cb9987fb3a +checksum=7bd9334c02edaf02f5b0b52beb19fe7f72556c3ca0180e20f0095f0ef2f25f14 _fmts="aarch64 alpha arm armeb cris i386 m68k microblaze mips mipsel mips64 mips64el ppc ppc64 ppc64abi32 ppc64le s390x sh4 sh4eb sparc sparc32plus sparc64 x86_64" @@ -79,20 +81,18 @@ done binfmts="${binfmts%?}" -post_extract() { - sed -i 's/__u64/unsigned long/' linux-user/host/aarch64/hostdep.h -} - do_configure() { + if [ "$CROSS_BUILD" ]; then + _args="--cross-prefix=${XBPS_CROSS_TRIPLET}-" + export LIBTOOL=libtool + fi + unset CPP + ./configure --prefix=/usr --sysconfdir=/etc --libexecdir=/usr/libexec \ --disable-kvm --disable-vnc-png \ --disable-virtfs --disable-fdt --disable-seccomp \ --enable-linux-user --disable-system \ - --static -} - -do_build() { - make ${makejobs} LDFLAGS="-static -lrt -luuid" + --static ${_args} } do_install() { From 307999a4fdd666cacd250a66670cbb802aa546f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89rico=20Rolim?= Date: Wed, 10 Feb 2021 23:19:15 -0300 Subject: [PATCH 3/4] qemu: remove unnecessary vsed and add comment about qemu-user-static. It's important to update the two packages together, since they share the patches folder. --- srcpkgs/qemu/patches/musl-initialize-msghdr.patch | 15 +++++++++++++++ srcpkgs/qemu/template | 5 +---- 2 files changed, 16 insertions(+), 4 deletions(-) create mode 100644 srcpkgs/qemu/patches/musl-initialize-msghdr.patch diff --git a/srcpkgs/qemu/patches/musl-initialize-msghdr.patch b/srcpkgs/qemu/patches/musl-initialize-msghdr.patch new file mode 100644 index 00000000000..c195f0c0b1f --- /dev/null +++ b/srcpkgs/qemu/patches/musl-initialize-msghdr.patch @@ -0,0 +1,15 @@ +Source: https://github.com/void-linux/void-packages/issues/23557 + +diff --git linux-user/syscall.c linux-user/syscall.c +index 945fc25..8d8b68a 100644 +--- linux-user/syscall.c ++++ linux-user/syscall.c +@@ -3071,7 +3071,7 @@ static abi_long do_sendrecvmsg_locked(int fd, struct target_msghdr *msgp, + int flags, int send) + { + abi_long ret, len; +- struct msghdr msg; ++ struct msghdr msg = {0}; + abi_ulong count; + struct iovec *vec; + abi_ulong target_vec; diff --git a/srcpkgs/qemu/template b/srcpkgs/qemu/template index e8cb4d4672c..ac19de618dc 100644 --- a/srcpkgs/qemu/template +++ b/srcpkgs/qemu/template @@ -1,4 +1,5 @@ # Template file for 'qemu' +# This package should be updated together with qemu-user-static pkgname=qemu version=5.2.0 revision=1 @@ -46,10 +47,6 @@ if [ -z "$CROSS_BUILD" ]; then build_options_default+=" smartcard" fi -pre_configure() { - vsed -i 's/__u64/unsigned long/' linux-user/host/aarch64/hostdep.h -} - do_configure() { local args= From 1a700916afeca1018dd2811afdc5687f72139ad7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89rico=20Rolim?= Date: Wed, 13 Jan 2021 11:37:04 -0300 Subject: [PATCH 4/4] libglib-static: remove package. No longer necessary, now that glib includes static libraries. --- .../patches/gobject_init_on_demand.patch | 91 ------------------- .../patches/quark_init_on_demand.patch | 37 -------- srcpkgs/libglib-static/template | 49 ---------- 3 files changed, 177 deletions(-) delete mode 100644 srcpkgs/libglib-static/patches/gobject_init_on_demand.patch delete mode 100644 srcpkgs/libglib-static/patches/quark_init_on_demand.patch delete mode 100644 srcpkgs/libglib-static/template diff --git a/srcpkgs/libglib-static/patches/gobject_init_on_demand.patch b/srcpkgs/libglib-static/patches/gobject_init_on_demand.patch deleted file mode 100644 index bcc3cabfbcd..00000000000 --- a/srcpkgs/libglib-static/patches/gobject_init_on_demand.patch +++ /dev/null @@ -1,91 +0,0 @@ -Initialize the gobject system on demand, i.e. before it is -expected to be initialized. Do this only once by checking -a local static variable gobject_initialized. - ---- gobject/gtype.c 2016-08-17 17:20:47.000000000 +0200 -+++ gobject/gtype.c 2016-09-01 21:56:31.777406646 +0200 -@@ -209,6 +209,9 @@ - static gboolean type_node_is_a_L (TypeNode *node, - TypeNode *iface_node); - -+#if !defined(__GLIBC__) -+static void gobject_init (void); -+#endif - - /* --- enumeration --- */ - -@@ -2631,7 +2634,10 @@ - GTypeFlags flags) - { - TypeNode *node; -- -+ -+#if !defined(__GLIBC__) -+ gobject_init(); -+#endif - g_assert_type_system_initialized (); - g_return_val_if_fail (type_id > 0, 0); - g_return_val_if_fail (type_name != NULL, 0); -@@ -2749,6 +2755,9 @@ - TypeNode *pnode, *node; - GType type = 0; - -+#if !defined(__GLIBC__) -+ gobject_init(); -+#endif - g_assert_type_system_initialized (); - g_return_val_if_fail (parent_type > 0, 0); - g_return_val_if_fail (type_name != NULL, 0); -@@ -2804,6 +2813,9 @@ - TypeNode *pnode, *node; - GType type; - -+#if !defined(__GLIBC__) -+ gobject_init(); -+#endif - g_assert_type_system_initialized (); - g_return_val_if_fail (parent_type > 0, 0); - g_return_val_if_fail (type_name != NULL, 0); -@@ -3319,6 +3331,9 @@ - { - TypeNode *node; - -+#if !defined(__GLIBC__) -+ gobject_init(); -+#endif - g_assert_type_system_initialized (); - - node = lookup_type_node_I (type); -@@ -4343,6 +4358,9 @@ - void - g_type_init_with_debug_flags (GTypeDebugFlags debug_flags) - { -+#if !defined(__GLIBC__) -+ gobject_init(); -+#endif - g_assert_type_system_initialized (); - - if (debug_flags) -@@ -4361,6 +4379,9 @@ - void - g_type_init (void) - { -+#if !defined(__GLIBC__) -+ gobject_init(); -+#endif - g_assert_type_system_initialized (); - } - -@@ -4372,6 +4393,12 @@ - TypeNode *node; - GType type; - -+#if !defined(__GLIBC__) -+ static int gobject_initialized = 0; -+ if (gobject_initialized) -+ return; -+ gobject_initialized = 1; -+#endif - /* Ensure GLib is initialized first, see - * https://bugzilla.gnome.org/show_bug.cgi?id=756139 - */ diff --git a/srcpkgs/libglib-static/patches/quark_init_on_demand.patch b/srcpkgs/libglib-static/patches/quark_init_on_demand.patch deleted file mode 100644 index 458a2adab43..00000000000 --- a/srcpkgs/libglib-static/patches/quark_init_on_demand.patch +++ /dev/null @@ -1,37 +0,0 @@ -musl does not run ctors in the assumed order that glib-2.46 expects. -Call g_quark_init() where it is expected to have been called. - - ---- glib/gquark.c 2016-08-17 17:20:47.000000000 +0200 -+++ glib/gquark.c 2016-08-30 07:49:13.298234757 +0200 -@@ -57,6 +57,9 @@ - void - g_quark_init (void) - { -+ if (quark_ht) -+ return; -+ - g_assert (quark_seq_id == 0); - quark_ht = g_hash_table_new (g_str_hash, g_str_equal); - quarks = g_new (gchar*, QUARK_BLOCK_SIZE); -@@ -138,9 +141,12 @@ - return 0; - - G_LOCK (quark_global); -+#if !defined(__GLIBC__) -+ g_quark_init (); -+#endif - quark = GPOINTER_TO_UINT (g_hash_table_lookup (quark_ht, string)); - G_UNLOCK (quark_global); - - return quark; - } - -@@ -280,6 +286,7 @@ - GQuark quark; - gchar **quarks_new; - -+ g_quark_init (); - if (quark_seq_id % QUARK_BLOCK_SIZE == 0) - { - quarks_new = g_new (gchar*, quark_seq_id + QUARK_BLOCK_SIZE); diff --git a/srcpkgs/libglib-static/template b/srcpkgs/libglib-static/template deleted file mode 100644 index 83dc7323082..00000000000 --- a/srcpkgs/libglib-static/template +++ /dev/null @@ -1,49 +0,0 @@ -# Template file for 'libglib-static' -# -# This is only used for qemu-user-static until meson figures out building static -# glib 2.60.0 via meson. -# -pkgname=libglib-static -version=2.58.3 -revision=5 -wrksrc="glib-${version}" -build_style=gnu-configure -configure_args="--enable-libelf --disable-fam --disable-shared --with-pcre=system - --enable-static" -hostmakedepends="automake gettext libtool pkg-config python3 libxslt docbook-xsl" -makedepends="zlib-devel pcre-devel libffi-devel dbus-devel elfutils-devel libmount-devel" -depends="$makedepends" -short_desc="GNU library of C routines" -maintainer="Enno Boland " -license="LGPL-2.1-or-later" -homepage="https://wiki.gnome.org/Projects/GLib" -changelog="https://gitlab.gnome.org/GNOME/glib/raw/master/NEWS" -distfiles="${GNOME_SITE}/glib/${version%.*}/glib-${version}.tar.xz" -checksum=8f43c31767e88a25da72b52a40f3301fefc49a665b56dc10ee7cc9565cbe7481 -conflicts="libglib-devel>=0" - -if [ "$CROSS_BUILD" ]; then - hostmakedepends+=" glib-devel" - case "$XBPS_TARGET_MACHINE" in - mips*|ppc|ppc-musl) # It seems mips/ppc autoconf cache is not read? - configure_args+=" glib_cv_stack_grows=no glib_cv_rtldglobal_broken=no glib_cv_uscore=no" ;; - esac -fi - -post_patch() { - # Better to just rm -rf /usr/lib/locale in post_install? - vsed -i -e "s,localedir=.*,localedir=/usr/share/locale," \ - -e "s,DATADIRNAME=lib,DATADIRNAME=share," \ - m4macros/glib-gettext.m4 - vsed -i -e "s,^localedir =.*,localedir = /usr/share/locale," \ - po/Makefile.in.in -} - -pre_configure() { - NOCONFIGURE=1 ./autogen.sh -} - -post_install() { - rm -r $DESTDIR/usr/bin - rm -r $DESTDIR/usr/share -}