From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 0DDDD1382C5 for ; Sun, 3 Jan 2021 15:17:07 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id BEA90E0857; Sun, 3 Jan 2021 15:17:03 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 85976E0822 for ; Sun, 3 Jan 2021 15:17:03 +0000 (UTC) Received: by mail-io1-f51.google.com with SMTP id q137so22715766iod.9 for ; Sun, 03 Jan 2021 07:17:02 -0800 (PST) X-Gm-Message-State: AOAM531eIyJvyzDo87j3ElsS1fbIcZ7KsKtz3hCnYU+LaQuynjtpOFma 2eWbN0M4fRRopr+ZZeSlIF3nJGlkT+Lk/bGG0Yk= X-Google-Smtp-Source: ABdhPJyKpBU+pbtG9Y7q01+keRVgrFE6+3f3Qp1VXqQC6EBp7kkawNjQ2KEzaMS9S2xw5qMQPpcei3Mh4Kfv7HOPur0= X-Received: by 2002:a6b:ce12:: with SMTP id p18mr9737332iob.181.1609687020712; Sun, 03 Jan 2021 07:17:00 -0800 (PST) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-dev@lists.gentoo.org Reply-to: gentoo-dev@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply MIME-Version: 1.0 References: <20210103010904.1158863-1-floppym@gentoo.org> <20210103125208.0694a788@symphony.aura-online.co.uk> In-Reply-To: <20210103125208.0694a788@symphony.aura-online.co.uk> From: Mike Gilbert Date: Sun, 3 Jan 2021 10:16:49 -0500 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [gentoo-dev] [PATCH] systemd.eclass: remove SYSROOT from pkg-config output To: Gentoo Dev Content-Type: text/plain; charset="UTF-8" X-Archives-Salt: bad8b72c-464d-476f-b9c1-4f4874d6b4a4 X-Archives-Hash: 72cbdfd4f6073a806256238e315bfb75 On Sun, Jan 3, 2021 at 7:52 AM James Le Cuirot wrote: > > On Sat, 2 Jan 2021 20:09:04 -0500 > Mike Gilbert wrote: > > > When cross-compiling, users will typically have > > PKG_CONFIG_SYSROOT=${SYSROOT} defined via pkg-config wrapper. > > > > When PKG_CONFIG_SYSROOT is set, all paths included in pkg-config > > output get prefixed with this value. > > > > Signed-off-by: Mike Gilbert > > --- > > > > This patch has already been pushed, but I figured I would send it for > > review in case someone else can think of a failure case, or has a better > > solution. > > > > eclass/systemd.eclass | 1 + > > 1 file changed, 1 insertion(+) > > > > diff --git a/eclass/systemd.eclass b/eclass/systemd.eclass > > index 81065a0af79a..f6d1fa2d92d6 100644 > > --- a/eclass/systemd.eclass > > +++ b/eclass/systemd.eclass > > @@ -50,6 +50,7 @@ _systemd_get_dir() { > > > > if $(tc-getPKG_CONFIG) --exists systemd; then > > d=$($(tc-getPKG_CONFIG) --variable="${variable}" systemd) || die > > + d=${d#${SYSROOT}} > > d=${d#${EPREFIX}} > > else > > d=${fallback} > > I was going to say this is not the best approach as it would be better > to tell pkg-config to not add the SYSROOT in the first place. I now > realise we have shot ourselves in the foot with cross-pkg-config as it > uses SYSROOT to set both PKG_CONFIG_SYSROOT_DIR to control the output > and PKG_CONFIG_LIBDIR to find the .pc files in the first place. I have > had prefix-related fixes for cross-pkg-config lined up for over a year > but unfortunately they do not address this. Trying to accommodate this > use case would probably just make it more confusing though so maybe > your approach is best after all. It would be cleaner overall if we could prevent SYSROOT from being added to the paths in the first place. > The EPREFIX line is (sometimes) wrong in EAPI 7 though and the same goes > for udev.eclass. It took a while to get this agreed and corrected in > PMS but if SYSROOT points to / then the effective prefix is BROOT, not > EPREFIX; they may not be the same. Ugh, that "corrected" logic in PMS head is nasty. > If you just strip ESYSROOT then > it will always do the right thing but you'll need this fall back for > older EAPIs. I'm not sure why you didn't do it in one line? I was trying to accommodate older EAPIs that do not define ESYSROOT. This seemed like the simplest approach. It also allows for the case where someone is not using cross-pkg-config, and PKG_CONFIG_SYSROOT_DIR is unset. Since SYSROOT and EPREFIX are removed separately, if one of them is already missing, it will just be skipped. > I forget if EPREFIX is normalised to be / rather thank blank. > > d=${d#${SYSROOT%/}/${EPREFIX#/}} SYSROOT never ends with a / in modern versions of portage (regardless of EAPI), so there's currently no need to remove a trailing slash. https://gitweb.gentoo.org/proj/portage.git/commit/?id=1b5110557d1dd725f7c12bbed4b7ceaaec29f2a3 I have never seen EPREFIX equal to "/", or end with a trailing slash. Given it is most commonly used as "${EPREFIX}/usr", this would result in double-slashes everywhere.