Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 955822 - =sys-devel/crossdev-20250410 breaks cross-pkg-config when CBUILD = CHOST
Summary: =sys-devel/crossdev-20250410 breaks cross-pkg-config when CBUILD = CHOST
Status: UNCONFIRMED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal
Assignee: Gentoo Crossdev team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-05-11 08:07 UTC by dE
Modified: 2025-05-24 17:18 UTC (History)
3 users (show)

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


Attachments
Same failed build log with the crossdev-20250410 installed of unbound. (build.log,7.10 KB, text/x-log)
2025-05-11 08:09 UTC, dE
Details
Checks if $REAL_PKG_CONFIG symlinks to cross-pkg-config, and fallbacks to pkg-config if that's so. (cross-pkg-config.patch,725 bytes, patch)
2025-05-12 14:49 UTC, dE
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description dE 2025-05-11 08:07:26 UTC
Since the update from 20250106 to 20250410 cross-pkg-config has added line 29 -- 
[ "${0##*/}" = "${REAL_PKG_CONFIG}" ] && error "aborting infinite loop! (make sure to delete uClinux-dist/tools/pkg-config)"


This check bails out situations where CBUILD=CHOST which is the case when PORTAGE_CONFIGROOT and ROOT is used to cross build which results in error --
 cross-pkg-config: error: aborting infinite loop! (make sure to delete uClinux-dist/tools/pkg-config)

Another side effect of this is that even when not using crossdev i.e using emerge directly to crossbuild (with SYSROOT etc... with other environment variables to support the build process), when the user intentionally sets CBUILD=CHOST to make the toolchain assume that it's not cross compiling, cross-pkg-config fails with this error for the same reason. The reason for setting CBUILD=CHOST is because many packages do not cross compile e.g. -- 

www-servers/varnish: configure: error: cannot run test program while cross compiling
dev-vcs/git: ERROR: Can not run test applications in this cross environment.
dev-util/ragel: error: cannot check for file existence when cross compiling
dev-cpp/clucene: CMake Error: try_run() invoked in cross-compiling mode, please set the following cache variables appropriately
dev-python/numpy: ERROR: Can not run test applications in this cross environment.
And may packages which give various errors when cross compiling.
etc..
etc..
etc...

For these package the common workaround is setting CBUILD=CHOST when building on machines with similar (but not identical) CPU types (for e.g. znver1 on icelake where you cannot even chroot (and even qemu-softmmu cannot do that because does not support all instructions) or situations where building in chroot results in invalid instructions but not with CBUILD=CHOST). With this check in place in cross-pkg-config, this workaround cannot be used.

Reproducible: Always
Comment 1 dE 2025-05-11 08:09:59 UTC
Created attachment 928435 [details]
Same failed build log with the crossdev-20250410 installed of unbound.

unbound was attempted to build with -- 
PORTAGE_CONFIGROOT=/usr/x86_64-mypc-linux-gnu/ ROOT=/usr/x86_64-mypc-linux-gnu/ emerge --getbinpkg --keep-going net-dns/unbound

The build works with crossdev-20250106.
Comment 2 Mike Gilbert gentoo-dev 2025-05-12 03:32:30 UTC
Your use case is a little strange strange: cross-pkg-config is normally invoked when cross-compiling, but you are not cross-compiling if CBUILD == CHOST. It was not designed to work under that condition.

