From 3496df638fca284c97927d42ed27a76763b60f36 Mon Sep 17 00:00:00 2001 From: Matt Whitlock Date: Sun, 3 Aug 2025 14:24:04 +0100 Subject: [PATCH] multilib.eclass: respect SYSROOT when overriding PKG_CONFIG_* vars MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In multilib.eclass, multilib_toolchain_setup() overrides the environment variables PKG_CONFIG_LIBDIR, PKG_CONFIG_PATH, PKG_CONFIG_SYSTEM_INCLUDE_PATH, and PKG_CONFIG_SYSTEM_LIBRARY_PATH so that the .pc files for the correct ABI will be found and used. As a reminder, pkgconfig is normally called upon to find packages that have been installed into the *host* system — i.e., packages listed in DEPEND. The "Ebuild writing: Variables" page[1] describes the SYSROOT variable as "The absolute path to the root directory containing build dependencies satisfied by DEPEND" and ESYSROOT as "The same as either EROOT, BROOT or SYSROOT depending on the value of SYSROOT. Commonly used to reference the location of headers and libraries at build time." In order to support the use case of setting SYSROOT to a path other than "/" while building packages for ABIs other than the default ABI, change multilib.eclass so that it prefixes the PKG_CONFIG_* vars with ${ESYSROOT} rather than ${EPREFIX}. For Gentoo users who do not set SYSROOT, this change will have no bearing. This change could conceivably affect crossdev users, but I think typically crossdev sysroots do not support multilib anyway, so this change wouldn't affect them either. [1] https://devmanual.gentoo.org/ebuild-writing/variables/ Closes: https://bugs.gentoo.org/945108 Signed-off-by: Matt Whitlock Part-of: https://github.com/gentoo/gentoo/pull/43088 Closes: https://github.com/gentoo/gentoo/pull/43088 Signed-off-by: James Le Cuirot --- eclass/multilib.eclass | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/eclass/multilib.eclass b/eclass/multilib.eclass index f19ad20af8fd9..c28fee7aa1efe 100644 --- a/eclass/multilib.eclass +++ b/eclass/multilib.eclass @@ -1,4 +1,4 @@ -# Copyright 1999-2024 Gentoo Authors +# Copyright 1999-2025 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 # @ECLASS: multilib.eclass @@ -552,10 +552,10 @@ multilib_toolchain_setup() { export STRIP="$(tc-getSTRIP)" # Avoid 'strip', use '${CHOST}-strip' export CHOST=$(get_abi_CHOST $1) - export PKG_CONFIG_LIBDIR=${EPREFIX}/usr/$(get_libdir)/pkgconfig - export PKG_CONFIG_PATH=${EPREFIX}/usr/share/pkgconfig - export PKG_CONFIG_SYSTEM_INCLUDE_PATH=${EPREFIX}/usr/include - export PKG_CONFIG_SYSTEM_LIBRARY_PATH=${EPREFIX}/$(get_libdir):${EPREFIX}/usr/$(get_libdir) + export PKG_CONFIG_LIBDIR=${ESYSROOT}/usr/$(get_libdir)/pkgconfig + export PKG_CONFIG_PATH=${ESYSROOT}/usr/share/pkgconfig + export PKG_CONFIG_SYSTEM_INCLUDE_PATH=${ESYSROOT}/usr/include + export PKG_CONFIG_SYSTEM_LIBRARY_PATH=${ESYSROOT}/$(get_libdir):${ESYSROOT}/usr/$(get_libdir) fi }