diff mbox series

[4/4] classes/recipes: Switch to use inherit_defer

Message ID 20240103145902.2124110-4-richard.purdie@linuxfoundation.org
State New
Headers show
Series [1/4] allarch: Fix allarch corner case | expand

Commit Message

Richard Purdie Jan. 3, 2024, 2:59 p.m. UTC
Now that bitbake supports the use of inherit_defer, switch all conditional
(variable based) inherits to use this instead. This leads to more a more
deterministic user experience since there is no longer an immediate expansion
and later changes to the variables in question (e.g. a bbappend) are
accounted for.

This patch tries to ensure the behaviour before/after remains as unchanged
as it reasonably can, e.g. by always inherting populate_sdk_base. native
and nativesdk continue to need to be inherited last, hence being used
with inherit_defer in a handful of very specific cases.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
 meta-selftest/recipes-test/overlayfs-user/overlayfs-user.bb  | 2 +-
 meta/classes-recipe/baremetal-image.bbclass                  | 2 +-
 meta/classes-recipe/gnomebase.bbclass                        | 2 +-
 meta/classes-recipe/image.bbclass                            | 5 +++--
 meta/classes-recipe/image_types_wic.bbclass                  | 2 +-
 meta/classes-recipe/kernel.bbclass                           | 2 +-
 meta/classes-recipe/live-vm-common.bbclass                   | 4 ++--
 meta/classes-recipe/packagegroup.bbclass                     | 2 +-
 meta/classes-recipe/populate_sdk_base.bbclass                | 2 +-
 meta/classes/useradd.bbclass                                 | 2 +-
 meta/recipes-core/libxml/libxml2_2.11.5.bb                   | 2 +-
 .../packagegroups/nativesdk-packagegroup-sdk-host.bb         | 3 ++-
 meta/recipes-devtools/btrfs-tools/btrfs-tools_6.5.3.bb       | 2 +-
 meta/recipes-graphics/xorg-driver/xorg-driver-common.inc     | 2 +-
 meta/recipes-kernel/perf/perf.bb                             | 2 +-
 meta/recipes-kernel/systemtap/systemtap-native_git.bb        | 2 +-
 meta/recipes-kernel/systemtap/systemtap_git.bb               | 2 +-
 meta/recipes-support/gpgme/gpgme_1.23.2.bb                   | 3 ++-
 18 files changed, 23 insertions(+), 20 deletions(-)

Comments

Ross Burton Jan. 8, 2024, 5:14 p.m. UTC | #1
On 3 Jan 2024, at 14:59, Richard Purdie via lists.openembedded.org <richard.purdie=linuxfoundation.org@lists.openembedded.org> wrote:
> --- a/meta/classes-recipe/gnomebase.bbclass
> +++ b/meta/classes-recipe/gnomebase.bbclass
> @@ -28,7 +28,7 @@ FILES:${PN} += "${datadir}/application-registry  \
> FILES:${PN}-doc += "${datadir}/devhelp"
> 
> GNOMEBASEBUILDCLASS ??= "meson"
> -inherit ${GNOMEBASEBUILDCLASS} pkgconfig
> +inherit_defer ${GNOMEBASEBUILDCLASS} pkgconfig

Feels like this should be split into inherit pkgconfig and inher_defer ${GNOMEBASEBUILDCLASS}.

> +inherit populate_sdk_base
> +IMGCLASSES += "${@['', 'populate_sdk_ext']['linux' in d.getVar("SDK_OS")]}"

Whilst you’re here change this to foo if bar else flob, this boolean subsetting idiom drives me insane.

> --- a/meta/recipes-graphics/xorg-driver/xorg-driver-common.inc
> +++ b/meta/recipes-graphics/xorg-driver/xorg-driver-common.inc
> @@ -14,7 +14,7 @@ SRC_URI = "${XORG_MIRROR}/individual/driver/${BPN}-${PV}${XORG_DRIVER_COMPRESSOR
> FILES:${PN} += " ${libdir}/xorg/modules/drivers/*.so"
> 
> XORGBUILDCLASS ??= "autotools"
> -inherit ${XORGBUILDCLASS} pkgconfig features_check
> +inherit_defer ${XORGBUILDCLASS} pkgconfig features_check

As above.

> -inherit autotools texinfo binconfig-disabled pkgconfig ${PYTHON_INHERIT} python3native multilib_header
> +inherit autotools texinfo binconfig-disabled pkgconfig multilib_header
> +inherit_defer ${PYTHON_INHERIT} python3native

Why is python3native defered?

Ross
Richard Purdie Jan. 8, 2024, 10:39 p.m. UTC | #2
On Mon, 2024-01-08 at 17:14 +0000, Ross Burton wrote:
> On 3 Jan 2024, at 14:59, Richard Purdie via lists.openembedded.org <richard.purdie=linuxfoundation.org@lists.openembedded.org> wrote:
> > --- a/meta/classes-recipe/gnomebase.bbclass
> > +++ b/meta/classes-recipe/gnomebase.bbclass
> > @@ -28,7 +28,7 @@ FILES:${PN} += "${datadir}/application-registry  \
> > FILES:${PN}-doc += "${datadir}/devhelp"
> > 
> > GNOMEBASEBUILDCLASS ??= "meson"
> > -inherit ${GNOMEBASEBUILDCLASS} pkgconfig
> > +inherit_defer ${GNOMEBASEBUILDCLASS} pkgconfig
> 
> Feels like this should be split into inherit pkgconfig and inher_defer ${GNOMEBASEBUILDCLASS}.

I guess did it this way for ease in the patch, it won't really make
much difference either way, particularly for pkgconfig given how simple
that class is.

> 
> > +inherit populate_sdk_base
> > +IMGCLASSES += "${@['', 'populate_sdk_ext']['linux' in d.getVar("SDK_OS")]}"
> 
> Whilst you’re here change this to foo if bar else flob, this boolean subsetting idiom drives me insane.