I would be happy to review a patch to resolve the issue, but be aware of bug 948948.
Comment 3 dE 2025-05-12 03:58:04 UTC
But this also breaks building with ROOT= only -- which is a critical functionality because a LOT of package do not cross compile. ROOT= is supposed to work.
Comment 4 Mike Gilbert gentoo-dev 2025-05-12 05:01:03 UTC
ROOT has nothing to do with it. This is caused by you setting CBUILD equal to CHOST when CBUILD-pkg-config is cross-pkg-config and not a real pkgconf binary.
Comment 5 dE 2025-05-12 07:12:18 UTC
So what could be done is that if cross-pkg-config sees that ${CBUILD}-pkg-config is a symlink to /usr/bin/cross-pkg-config (which is invalid anyway), it'll set REAL_PKG_CONFIG to /usr/bin/pkg-config. Will that be a viable solution?
Comment 6 dE 2025-05-12 14:49:21 UTC
Created attachment 928534 [details, diff]
Checks if $REAL_PKG_CONFIG symlinks to cross-pkg-config, and fallbacks to pkg-config if that's so.

This patch seems to be working.
Comment 7 Mike Gilbert gentoo-dev 2025-05-12 15:17:23 UTC
I'm not crazy about making guesses based on symlinks.

I added a link to my own PR. Will that work for you?
Comment 8 dE 2025-05-13 05:30:08 UTC
I modified crossdev-99999999.ebuild with -- 
EGIT_REPO_URI="https://github.com/floppym/crossdev"
EGIT_BRANCH="bug955822-cbuild"

Seems to be working fine. (Unbound works). Let me complete the upgrade and I'll revert if there are issues.

Thanks!!
Comment 9 dE 2025-05-15 05:23:15 UTC
I can confirm that this issues if fixed with https://github.com/floppym/crossdev branch bug955822-cbuild

Thanks again for the fix.
Comment 10 dE 2025-05-24 05:56:15 UTC
Any chance of this being merged to the official project repo?
Comment 11 Larry the Git Cow gentoo-dev 2025-05-24 17:12:37 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/proj/crossdev.git/commit/?id=99a3974e9108a231523af6002578682391b26260

commit 99a3974e9108a231523af6002578682391b26260
Author:     Mike Gilbert <floppym@gentoo.org>
AuthorDate: 2025-05-12 14:57:27 +0000
Commit:     Mike Gilbert <floppym@gentoo.org>
CommitDate: 2025-05-24 17:11:45 +0000

    cross-pkg-config: remember PKG_CONFIG from build time
    
    This should avoid recursive cross-pkg-config calls when someone sets
    CBUILD = CHOST in the cross-emerge environment, which might be useful
    for building a system image with SYSROOT != /.
    
    For sys-devel/crossdev we will call "tc-export PKG_CONFIG" to set a
    reasonable default for REAL_PKG_CONFIG. This will generally be
    ${CHOST}-pkg-config, where CBUILD = CHOST and SYSROOT = ROOT = /.
    
    In the case we are cross-compiling crossdev itself, we want
    ${CHOST}-pkg-config for REAL_PKG_CONFIG in SYSROOT/ROOT in case it is later
    used as a root image on appropriate hardware.
    
    We also allow the user to override REAL_PKG_CONFIG via the environment
    in case some unforseen use case is discovered.
    
    Bug: https://bugs.gentoo.org/955822
    Signed-off-by: Mike Gilbert <floppym@gentoo.org>

 wrappers/Makefile         | 4 +++-
 wrappers/cross-pkg-config | 4 +++-
 2 files changed, 6 insertions(+), 2 deletions(-)
Comment 12 Larry the Git Cow gentoo-dev 2025-05-24 17:18:08 UTC
The bug has been referenced in the following commit(s):

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

commit af5d9197a2903c49426fa999e278c0aa77f98fa6
Author:     Mike Gilbert <floppym@gentoo.org>
AuthorDate: 2025-05-24 17:16:57 +0000
Commit:     Mike Gilbert <floppym@gentoo.org>
CommitDate: 2025-05-24 17:16:57 +0000

    sys-devel/crossdev: export PKG_CONFIG
    
    Bug: https://bugs.gentoo.org/955822
    Signed-off-by: Mike Gilbert <floppym@gentoo.org>

 sys-devel/crossdev/crossdev-99999999.ebuild | 4 ++++
 1 file changed, 4 insertions(+)