Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 948948 - sys-devel/crossdev - cross-pkg-config calls unprefixed pkg-config
Summary: sys-devel/crossdev - cross-pkg-config calls unprefixed pkg-config
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal
Assignee: Gentoo Toolchain Maintainers
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-01-28 11:01 UTC by Adrian Ratiu
Modified: 2025-01-31 12:59 UTC (History)
4 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Adrian Ratiu 2025-01-28 11:01:22 UTC
Hello, I try to explain this as well as I can, feel free to ask questions and I'll do my best to clarify.

Starting with commit 03f1639 ("sys-libs/libxcrypt: general clean up"), a breakage was introduced for systems where CHOST != CTARGET because of this new line: "local CHOST=${CTARGET}".

Inspecting the default Gentoo toolchains and crossdev setup (eg by debugging aarch64-unknown-linux-gnu-emerge sys-libs/libxcrypt), I notice:

CHOST = aarch64-unknown-linux-gnu
CTARGET = aarch64-unknown-linux-gnu

so the CHOST=${CTARGET} line is a NO-OP, in other words the same tools get called as before the commit, like for example aarch64-unknown-linux-gnu-pkg-config (symlinked from crossdev's cross-pkg-config).

Other toolchains, like the ChromiumOS toolchain, set CHOST != CTARGET so one gets values like the following:

CHOST = x86_64-pc-linux-gnu
CTARGET = aarch64-cros-linux-gnu

Thus the newly added CHOST=${CTARGET} line causes a different set of tools to be invoked by configure (eg aarch64-cros-linux-gnu-pkg-config instead of x86_64-pc-linux-gnu-pkg-config).

This causes breakage because the crossdev versions, like aarch64-cros-linux-gnu-pkg-config symlinked to the cross-pkg-config script, in turn call the unprefixed pkg-config [1] instead of the properly prefixed tools (eg x86_64-pc-linux-gnu-pkg-config).

The breakage is caused by my profile containing a check which strictly prohibits calling unprefixed tools like this pkg-config while cross compiling. Before libxcrypt-4.4.36-r3 it was ok because configure called x86_64-pc-linux-gnu-pkg-config directly.

I have created a PR with a simple solution of bringing back the old behaviour:
https://github.com/gentoo/gentoo/pull/40337

If that is not acceptable maybe we can find another, eg. to add a use flag to allow CHOST != CTARGET?

[1] https://gitweb.gentoo.org/proj/crossdev.git/tree/wrappers/cross-pkg-config#n135

Reproducible: Always

Steps to Reproduce:
1. Build libxcrypt-4.4.36-r3 with a CHOST != CTARGET toolchain
2. Notice how instead of calling ${CHOST}-pkg-config, libxcrypt now ends up calling the unprefixed pkg-config via cross-pkg-config.
Actual Results:  
My profile check fails the build because an unprefixed "pkg-config" gets called instead of the expected ${CHOST}-pkg-config.

Expected Results:  
I expect the libxcrypt-4.4.36-r3 build to respect the CHOST setting and call the properly prefixed pkg-config.
Comment 1 Mike Gilbert gentoo-dev 2025-01-28 15:55:02 UTC
Calling ${CHOST}-pkg-config is simply wrong in the scenario.

We want to call the cross-pkg-config wrapper (or an appropriate ${CTARGET-pkg-config binary) so that SYSROOT gets added to PKG_CONFIG_PATH, etc.

The problem here is with your profile, which is breaking the cross-pkg-config script. I think we should focus on how to make that work.
Comment 2 James Le Cuirot gentoo-dev 2025-01-28 16:18:02 UTC
I'm confused. CTARGET is rarely used and when it is, it always involves crossdev. crossdev doesn't handle this package though, so what is this code even for?

In any case, having the wrapper call "${CBUILD}{CBUILD+-}pkg-config" rather than "pkg-config" seems like a reasonable compromise.
Comment 3 Mike Gilbert gentoo-dev 2025-01-28 16:51:41 UTC
CTARGET gets set to ${tuple} when you install cross-${tuple}/libcrypt. It's like installing cross-${tuple}/glibc or cross-${tuple}/musl.

We set that up to allow libxcrypt to be installed as part of bootstrapping a crossdev environment rather than installing it after the crossdev environment has already been established.

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=aabea35bb6fdc0e5de5b899c0c2efa8e9570b1e1

It's really kind of an abuse of ${CTARGET} since we are not building a compiler here, and that's why the ebuild ends up copying it to ${CHOST}.
Comment 4 Mike Gilbert gentoo-dev 2025-01-28 16:52:34 UTC
(In reply to James Le Cuirot from comment #2)
> In any case, having the wrapper call "${CBUILD}{CBUILD+-}pkg-config" rather
> than "pkg-config" seems like a reasonable compromise.

I like that idea.
Comment 5 Mike Gilbert gentoo-dev 2025-01-28 17:13:10 UTC
PR filed. Please review.
Comment 6 Adrian Ratiu 2025-01-29 09:43:20 UTC
Thank you, I tested the patch and it solves my unprefixed pkg-config problem.
Comment 7 James Le Cuirot gentoo-dev 2025-01-29 11:38:40 UTC
Approved.

(In reply to Mike Gilbert from comment #3)
> CTARGET gets set to ${tuple} when you install cross-${tuple}/libcrypt. It's
> like installing cross-${tuple}/glibc or cross-${tuple}/musl.

I get that, but when do we actually do that? There's no reference to libxcrypt in crossdev at all and cross-${tuple} symlinks don't get created by anything else?
Comment 8 Mike Gilbert gentoo-dev 2025-01-29 11:59:48 UTC
Not sure how the symlink gets created. Perhaps Adrian is using a fork of crossdev?
Comment 9 Mike Gilbert gentoo-dev 2025-01-29 12:06:27 UTC
Ah, it looks like ChromiumOS uses the --ex-pkg option to install it.

https://chromium.googlesource.com/chromiumos/overlays/toolchains/+/refs/heads/main/README.md
Comment 10 Adrian Ratiu 2025-01-29 12:23:36 UTC
Yes, I'm using the --ex-pkg option and I'm also the one who added the "headers-only" USE flag to the libxcrypt ebuild because otherwise I couldn't bootstrap the ChromeOS LLVM compiler due to a circular dependency (I needed libxcrypt early in the toolchain bootstrap process).
Comment 11 Larry the Git Cow gentoo-dev 2025-01-29 17:42:27 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/proj/crossdev.git/commit/?id=15280e942a3f6490c62b2978e0b951f9cbb9066d

commit 15280e942a3f6490c62b2978e0b951f9cbb9066d
Author:     Mike Gilbert <floppym@gentoo.org>
AuthorDate: 2025-01-28 17:09:02 +0000
Commit:     Mike Gilbert <floppym@gentoo.org>
CommitDate: 2025-01-28 17:11:14 +0000

    cross-pkg-config: call ${CBUILD}-pkg-config when available
    
    This avoids calling plain pkg-config in environments where that binary
    has been blacklisted.
    
    Bug: https://bugs.gentoo.org/948948
    Signed-off-by: Mike Gilbert <floppym@gentoo.org>

 wrappers/cross-pkg-config | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)