From 84a5c1ef7cc23fefc5db1db8e01fdbd71e234804 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] 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} \