I don't really mixing up changes as it just makes review harder so
whilst I don't mind changing that, I think it should be done
separately.

> > --- a/meta/recipes-graphics/xorg-driver/xorg-driver-common.inc
> > +++ b/meta/recipes-graphics/xorg-driver/xorg-driver-common.inc
> > @@ -14,7 +14,7 @@ SRC_URI = "${XORG_MIRROR}/individual/driver/${BPN}-${PV}${XORG_DRIVER_COMPRESSOR
> > FILES:${PN} += " ${libdir}/xorg/modules/drivers/*.so"
> > 
> > XORGBUILDCLASS ??= "autotools"
> > -inherit ${XORGBUILDCLASS} pkgconfig features_check
> > +inherit_defer ${XORGBUILDCLASS} pkgconfig features_check
> 
> As above.
> 
> > -inherit autotools texinfo binconfig-disabled pkgconfig ${PYTHON_INHERIT} python3native multilib_header
> > +inherit autotools texinfo binconfig-disabled pkgconfig multilib_header
> > +inherit_defer ${PYTHON_INHERIT} python3native
> 
> Why is python3native defered?

In the past there were some ordering issues around the python classes
so I was just being careful not to cause more problems in the patchset
than I was already trying to debug. It probably isn't necessary but at
the time I wasn't 100% sure and there were bigger issues.

I can make the above tweaks if they really bother you...

Cheers,

Richard
Khem Raj Jan. 9, 2024, 3:49 a.m. UTC | #3
On Mon, Jan 8, 2024 at 2:39 PM Richard Purdie
<richard.purdie@linuxfoundation.org> wrote:
>
> On Mon, 2024-01-08 at 17:14 +0000, Ross Burton wrote:
> > On 3 Jan 2024, at 14:59, Richard Purdie via lists.openembedded.org <richard.purdie=linuxfoundation.org@lists.openembedded.org> wrote:
> > > --- a/meta/classes-recipe/gnomebase.bbclass
> > > +++ b/meta/classes-recipe/gnomebase.bbclass
> > > @@ -28,7 +28,7 @@ FILES:${PN} += "${datadir}/application-registry  \
> > > FILES:${PN}-doc += "${datadir}/devhelp"
> > >
> > > GNOMEBASEBUILDCLASS ??= "meson"
> > > -inherit ${GNOMEBASEBUILDCLASS} pkgconfig
> > > +inherit_defer ${GNOMEBASEBUILDCLASS} pkgconfig
> >
> > Feels like this should be split into inherit pkgconfig and inher_defer ${GNOMEBASEBUILDCLASS}.
>
> I guess did it this way for ease in the patch, it won't really make
> much difference either way, particularly for pkgconfig given how simple
> that class is.
>
> >
> > > +inherit populate_sdk_base
> > > +IMGCLASSES += "${@['', 'populate_sdk_ext']['linux' in d.getVar("SDK_OS")]}"
> >
> > Whilst you’re here change this to foo if bar else flob, this boolean subsetting idiom drives me insane.
>
> I don't really mixing up changes as it just makes review harder so
> whilst I don't mind changing that, I think it should be done
> separately.
>
> > > --- a/meta/recipes-graphics/xorg-driver/xorg-driver-common.inc
> > > +++ b/meta/recipes-graphics/xorg-driver/xorg-driver-common.inc
> > > @@ -14,7 +14,7 @@ SRC_URI = "${XORG_MIRROR}/individual/driver/${BPN}-${PV}${XORG_DRIVER_COMPRESSOR
> > > FILES:${PN} += " ${libdir}/xorg/modules/drivers/*.so"
> > >
> > > XORGBUILDCLASS ??= "autotools"
> > > -inherit ${XORGBUILDCLASS} pkgconfig features_check
> > > +inherit_defer ${XORGBUILDCLASS} pkgconfig features_check
> >
> > As above.
> >
> > > -inherit autotools texinfo binconfig-disabled pkgconfig ${PYTHON_INHERIT} python3native multilib_header
> > > +inherit autotools texinfo binconfig-disabled pkgconfig multilib_header
> > > +inherit_defer ${PYTHON_INHERIT} python3native
> >
> > Why is python3native defered?
>
> In the past there were some ordering issues around the python classes
> so I was just being careful not to cause more problems in the patchset
> than I was already trying to debug. It probably isn't necessary but at
> the time I wasn't 100% sure and there were bigger issues.
>
> I can make the above tweaks if they really bother you...
>

Look into evolution-data-server-native.bb from meta-gnome
it inherits native and provides own default do_compile/do_install functions

it now needs to use
inherit_defer native

which parses but then the functions provided by the recipe are overridden
by ones from autotools class perhaps because it is deferred too ?

