Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 951515 - [Future EAPI] introduce is_cross
Summary: [Future EAPI] introduce is_cross
Status: CONFIRMED
Alias: None
Product: Gentoo Hosted Projects
Classification: Unclassified
Component: PMS/EAPI (show other bugs)
Hardware: All Linux
: Normal normal
Assignee: Package Manager Specification
URL:
Whiteboard: distant-future-eapi
Keywords:
Depends on:
Blocks: future-eapi
  Show dependency tree
 
Reported: 2025-03-17 19:48 UTC by Arthur Zamarin
Modified: 2025-03-18 07:05 UTC (History)
2 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 Arthur Zamarin archtester Gentoo Infrastructure gentoo-dev Security 2025-03-17 19:48:00 UTC
Today we have "tc-is-cross-compiler" function from "toolchain-funcs.eclass", which is very useful for knowing if we can run the recently built binary to generate misc files (like bash completion for various rust/go packages).

The current implementation is simple, but first I don't know if it covers every possibility, and maybe the PM can select it in a better way. But inheriting the complicated eclass just for this function is somewhat sad.

So maybe introduce a new function, with simpler name "is_cross", "iscross", ...

Another option is to just move it into a new eclass, which is more slim, but maybe PMS is actually a good place for this function.
Comment 1 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2025-03-17 19:50:50 UTC
Wait, we have a function for that?  I always thought the condition is so simple that it makes sense to just inline it.
Comment 2 Arthur Zamarin archtester Gentoo Infrastructure gentoo-dev Security 2025-03-17 19:53:21 UTC
(In reply to Michał Górny from comment #1)
> Wait, we have a function for that?  I always thought the condition is so
> simple that it makes sense to just inline it.

I think a function is nicer, since people can mistake, not think on every edge case, and if we need to update it (cause we change crossdev), changing a single place is better than all places.
Comment 3 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2025-03-17 19:56:26 UTC
If it's an EAPI function, you can't change it.
Comment 4 Arthur Zamarin archtester Gentoo Infrastructure gentoo-dev Security 2025-03-17 20:01:04 UTC
(In reply to Michał Górny from comment #3)
> If it's an EAPI function, you can't change it.

If I understand it correct, the API must remain the same (function name, args, result same type), but the implementation can change by the PM to be as appropriate as needed?
Comment 5 James Le Cuirot gentoo-dev 2025-03-17 21:38:15 UTC
I don't really care that the eclass has other stuff in it. Quite often, you do need to call tc-getCC or similar.

I actually don't like the current definition of tc-is-cross-compiler, or at least a differently-named function should usually be used instead. The condition it should really check for is probably [[ -n ${SYSROOT} ]]. If you're building against a different SYSROOT, you shouldn't try to (directly) execute anything from it, even if it is for the same tuple.

What we do need (and I should have filed a bug for already, sorry) is a USE flag for this condition, similar to the old EAPI 5-hdepend "targetroot" flag. For the same reason above, I didn't want to call it anything like "cross", but I haven't decided on a good name yet.

The flag is primarily meant to be used in *DEPEND variables where a package can only be cross-compiled with itself, but it would also mean you effectively get a helper for free.

> if use other-sysroot; then
Comment 6 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2025-03-17 21:39:14 UTC
FWIW, I'd suggest we hold off (but not a "veto") until Chewi and I can hash out any other "cross-related" changes.
Comment 7 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2025-03-18 07:05:34 UTC
(In reply to Arthur Zamarin from comment #4)
> If I understand it correct, the API must remain the same (function name,
> args, result same type), but the implementation can change by the PM to be
> as appropriate as needed?

Err, yes and no.  For some functions (like user patches), the implementation may be pretty much left to the package manager.  However, for functions where you expect ebuilds to behave consistently (read: not suddenly fail if one package manager implements something slightly differently), the PMS needs to explicitly define the behavior.  I'm not 100% sure here but I think this case is closer to the latter than the former.