> Cheers,
>
> Richard
>
>
>
>
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#193434): https://lists.openembedded.org/g/openembedded-core/message/193434
> Mute This Topic: https://lists.openembedded.org/mt/103502916/1997914
> Group Owner: openembedded-core+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [raj.khem@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
Khem Raj Jan. 9, 2024, 3:53 a.m. UTC | #4
On Mon, Jan 8, 2024 at 7:49 PM Khem Raj <raj.khem@gmail.com> wrote:
>
> On Mon, Jan 8, 2024 at 2:39 PM Richard Purdie
> <richard.purdie@linuxfoundation.org> wrote:
> >
> > On Mon, 2024-01-08 at 17:14 +0000, Ross Burton wrote:
> > > On 3 Jan 2024, at 14:59, Richard Purdie via lists.openembedded.org <richard.purdie=linuxfoundation.org@lists.openembedded.org> wrote:
> > > > --- a/meta/classes-recipe/gnomebase.bbclass
> > > > +++ b/meta/classes-recipe/gnomebase.bbclass
> > > > @@ -28,7 +28,7 @@ FILES:${PN} += "${datadir}/application-registry  \
> > > > FILES:${PN}-doc += "${datadir}/devhelp"
> > > >
> > > > GNOMEBASEBUILDCLASS ??= "meson"
> > > > -inherit ${GNOMEBASEBUILDCLASS} pkgconfig
> > > > +inherit_defer ${GNOMEBASEBUILDCLASS} pkgconfig
> > >
> > > Feels like this should be split into inherit pkgconfig and inher_defer ${GNOMEBASEBUILDCLASS}.
> >
> > I guess did it this way for ease in the patch, it won't really make
> > much difference either way, particularly for pkgconfig given how simple
> > that class is.
> >
> > >
> > > > +inherit populate_sdk_base
> > > > +IMGCLASSES += "${@['', 'populate_sdk_ext']['linux' in d.getVar("SDK_OS")]}"
> > >
> > > Whilst you’re here change this to foo if bar else flob, this boolean subsetting idiom drives me insane.
> >
> > I don't really mixing up changes as it just makes review harder so
> > whilst I don't mind changing that, I think it should be done
> > separately.
> >
> > > > --- a/meta/recipes-graphics/xorg-driver/xorg-driver-common.inc
> > > > +++ b/meta/recipes-graphics/xorg-driver/xorg-driver-common.inc
> > > > @@ -14,7 +14,7 @@ SRC_URI = "${XORG_MIRROR}/individual/driver/${BPN}-${PV}${XORG_DRIVER_COMPRESSOR
> > > > FILES:${PN} += " ${libdir}/xorg/modules/drivers/*.so"
> > > >
> > > > XORGBUILDCLASS ??= "autotools"
> > > > -inherit ${XORGBUILDCLASS} pkgconfig features_check
> > > > +inherit_defer ${XORGBUILDCLASS} pkgconfig features_check
> > >
> > > As above.
> > >
> > > > -inherit autotools texinfo binconfig-disabled pkgconfig ${PYTHON_INHERIT} python3native multilib_header
> > > > +inherit autotools texinfo binconfig-disabled pkgconfig multilib_header
> > > > +inherit_defer ${PYTHON_INHERIT} python3native
> > >
> > > Why is python3native defered?
> >
> > In the past there were some ordering issues around the python classes
> > so I was just being careful not to cause more problems in the patchset
> > than I was already trying to debug. It probably isn't necessary but at
> > the time I wasn't 100% sure and there were bigger issues.
> >
> > I can make the above tweaks if they really bother you...
> >
>
> Look into evolution-data-server-native.bb from meta-gnome
> it inherits native and provides own default do_compile/do_install functions
>
> it now needs to use
> inherit_defer native
>
> which parses but then the functions provided by the recipe are overridden
> by ones from autotools class perhaps because it is deferred too ?
>

To add a bit more
diff --git a/meta-gnome/recipes-gnome/evolution-data-server/evolution-data-server-native.bb
b/meta-gnome/recipes-gnome/evolution-data-server/evolution-data-server-native.bb
index 8f5c9ffb67..e163576c02 100644
--- a/meta-gnome/recipes-gnome/evolution-data-server/evolution-data-server-native.bb
+++ b/meta-gnome/recipes-gnome/evolution-data-server/evolution-data-server-native.bb
@@ -5,7 +5,7 @@ inherit_defer native
 DEPENDS = "glib-2.0-native"

 # build native helpers
-do_compile() {
+do_compile:class-native() {
     cd ${S}/src/camel
     sed -i 's:#include "evolution-data-server-config.h"::g' camel-gen-tables.c
     ${CC} -o ${B}/camel-gen-tables camel-gen-tables.c ${CFLAGS} ${LDFLAGS}
@@ -17,7 +17,7 @@ do_compile() {
     ${CC} -o ${B}/gen-western-table gen-western-table.c ${CFLAGS}
${CFLAGS_glib} ${LDFLAGS} ${LDFLAGS_glib}
 }

-do_install() {
+do_install:class-native() {
     install -d ${D}${bindir}
     install -m 755 ${B}/* ${D}${bindir}
 }

works, but it seems wrong to do it like this

> > Cheers,
> >
> > Richard
> >
> >
> >
> >
> >
> > -=-=-=-=-=-=-=-=-=-=-=-
> > Links: You receive all messages sent to this group.
> > View/Reply Online (#193434): https://lists.openembedded.org/g/openembedded-core/message/193434
> > Mute This Topic: https://lists.openembedded.org/mt/103502916/1997914
> > Group Owner: openembedded-core+owner@lists.openembedded.org
> > Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [raj.khem@gmail.com]
> > -=-=-=-=-=-=-=-=-=-=-=-
> >
Richard Purdie Jan. 9, 2024, 11:31 a.m. UTC | #5
On Mon, 2024-01-08 at 19:53 -0800, Khem Raj wrote:
> On Mon, Jan 8, 2024 at 7:49 PM Khem Raj <raj.khem@gmail.com> wrote:
> > 
> > On Mon, Jan 8, 2024 at 2:39 PM Richard Purdie
> > <richard.purdie@linuxfoundation.org> wrote:
> > > 
> > > On Mon, 2024-01-08 at 17:14 +0000, Ross Burton wrote:
> > > > On 3 Jan 2024, at 14:59, Richard Purdie via lists.openembedded.org <richard.purdie=linuxfoundation.org@lists.openembedded.org> wrote:
> > > > > --- a/meta/classes-recipe/gnomebase.bbclass
> > > > > +++ b/meta/classes-recipe/gnomebase.bbclass
> > > > > @@ -28,7 +28,7 @@ FILES:${PN} += "${datadir}/application-registry  \
> > > > > FILES:${PN}-doc += "${datadir}/devhelp"
> > > > > 
> > > > > GNOMEBASEBUILDCLASS ??= "meson"
> > > > > -inherit ${GNOMEBASEBUILDCLASS} pkgconfig
> > > > > +inherit_defer ${GNOMEBASEBUILDCLASS} pkgconfig
> > > > 
> > > > Feels like this should be split into inherit pkgconfig and inher_defer ${GNOMEBASEBUILDCLASS}.
> > > 
> > > I guess did it this way for ease in the patch, it won't really make
> > > much difference either way, particularly for pkgconfig given how simple
> > > that class is.
> > > 
> > > > 
> > > > > +inherit populate_sdk_base
> > > > > +IMGCLASSES += "${@['', 'populate_sdk_ext']['linux' in d.getVar("SDK_OS")]}"
> > > > 
> > > > Whilst you’re here change this to foo if bar else flob, this boolean subsetting idiom drives me insane.
> > > 
> > > I don't really mixing up changes as it just makes review harder so
> > > whilst I don't mind changing that, I think it should be done
> > > separately.
> > > 
> > > > > --- a/meta/recipes-graphics/xorg-driver/xorg-driver-common.inc
> > > > > +++ b/meta/recipes-graphics/xorg-driver/xorg-driver-common.inc
> > > > > @@ -14,7 +14,7 @@ SRC_URI = "${XORG_MIRROR}/individual/driver/${BPN}-${PV}${XORG_DRIVER_COMPRESSOR
> > > > > FILES:${PN} += " ${libdir}/xorg/modules/drivers/*.so"
> > > > > 
> > > > > XORGBUILDCLASS ??= "autotools"
> > > > > -inherit ${XORGBUILDCLASS} pkgconfig features_check
> > > > > +inherit_defer ${XORGBUILDCLASS} pkgconfig features_check
> > > > 
> > > > As above.
> > > > 
> > > > > -inherit autotools texinfo binconfig-disabled pkgconfig ${PYTHON_INHERIT} python3native multilib_header
> > > > > +inherit autotools texinfo binconfig-disabled pkgconfig multilib_header
> > > > > +inherit_defer ${PYTHON_INHERIT} python3native
> > > > 
> > > > Why is python3native defered?
> > > 
> > > In the past there were some ordering issues around the python classes
> > > so I was just being careful not to cause more problems in the patchset
> > > than I was already trying to debug. It probably isn't necessary but at
> > > the time I wasn't 100% sure and there were bigger issues.
> > > 
> > > I can make the above tweaks if they really bother you...
> > > 
> > 
> > Look into evolution-data-server-native.bb from meta-gnome
> > it inherits native and provides own default do_compile/do_install functions
> > 
> > it now needs to use
> > inherit_defer native
> > 
> > which parses but then the functions provided by the recipe are overridden
> > by ones from autotools class perhaps because it is deferred too ?
> > 
> 
> To add a bit more
> diff --git a/meta-gnome/recipes-gnome/evolution-data-server/evolution-data-server-native.bb
> b/meta-gnome/recipes-gnome/evolution-data-server/evolution-data-server-native.bb
> index 8f5c9ffb67..e163576c02 100644
> --- a/meta-gnome/recipes-gnome/evolution-data-server/evolution-data-server-native.bb
> +++ b/meta-gnome/recipes-gnome/evolution-data-server/evolution-data-server-native.bb
> @@ -5,7 +5,7 @@ inherit_defer native
>  DEPENDS = "glib-2.0-native"
> 
>  # build native helpers
> -do_compile() {
> +do_compile:class-native() {
>      cd ${S}/src/camel
>      sed -i 's:#include "evolution-data-server-config.h"::g' camel-gen-tables.c
>      ${CC} -o ${B}/camel-gen-tables camel-gen-tables.c ${CFLAGS} ${LDFLAGS}
> @@ -17,7 +17,7 @@ do_compile() {
>      ${CC} -o ${B}/gen-western-table gen-western-table.c ${CFLAGS}
> ${CFLAGS_glib} ${LDFLAGS} ${LDFLAGS_glib}
>  }
> 
> -do_install() {
> +do_install:class-native() {
>      install -d ${D}${bindir}
>      install -m 755 ${B}/* ${D}${bindir}
>  }
> 
> works, but it seems wrong to do it like this

This is the unfortunate corner case this change triggers unfortunately.

The gnomebase class has a conditional variable for whether to use
autotools or meson. This means meson/autotools are put into
inherit_defer since they depend on the value of GNOMEBASEBUILDCLASS.

This means autotools is deferred to after these variables are set and
the values from the class override the originals. That said, autotools
uses EXPORT_FUNCTIONS against do_compile this so it should not happen.

I did dive into what is actually going on and the issue is that
do_compile is an EXPORT_FUNCTION from both base.bbclass and from
autotools.bbclass.

export functions overwrite their own versions, the issue looks to be
that the setting from base.bbclass sets the magic flag to say it is
special and the new value from the recipe doesn't clear the magic flag.
That would be a separate bug. I think we can improve the
export_functions logic to fix that.

I do agree this kind of issue isn't optimal however I think some of the
current behaviours are probably worse and if we can move core classes
away from deferred inherits (e.g. let gnome recipes pick autotools or
meson directly), these issues should be rare.

Cheers,

Richard
Richard Purdie Jan. 9, 2024, 2:17 p.m. UTC | #6
On Tue, 2024-01-09 at 11:31 +0000, Richard Purdie via
lists.openembedded.org wrote:
> On Mon, 2024-01-08 at 19:53 -0800, Khem Raj wrote:
> > On Mon, Jan 8, 2024 at 7:49 PM Khem Raj <raj.khem@gmail.com> wrote:
> > > 
> > > On Mon, Jan 8, 2024 at 2:39 PM Richard Purdie
> > > <richard.purdie@linuxfoundation.org> wrote:
> > > > 
> > > > On Mon, 2024-01-08 at 17:14 +0000, Ross Burton wrote:
> > > > > On 3 Jan 2024, at 14:59, Richard Purdie via lists.openembedded.org <richard.purdie=linuxfoundation.org@lists.openembedded.org> wrote:
> > > > > > --- a/meta/classes-recipe/gnomebase.bbclass
> > > > > > +++ b/meta/classes-recipe/gnomebase.bbclass
> > > > > > @@ -28,7 +28,7 @@ FILES:${PN} += "${datadir}/application-registry  \
> > > > > > FILES:${PN}-doc += "${datadir}/devhelp"
> > > > > > 
> > > > > > GNOMEBASEBUILDCLASS ??= "meson"
> > > > > > -inherit ${GNOMEBASEBUILDCLASS} pkgconfig
> > > > > > +inherit_defer ${GNOMEBASEBUILDCLASS} pkgconfig
> > > > > 
> > > > > Feels like this should be split into inherit pkgconfig and inher_defer ${GNOMEBASEBUILDCLASS}.
> > > > 
> > > > I guess did it this way for ease in the patch, it won't really make
> > > > much difference either way, particularly for pkgconfig given how simple
> > > > that class is.
> > > > 
> > > > > 
> > > > > > +inherit populate_sdk_base
> > > > > > +IMGCLASSES += "${@['', 'populate_sdk_ext']['linux' in d.getVar("SDK_OS")]}"
> > > > > 
> > > > > Whilst you’re here change this to foo if bar else flob, this boolean subsetting idiom drives me insane.
> > > > 
> > > > I don't really mixing up changes as it just makes review harder so
> > > > whilst I don't mind changing that, I think it should be done
> > > > separately.
> > > > 
> > > > > > --- a/meta/recipes-graphics/xorg-driver/xorg-driver-common.inc
> > > > > > +++ b/meta/recipes-graphics/xorg-driver/xorg-driver-common.inc
> > > > > > @@ -14,7 +14,7 @@ SRC_URI = "${XORG_MIRROR}/individual/driver/${BPN}-${PV}${XORG_DRIVER_COMPRESSOR
> > > > > > FILES:${PN} += " ${libdir}/xorg/modules/drivers/*.so"
> > > > > > 
> > > > > > XORGBUILDCLASS ??= "autotools"
> > > > > > -inherit ${XORGBUILDCLASS} pkgconfig features_check
> > > > > > +inherit_defer ${XORGBUILDCLASS} pkgconfig features_check
> > > > > 
> > > > > As above.
> > > > > 
> > > > > > -inherit autotools texinfo binconfig-disabled pkgconfig ${PYTHON_INHERIT} python3native multilib_header
> > > > > > +inherit autotools texinfo binconfig-disabled pkgconfig multilib_header
> > > > > > +inherit_defer ${PYTHON_INHERIT} python3native
> > > > > 
> > > > > Why is python3native defered?
> > > > 
> > > > In the past there were some ordering issues around the python classes
> > > > so I was just being careful not to cause more problems in the patchset
> > > > than I was already trying to debug. It probably isn't necessary but at
> > > > the time I wasn't 100% sure and there were bigger issues.
> > > > 
> > > > I can make the above tweaks if they really bother you...
> > > > 
> > > 
> > > Look into evolution-data-server-native.bb from meta-gnome
> > > it inherits native and provides own default do_compile/do_install functions
> > > 
> > > it now needs to use
> > > inherit_defer native
> > > 
> > > which parses but then the functions provided by the recipe are overridden
> > > by ones from autotools class perhaps because it is deferred too ?
> > > 
> > 
> > To add a bit more
> > diff --git a/meta-gnome/recipes-gnome/evolution-data-server/evolution-data-server-native.bb
> > b/meta-gnome/recipes-gnome/evolution-data-server/evolution-data-server-native.bb
> > index 8f5c9ffb67..e163576c02 100644
> > --- a/meta-gnome/recipes-gnome/evolution-data-server/evolution-data-server-native.bb
> > +++ b/meta-gnome/recipes-gnome/evolution-data-server/evolution-data-server-native.bb
> > @@ -5,7 +5,7 @@ inherit_defer native
> >  DEPENDS = "glib-2.0-native"
> > 
> >  # build native helpers
> > -do_compile() {
> > +do_compile:class-native() {
> >      cd ${S}/src/camel
> >      sed -i 's:#include "evolution-data-server-config.h"::g' camel-gen-tables.c
> >      ${CC} -o ${B}/camel-gen-tables camel-gen-tables.c ${CFLAGS} ${LDFLAGS}
> > @@ -17,7 +17,7 @@ do_compile() {
> >      ${CC} -o ${B}/gen-western-table gen-western-table.c ${CFLAGS}
> > ${CFLAGS_glib} ${LDFLAGS} ${LDFLAGS_glib}
> >  }
> > 
> > -do_install() {
> > +do_install:class-native() {
> >      install -d ${D}${bindir}
> >      install -m 755 ${B}/* ${D}${bindir}
> >  }
> > 
> > works, but it seems wrong to do it like this
> 
> This is the unfortunate corner case this change triggers unfortunately.
> 
> The gnomebase class has a conditional variable for whether to use
> autotools or meson. This means meson/autotools are put into
> inherit_defer since they depend on the value of GNOMEBASEBUILDCLASS.
> 
> This means autotools is deferred to after these variables are set and
> the values from the class override the originals. That said, autotools
> uses EXPORT_FUNCTIONS against do_compile this so it should not happen.
> 
> I did dive into what is actually going on and the issue is that
> do_compile is an EXPORT_FUNCTION from both base.bbclass and from
> autotools.bbclass.
> 
> export functions overwrite their own versions, the issue looks to be
> that the setting from base.bbclass sets the magic flag to say it is
> special and the new value from the recipe doesn't clear the magic flag.
> That would be a separate bug. I think we can improve the
> export_functions logic to fix that.
> 
> I do agree this kind of issue isn't optimal however I think some of the
> current behaviours are probably worse and if we can move core classes
> away from deferred inherits (e.g. let gnome recipes pick autotools or
> meson directly), these issues should be rare.

There is a patch for bitbake on master-next which fixes
EXPORT_FUNCTIONS and adds tests for it. That should fix the issue here.

Cheers,

Richard
Patrick Williams Jan. 22, 2024, 4:08 p.m. UTC | #7
On Wed, Jan 03, 2024 at 02:59:02PM +0000, Richard Purdie wrote:
>  meta/recipes-core/libxml/libxml2_2.11.5.bb                   | 2 +-

I'm seeing some issues after this commit with libxml and Python
PATH, etc. variables.  I opened a bugzilla but maybe I should have
reported it to this mailing list first.

https://bugzilla.yoctoproject.org/show_bug.cgi?id=15361
Patrick Williams Jan. 22, 2024, 5:37 p.m. UTC | #8
On Mon, Jan 22, 2024 at 10:08:56AM -0600, Patrick Williams wrote:
> On Wed, Jan 03, 2024 at 02:59:02PM +0000, Richard Purdie wrote:
> >  meta/recipes-core/libxml/libxml2_2.11.5.bb                   | 2 +-
> 
> I'm seeing some issues after this commit with libxml and Python
> PATH, etc. variables.  I opened a bugzilla but maybe I should have
> reported it to this mailing list first.
> 
> https://bugzilla.yoctoproject.org/show_bug.cgi?id=15361

I added some more data to the bugzilla but it seems like the expand
calls in bitbake's BBHandler.py inherit function are ending up with the
wrong class-target instead of class-native, even though this is being
compiled as `libxml2-native`, and we happen to have a `class-target`
override that removes python from the PACKAGECONFIG.
diff mbox series

Patch

diff --git a/meta-selftest/recipes-test/overlayfs-user/overlayfs-user.bb b/meta-selftest/recipes-test/overlayfs-user/overlayfs-user.bb
index 50cba9514bf..88c8998cf9e 100644
--- a/meta-selftest/recipes-test/overlayfs-user/overlayfs-user.bb
+++ b/meta-selftest/recipes-test/overlayfs-user/overlayfs-user.bb
@@ -5,7 +5,7 @@  LICENSE = "MIT"
 INHIBIT_DEFAULT_DEPS = "1"
 EXCLUDE_FROM_WORLD = "1"
 
-inherit ${@bb.utils.contains("DISTRO_FEATURES", "overlayfs", "overlayfs", "", d)}
+inherit_defer ${@bb.utils.contains("DISTRO_FEATURES", "overlayfs", "overlayfs", "", d)}
 include test_recipe.inc
 
 OVERLAYFS_WRITABLE_PATHS[mnt-overlay] += "/usr/share/my-application"
diff --git a/meta/classes-recipe/baremetal-image.bbclass b/meta/classes-recipe/baremetal-image.bbclass
index 70791f999ac..b9a584351a1 100644
--- a/meta/classes-recipe/baremetal-image.bbclass
+++ b/meta/classes-recipe/baremetal-image.bbclass
@@ -110,7 +110,7 @@  CFLAGS:append:qemuriscv64 = " -mcmodel=medany"
 # Handle inherits of any of the image classes we need
 IMAGE_CLASSES ??= ""
 IMGCLASSES = " ${IMAGE_CLASSES}"
-inherit ${IMGCLASSES}
+inherit_defer ${IMGCLASSES}
 # Set defaults to satisfy IMAGE_FEATURES check
 IMAGE_FEATURES ?= ""
 IMAGE_FEATURES[type] = "list"
diff --git a/meta/classes-recipe/gnomebase.bbclass b/meta/classes-recipe/gnomebase.bbclass
index a12e9f31a95..09abb039909 100644
--- a/meta/classes-recipe/gnomebase.bbclass
+++ b/meta/classes-recipe/gnomebase.bbclass
@@ -28,7 +28,7 @@  FILES:${PN} += "${datadir}/application-registry  \
 FILES:${PN}-doc += "${datadir}/devhelp"
 
 GNOMEBASEBUILDCLASS ??= "meson"
-inherit ${GNOMEBASEBUILDCLASS} pkgconfig
+inherit_defer ${GNOMEBASEBUILDCLASS} pkgconfig
 
 do_install:append() {
 	rm -rf ${D}${localstatedir}/lib/scrollkeeper/*
diff --git a/meta/classes-recipe/image.bbclass b/meta/classes-recipe/image.bbclass
index 6bdddc0134c..28be6c63623 100644
--- a/meta/classes-recipe/image.bbclass
+++ b/meta/classes-recipe/image.bbclass
@@ -14,14 +14,15 @@  ROOTFS_BOOTSTRAP_INSTALL = "run-postinsts"
 IMGCLASSES = "rootfs_${IMAGE_PKGTYPE} image_types ${IMAGE_CLASSES}"
 # Only Linux SDKs support populate_sdk_ext, fall back to populate_sdk_base
 # in the non-Linux SDK_OS case, such as mingw32
-IMGCLASSES += "${@['populate_sdk_base', 'populate_sdk_ext']['linux' in d.getVar("SDK_OS")]}"
+inherit populate_sdk_base
+IMGCLASSES += "${@['', 'populate_sdk_ext']['linux' in d.getVar("SDK_OS")]}"
 IMGCLASSES += "${@bb.utils.contains_any('IMAGE_FSTYPES', 'live iso hddimg', 'image-live', '', d)}"
 IMGCLASSES += "${@bb.utils.contains('IMAGE_FSTYPES', 'container', 'image-container', '', d)}"
 IMGCLASSES += "image_types_wic"
 IMGCLASSES += "rootfs-postcommands"
 IMGCLASSES += "image-postinst-intercepts"
 IMGCLASSES += "overlayfs-etc"
-inherit ${IMGCLASSES}
+inherit_defer ${IMGCLASSES}
 
 TOOLCHAIN_TARGET_TASK += "${PACKAGE_INSTALL}"
 TOOLCHAIN_TARGET_TASK_ATTEMPTONLY += "${PACKAGE_INSTALL_ATTEMPTONLY}"
diff --git a/meta/classes-recipe/image_types_wic.bbclass b/meta/classes-recipe/image_types_wic.bbclass
index 669606da75a..00620fdc9d1 100644
--- a/meta/classes-recipe/image_types_wic.bbclass
+++ b/meta/classes-recipe/image_types_wic.bbclass
@@ -38,7 +38,7 @@  WICVARS ?= "\
 	TARGET_SYS \
 "
 
-inherit ${@bb.utils.contains('INITRAMFS_IMAGE_BUNDLE', '1', 'kernel-artifact-names', '', d)}
+inherit_defer ${@bb.utils.contains('INITRAMFS_IMAGE_BUNDLE', '1', 'kernel-artifact-names', '', d)}
 
 WKS_FILE ??= "${IMAGE_BASENAME}.${MACHINE}.wks"
 WKS_FILES ?= "${WKS_FILE} ${IMAGE_BASENAME}.wks"
diff --git a/meta/classes-recipe/kernel.bbclass b/meta/classes-recipe/kernel.bbclass
index 9ff37f5c38c..a76aaee5bac 100644
--- a/meta/classes-recipe/kernel.bbclass
+++ b/meta/classes-recipe/kernel.bbclass
@@ -171,7 +171,7 @@  set -e
 # image types.
 
 KERNEL_CLASSES ?= " kernel-uimage "
-inherit ${KERNEL_CLASSES}
+inherit_defer ${KERNEL_CLASSES}
 
 # Old style kernels may set ${S} = ${WORKDIR}/git for example
 # We need to move these over to STAGING_KERNEL_DIR. We can't just
diff --git a/meta/classes-recipe/live-vm-common.bbclass b/meta/classes-recipe/live-vm-common.bbclass
index b619f3a4be0..d90cc67ebc3 100644
--- a/meta/classes-recipe/live-vm-common.bbclass
+++ b/meta/classes-recipe/live-vm-common.bbclass
@@ -68,8 +68,8 @@  efi_hddimg_populate() {
 	efi_populate $1
 }
 
-inherit ${EFI_CLASS}
-inherit ${PCBIOS_CLASS}
+inherit_defer ${EFI_CLASS}
+inherit_defer ${PCBIOS_CLASS}
 
 populate_kernel() {
 	dest=$1
diff --git a/meta/classes-recipe/packagegroup.bbclass b/meta/classes-recipe/packagegroup.bbclass
index c2db6649045..cf6fc354a81 100644
--- a/meta/classes-recipe/packagegroup.bbclass
+++ b/meta/classes-recipe/packagegroup.bbclass
@@ -22,7 +22,7 @@  PACKAGE_ARCH_EXPANDED := "${PACKAGE_ARCH}"
 
 LICENSE ?= "MIT"
 
-inherit ${@oe.utils.ifelse(d.getVar('PACKAGE_ARCH_EXPANDED') == 'all', 'allarch', '')}
+inherit_defer ${@oe.utils.ifelse(d.getVar('PACKAGE_ARCH_EXPANDED') == 'all', 'allarch', '')}
 
 # This automatically adds -dbg and -dev flavours of all PACKAGES
 # to the list. Their dependencies (RRECOMMENDS) are handled as usual
diff --git a/meta/classes-recipe/populate_sdk_base.bbclass b/meta/classes-recipe/populate_sdk_base.bbclass
index 8fadfef9422..81896d808f5 100644
--- a/meta/classes-recipe/populate_sdk_base.bbclass
+++ b/meta/classes-recipe/populate_sdk_base.bbclass
@@ -37,7 +37,7 @@  SDK_PACKAGE_ARCHS += "sdk-provides-dummy-${SDKPKGSUFFIX}"
 # List of locales to install, or "all" for all of them, or unset for none.
 SDKIMAGE_LINGUAS ?= "all"
 
-inherit rootfs_${IMAGE_PKGTYPE}
+inherit_defer rootfs_${IMAGE_PKGTYPE}
 
 SDK_DIR = "${WORKDIR}/sdk"
 SDK_OUTPUT = "${SDK_DIR}/image"
diff --git a/meta/classes/useradd.bbclass b/meta/classes/useradd.bbclass
index 0997b3da7a5..cb809b5dd74 100644
--- a/meta/classes/useradd.bbclass
+++ b/meta/classes/useradd.bbclass
@@ -268,4 +268,4 @@  fakeroot python populate_packages:prepend () {
 # Use the following to extend the useradd with custom functions
 USERADDEXTENSION ?= ""
 
-inherit ${USERADDEXTENSION}
+inherit_defer ${USERADDEXTENSION}
diff --git a/meta/recipes-core/libxml/libxml2_2.11.5.bb b/meta/recipes-core/libxml/libxml2_2.11.5.bb
index 319833f053e..44336c25e1c 100644
--- a/meta/recipes-core/libxml/libxml2_2.11.5.bb
+++ b/meta/recipes-core/libxml/libxml2_2.11.5.bb
@@ -35,7 +35,7 @@  PACKAGECONFIG[ipv6] = "--enable-ipv6,--disable-ipv6,"
 
 inherit autotools pkgconfig binconfig-disabled ptest
 
-inherit ${@bb.utils.contains('PACKAGECONFIG', 'python', 'python3targetconfig', '', d)}
+inherit_defer ${@bb.utils.contains('PACKAGECONFIG', 'python', 'python3targetconfig', '', d)}
 
 LDFLAGS:append:riscv64 = "${@bb.utils.contains('DISTRO_FEATURES', 'ld-is-lld ptest', ' -fuse-ld=bfd', '', d)}"
 
diff --git a/meta/recipes-core/packagegroups/nativesdk-packagegroup-sdk-host.bb b/meta/recipes-core/packagegroups/nativesdk-packagegroup-sdk-host.bb
index 11e31dcba3b..c1d3c250605 100644
--- a/meta/recipes-core/packagegroups/nativesdk-packagegroup-sdk-host.bb
+++ b/meta/recipes-core/packagegroups/nativesdk-packagegroup-sdk-host.bb
@@ -4,7 +4,8 @@ 
 
 SUMMARY = "Host packages for the standalone SDK or external toolchain"
 
-inherit packagegroup nativesdk
+inherit packagegroup
+inherit_defer nativesdk
 
 PACKAGEGROUP_DISABLE_COMPLEMENTARY = "1"
 
diff --git a/meta/recipes-devtools/btrfs-tools/btrfs-tools_6.5.3.bb b/meta/recipes-devtools/btrfs-tools/btrfs-tools_6.5.3.bb
index 873d5e7a14b..6455efd1bca 100644
--- a/meta/recipes-devtools/btrfs-tools/btrfs-tools_6.5.3.bb
+++ b/meta/recipes-devtools/btrfs-tools/btrfs-tools_6.5.3.bb
@@ -43,7 +43,7 @@  PACKAGECONFIG[crypto-libsodium] = "--with-crypto=libsodium,,libsodium"
 PACKAGECONFIG[crypto-libkcapi] = "--with-crypto=libkcapi,,libkcapi"
 
 inherit autotools-brokensep pkgconfig manpages
-inherit ${@bb.utils.contains('PACKAGECONFIG', 'python', 'setuptools3-base', '', d)}
+inherit_defer ${@bb.utils.contains('PACKAGECONFIG', 'python', 'setuptools3-base', '', d)}
 
 CLEANBROKEN = "1"
 
diff --git a/meta/recipes-graphics/xorg-driver/xorg-driver-common.inc b/meta/recipes-graphics/xorg-driver/xorg-driver-common.inc
index 8b3f19426bc..f3744922c0c 100644
--- a/meta/recipes-graphics/xorg-driver/xorg-driver-common.inc
+++ b/meta/recipes-graphics/xorg-driver/xorg-driver-common.inc
@@ -14,7 +14,7 @@  SRC_URI = "${XORG_MIRROR}/individual/driver/${BPN}-${PV}${XORG_DRIVER_COMPRESSOR
 FILES:${PN} += " ${libdir}/xorg/modules/drivers/*.so"
 
 XORGBUILDCLASS ??= "autotools"
-inherit ${XORGBUILDCLASS} pkgconfig features_check
+inherit_defer ${XORGBUILDCLASS} pkgconfig features_check
 
 # depends on virtual/xserver
 REQUIRED_DISTRO_FEATURES = "x11"
diff --git a/meta/recipes-kernel/perf/perf.bb b/meta/recipes-kernel/perf/perf.bb
index 32882afdf4e..4f26813de02 100644
--- a/meta/recipes-kernel/perf/perf.bb
+++ b/meta/recipes-kernel/perf/perf.bb
@@ -54,7 +54,7 @@  PROVIDES = "virtual/perf"
 inherit linux-kernel-base kernel-arch manpages
 
 # needed for building the tools/perf Python bindings
-inherit ${@bb.utils.contains('PACKAGECONFIG', 'python', 'python3targetconfig', '', d)}
+inherit_defer ${@bb.utils.contains('PACKAGECONFIG', 'python', 'python3targetconfig', '', d)}
 inherit python3-dir
 export PYTHON_SITEPACKAGES_DIR
 
diff --git a/meta/recipes-kernel/systemtap/systemtap-native_git.bb b/meta/recipes-kernel/systemtap/systemtap-native_git.bb
index 19cc1cf0f0a..2690b259c8b 100644
--- a/meta/recipes-kernel/systemtap/systemtap-native_git.bb
+++ b/meta/recipes-kernel/systemtap/systemtap-native_git.bb
@@ -1,6 +1,6 @@ 
 
 require systemtap_git.bb
 
-inherit native
+inherit_defer native
 
 addtask addto_recipe_sysroot after do_populate_sysroot before do_build
diff --git a/meta/recipes-kernel/systemtap/systemtap_git.bb b/meta/recipes-kernel/systemtap/systemtap_git.bb
index 0a1349e1280..68f5c764282 100644
--- a/meta/recipes-kernel/systemtap/systemtap_git.bb
+++ b/meta/recipes-kernel/systemtap/systemtap_git.bb
@@ -33,7 +33,7 @@  PACKAGECONFIG[python3-probes] = "--with-python3-probes,--without-python3-probes,
 PACKAGECONFIG[debuginfod] = "--with-debuginfod, --without-debuginfod"
 
 inherit autotools gettext pkgconfig systemd
-inherit ${@bb.utils.contains('PACKAGECONFIG', 'python3-probes', 'setuptools3-base', '', d)}
+inherit_defer ${@bb.utils.contains('PACKAGECONFIG', 'python3-probes', 'setuptools3-base', '', d)}
 
 # | ../git/elaborate.cxx:2601:21: error: storing the address of local variable 'sym' in '*s.systemtap_session::symbol_resolver' [-Werror=dangling-pointer=]
 CXXFLAGS += "-Wno-dangling-pointer"
diff --git a/meta/recipes-support/gpgme/gpgme_1.23.2.bb b/meta/recipes-support/gpgme/gpgme_1.23.2.bb
index b29c182f365..d8807b3af26 100644
--- a/meta/recipes-support/gpgme/gpgme_1.23.2.bb
+++ b/meta/recipes-support/gpgme/gpgme_1.23.2.bb
@@ -54,7 +54,8 @@  EXTRA_OECONF += '--enable-languages="${LANGUAGES}" \
                  --disable-g13-test \
 '
 
-inherit autotools texinfo binconfig-disabled pkgconfig ${PYTHON_INHERIT} python3native multilib_header
+inherit autotools texinfo binconfig-disabled pkgconfig multilib_header
+inherit_defer ${PYTHON_INHERIT} python3native
 
 export PKG_CONFIG='pkg-config'