diff mbox series

[v5,2/3] mesa: add support for RustiCL under PACKAGECONFIG "opencl"

Message ID 20231230191444.1204808-3-dmitry.baryshkov@linaro.org
State New
Headers show
Series mesa: RustiCL support | expand

Commit Message

Dmitry Baryshkov Dec. 30, 2023, 7:14 p.m. UTC
From: Zoltán Böszörményi <zboszor@gmail.com>

Mesa now has two OpenCL implementations: Clover (older one) and RustiCL
(newer one). Extend the "opencl" package config to include both
implementations into the libopencl-mesa (-dev) packages. As the Clover
implementation is in maintenance mode and is expected to be removed at
some point, it doesn't make sense to split the packages or to provide
two config options.

Signed-off-by: Zoltán Böszörményi <zboszor@gmail.com>
[DB: reworked rust class inheritance]
[DB: merged "rusticl" and "clover" back to "opencl"]
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
---
 meta/recipes-graphics/mesa/mesa.inc | 21 ++++++++++++++++-----
 1 file changed, 16 insertions(+), 5 deletions(-)

Comments

Richard Purdie Dec. 30, 2023, 9:02 p.m. UTC | #1
On Sat, 2023-12-30 at 21:14 +0200, Dmitry Baryshkov wrote:
> From: Zoltán Böszörményi <zboszor@gmail.com>
> 
> Mesa now has two OpenCL implementations: Clover (older one) and RustiCL
> (newer one). Extend the "opencl" package config to include both
> implementations into the libopencl-mesa (-dev) packages. As the Clover
> implementation is in maintenance mode and is expected to be removed at
> some point, it doesn't make sense to split the packages or to provide
> two config options.
> 
> Signed-off-by: Zoltán Böszörményi <zboszor@gmail.com>
> [DB: reworked rust class inheritance]
> [DB: merged "rusticl" and "clover" back to "opencl"]
> Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
> ---
>  meta/recipes-graphics/mesa/mesa.inc | 21 ++++++++++++++++-----
>  1 file changed, 16 insertions(+), 5 deletions(-)
> 
> diff --git a/meta/recipes-graphics/mesa/mesa.inc b/meta/recipes-graphics/mesa/mesa.inc
> index efbce5caade5..a192562a7935 100644
> --- a/meta/recipes-graphics/mesa/mesa.inc
> +++ b/meta/recipes-graphics/mesa/mesa.inc
> @@ -48,6 +48,12 @@ PROVIDES = " \
>  
>  inherit meson pkgconfig python3native gettext features_check
>  
> +# We can not include rust conditionally, otherwise it can not be overriden by
> +# the bbappends.  Instead always include it, but remove the dependencies by
> +# default.
> +inherit rust
> +INHIBIT_DEFAULT_RUST_DEPS = "${@bb.utils.contains('PACKAGECONFIG', 'opencl', '', '1', d)}"
> +

I'd really prefer not to have the rust inherit unconditionally. I have
some ideas about how we could fix this in bitbake so we may need to
wait for that if we can't avoid the PACKAGECONFIG issue from appends...

Cheers,

Richard
Dmitry Baryshkov Jan. 2, 2024, 10:32 a.m. UTC | #2
On Sat, 30 Dec 2023 at 23:02, Richard Purdie
<richard.purdie@linuxfoundation.org> wrote:
>
> On Sat, 2023-12-30 at 21:14 +0200, Dmitry Baryshkov wrote:
> > From: Zoltán Böszörményi <zboszor@gmail.com>
> >
> > Mesa now has two OpenCL implementations: Clover (older one) and RustiCL
> > (newer one). Extend the "opencl" package config to include both
> > implementations into the libopencl-mesa (-dev) packages. As the Clover
> > implementation is in maintenance mode and is expected to be removed at
> > some point, it doesn't make sense to split the packages or to provide
> > two config options.
> >
> > Signed-off-by: Zoltán Böszörményi <zboszor@gmail.com>
> > [DB: reworked rust class inheritance]
> > [DB: merged "rusticl" and "clover" back to "opencl"]
> > Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
> > ---
> >  meta/recipes-graphics/mesa/mesa.inc | 21 ++++++++++++++++-----
> >  1 file changed, 16 insertions(+), 5 deletions(-)
> >
> > diff --git a/meta/recipes-graphics/mesa/mesa.inc b/meta/recipes-graphics/mesa/mesa.inc
> > index efbce5caade5..a192562a7935 100644
> > --- a/meta/recipes-graphics/mesa/mesa.inc
> > +++ b/meta/recipes-graphics/mesa/mesa.inc
> > @@ -48,6 +48,12 @@ PROVIDES = " \
> >
> >  inherit meson pkgconfig python3native gettext features_check
> >
> > +# We can not include rust conditionally, otherwise it can not be overriden by
> > +# the bbappends.  Instead always include it, but remove the dependencies by
> > +# default.
> > +inherit rust
> > +INHIBIT_DEFAULT_RUST_DEPS = "${@bb.utils.contains('PACKAGECONFIG', 'opencl', '', '1', d)}"
> > +
>
> I'd really prefer not to have the rust inherit unconditionally. I have
> some ideas about how we could fix this in bitbake so we may need to
> wait for that if we can't avoid the PACKAGECONFIG issue from appends...

Well, it's not just appends. Extending PACKAGECONFIG from local.conf
also doesn't work. In fact even adding "opencl" to the default
PACKAGECONFIG doesn't work unless I move `inherit
@{bb.utils.contains....` after the PACKAGECONFIG definition. Using
`INHIBIT_DEFAULT_RUST_DEPS` works around that issue, but yes, it has a
drawback of including rust unconditionally.
Richard Purdie Jan. 2, 2024, 11:40 a.m. UTC | #3
On Tue, 2024-01-02 at 12:32 +0200, Dmitry Baryshkov wrote:
> On Sat, 30 Dec 2023 at 23:02, Richard Purdie
> <richard.purdie@linuxfoundation.org> wrote:
> > 
> > On Sat, 2023-12-30 at 21:14 +0200, Dmitry Baryshkov wrote:
> > > From: Zoltán Böszörményi <zboszor@gmail.com>
> > > 
> > > Mesa now has two OpenCL implementations: Clover (older one) and RustiCL
> > > (newer one). Extend the "opencl" package config to include both
> > > implementations into the libopencl-mesa (-dev) packages. As the Clover
> > > implementation is in maintenance mode and is expected to be removed at
> > > some point, it doesn't make sense to split the packages or to provide
> > > two config options.
> > > 
> > > Signed-off-by: Zoltán Böszörményi <zboszor@gmail.com>
> > > [DB: reworked rust class inheritance]
> > > [DB: merged "rusticl" and "clover" back to "opencl"]
> > > Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
> > > ---
> > >  meta/recipes-graphics/mesa/mesa.inc | 21 ++++++++++++++++-----
> > >  1 file changed, 16 insertions(+), 5 deletions(-)
> > > 
> > > diff --git a/meta/recipes-graphics/mesa/mesa.inc b/meta/recipes-graphics/mesa/mesa.inc
> > > index efbce5caade5..a192562a7935 100644
> > > --- a/meta/recipes-graphics/mesa/mesa.inc
> > > +++ b/meta/recipes-graphics/mesa/mesa.inc
> > > @@ -48,6 +48,12 @@ PROVIDES = " \
> > > 
> > >  inherit meson pkgconfig python3native gettext features_check
> > > 
> > > +# We can not include rust conditionally, otherwise it can not be overriden by
> > > +# the bbappends.  Instead always include it, but remove the dependencies by
> > > +# default.
> > > +inherit rust
> > > +INHIBIT_DEFAULT_RUST_DEPS = "${@bb.utils.contains('PACKAGECONFIG', 'opencl', '', '1', d)}"
> > > +
> > 
> > I'd really prefer not to have the rust inherit unconditionally. I have
> > some ideas about how we could fix this in bitbake so we may need to
> > wait for that if we can't avoid the PACKAGECONFIG issue from appends...
> 
> Well, it's not just appends. Extending PACKAGECONFIG from local.conf
> also doesn't work. In fact even adding "opencl" to the default
> PACKAGECONFIG doesn't work unless I move `inherit
> @{bb.utils.contains....` after the PACKAGECONFIG definition. Using
> `INHIBIT_DEFAULT_RUST_DEPS` works around that issue, but yes, it has a
> drawback of including rust unconditionally.

PACKAGECONFIG:append:pn-mesa = " opencl"

should work from local.conf?

Cheers,

Richard
Dmitry Baryshkov Jan. 2, 2024, 3:25 p.m. UTC | #4
On Tue, 2 Jan 2024 at 13:40, Richard Purdie
<richard.purdie@linuxfoundation.org> wrote:
>
> On Tue, 2024-01-02 at 12:32 +0200, Dmitry Baryshkov wrote:
> > On Sat, 30 Dec 2023 at 23:02, Richard Purdie
> > <richard.purdie@linuxfoundation.org> wrote:
> > >
> > > On Sat, 2023-12-30 at 21:14 +0200, Dmitry Baryshkov wrote:
> > > > From: Zoltán Böszörményi <zboszor@gmail.com>
> > > >
> > > > Mesa now has two OpenCL implementations: Clover (older one) and RustiCL
> > > > (newer one). Extend the "opencl" package config to include both
> > > > implementations into the libopencl-mesa (-dev) packages. As the Clover
> > > > implementation is in maintenance mode and is expected to be removed at
> > > > some point, it doesn't make sense to split the packages or to provide
> > > > two config options.
> > > >
> > > > Signed-off-by: Zoltán Böszörményi <zboszor@gmail.com>
> > > > [DB: reworked rust class inheritance]
> > > > [DB: merged "rusticl" and "clover" back to "opencl"]
> > > > Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
> > > > ---
> > > >  meta/recipes-graphics/mesa/mesa.inc | 21 ++++++++++++++++-----
> > > >  1 file changed, 16 insertions(+), 5 deletions(-)
> > > >
> > > > diff --git a/meta/recipes-graphics/mesa/mesa.inc b/meta/recipes-graphics/mesa/mesa.inc
> > > > index efbce5caade5..a192562a7935 100644
> > > > --- a/meta/recipes-graphics/mesa/mesa.inc
> > > > +++ b/meta/recipes-graphics/mesa/mesa.inc
> > > > @@ -48,6 +48,12 @@ PROVIDES = " \
> > > >
> > > >  inherit meson pkgconfig python3native gettext features_check
> > > >
> > > > +# We can not include rust conditionally, otherwise it can not be overriden by
> > > > +# the bbappends.  Instead always include it, but remove the dependencies by
> > > > +# default.
> > > > +inherit rust
> > > > +INHIBIT_DEFAULT_RUST_DEPS = "${@bb.utils.contains('PACKAGECONFIG', 'opencl', '', '1', d)}"
> > > > +
> > >
> > > I'd really prefer not to have the rust inherit unconditionally. I have
> > > some ideas about how we could fix this in bitbake so we may need to
> > > wait for that if we can't avoid the PACKAGECONFIG issue from appends...
> >
> > Well, it's not just appends. Extending PACKAGECONFIG from local.conf
> > also doesn't work. In fact even adding "opencl" to the default
> > PACKAGECONFIG doesn't work unless I move `inherit
> > @{bb.utils.contains....` after the PACKAGECONFIG definition. Using
> > `INHIBIT_DEFAULT_RUST_DEPS` works around that issue, but yes, it has a
> > drawback of including rust unconditionally.
>
> PACKAGECONFIG:append:pn-mesa = " opencl"

Yes, I tried that. I got an error about rust tools not being defined.
I think the :append: and overrides are handled after the inherit
argument is handled. So it is either PACKAGECONFIG being fully defined
before inherit (literally before), or inherit ends up with an empty
argument.
Richard Purdie Jan. 2, 2024, 3:29 p.m. UTC | #5
On Tue, 2024-01-02 at 17:25 +0200, Dmitry Baryshkov wrote:
> On Tue, 2 Jan 2024 at 13:40, Richard Purdie
> <richard.purdie@linuxfoundation.org> wrote:
> > 
> > On Tue, 2024-01-02 at 12:32 +0200, Dmitry Baryshkov wrote:
> > > On Sat, 30 Dec 2023 at 23:02, Richard Purdie
> > > <richard.purdie@linuxfoundation.org> wrote:
> > > > 
> > > > On Sat, 2023-12-30 at 21:14 +0200, Dmitry Baryshkov wrote:
> > > > > From: Zoltán Böszörményi <zboszor@gmail.com>
> > > > > 
> > > > > Mesa now has two OpenCL implementations: Clover (older one) and RustiCL
> > > > > (newer one). Extend the "opencl" package config to include both
> > > > > implementations into the libopencl-mesa (-dev) packages. As the Clover
> > > > > implementation is in maintenance mode and is expected to be removed at
> > > > > some point, it doesn't make sense to split the packages or to provide
> > > > > two config options.
> > > > > 
> > > > > Signed-off-by: Zoltán Böszörményi <zboszor@gmail.com>
> > > > > [DB: reworked rust class inheritance]
> > > > > [DB: merged "rusticl" and "clover" back to "opencl"]
> > > > > Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
> > > > > ---
> > > > >  meta/recipes-graphics/mesa/mesa.inc | 21 ++++++++++++++++-----
> > > > >  1 file changed, 16 insertions(+), 5 deletions(-)
> > > > > 
> > > > > diff --git a/meta/recipes-graphics/mesa/mesa.inc b/meta/recipes-graphics/mesa/mesa.inc
> > > > > index efbce5caade5..a192562a7935 100644
> > > > > --- a/meta/recipes-graphics/mesa/mesa.inc
> > > > > +++ b/meta/recipes-graphics/mesa/mesa.inc
> > > > > @@ -48,6 +48,12 @@ PROVIDES = " \
> > > > > 
> > > > >  inherit meson pkgconfig python3native gettext features_check
> > > > > 
> > > > > +# We can not include rust conditionally, otherwise it can not be overriden by
> > > > > +# the bbappends.  Instead always include it, but remove the dependencies by
> > > > > +# default.
> > > > > +inherit rust
> > > > > +INHIBIT_DEFAULT_RUST_DEPS = "${@bb.utils.contains('PACKAGECONFIG', 'opencl', '', '1', d)}"
> > > > > +
> > > > 
> > > > I'd really prefer not to have the rust inherit unconditionally. I have
> > > > some ideas about how we could fix this in bitbake so we may need to
> > > > wait for that if we can't avoid the PACKAGECONFIG issue from appends...
> > > 
> > > Well, it's not just appends. Extending PACKAGECONFIG from local.conf
> > > also doesn't work. In fact even adding "opencl" to the default
> > > PACKAGECONFIG doesn't work unless I move `inherit
> > > @{bb.utils.contains....` after the PACKAGECONFIG definition. Using
> > > `INHIBIT_DEFAULT_RUST_DEPS` works around that issue, but yes, it has a
> > > drawback of including rust unconditionally.
> > 
> > PACKAGECONFIG:append:pn-mesa = " opencl"
> 
> Yes, I tried that. I got an error about rust tools not being defined.
> I think the :append: and overrides are handled after the inherit
> argument is handled. So it is either PACKAGECONFIG being fully defined
> before inherit (literally before), or inherit ends up with an empty
> argument.

The append and overrides would be expanded at the time the expression
in the inherit statement is evaluated so if that didn't work there is
something else at play...

Cheers,

Richard
Dmitry Baryshkov Jan. 2, 2024, 10:57 p.m. UTC | #6
On Tue, 2 Jan 2024 at 17:30, Richard Purdie
<richard.purdie@linuxfoundation.org> wrote:
>
> On Tue, 2024-01-02 at 17:25 +0200, Dmitry Baryshkov wrote:
> > On Tue, 2 Jan 2024 at 13:40, Richard Purdie
> > <richard.purdie@linuxfoundation.org> wrote:
> > >
> > > On Tue, 2024-01-02 at 12:32 +0200, Dmitry Baryshkov wrote:
> > > > On Sat, 30 Dec 2023 at 23:02, Richard Purdie
> > > > <richard.purdie@linuxfoundation.org> wrote:
> > > > >
> > > > > On Sat, 2023-12-30 at 21:14 +0200, Dmitry Baryshkov wrote:
> > > > > > From: Zoltán Böszörményi <zboszor@gmail.com>
> > > > > >
> > > > > > Mesa now has two OpenCL implementations: Clover (older one) and RustiCL
> > > > > > (newer one). Extend the "opencl" package config to include both
> > > > > > implementations into the libopencl-mesa (-dev) packages. As the Clover
> > > > > > implementation is in maintenance mode and is expected to be removed at
> > > > > > some point, it doesn't make sense to split the packages or to provide
> > > > > > two config options.
> > > > > >
> > > > > > Signed-off-by: Zoltán Böszörményi <zboszor@gmail.com>
> > > > > > [DB: reworked rust class inheritance]
> > > > > > [DB: merged "rusticl" and "clover" back to "opencl"]
> > > > > > Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
> > > > > > ---
> > > > > >  meta/recipes-graphics/mesa/mesa.inc | 21 ++++++++++++++++-----
> > > > > >  1 file changed, 16 insertions(+), 5 deletions(-)
> > > > > >
> > > > > > diff --git a/meta/recipes-graphics/mesa/mesa.inc b/meta/recipes-graphics/mesa/mesa.inc
> > > > > > index efbce5caade5..a192562a7935 100644
> > > > > > --- a/meta/recipes-graphics/mesa/mesa.inc
> > > > > > +++ b/meta/recipes-graphics/mesa/mesa.inc
> > > > > > @@ -48,6 +48,12 @@ PROVIDES = " \
> > > > > >
> > > > > >  inherit meson pkgconfig python3native gettext features_check
> > > > > >
> > > > > > +# We can not include rust conditionally, otherwise it can not be overriden by
> > > > > > +# the bbappends.  Instead always include it, but remove the dependencies by
> > > > > > +# default.
> > > > > > +inherit rust
> > > > > > +INHIBIT_DEFAULT_RUST_DEPS = "${@bb.utils.contains('PACKAGECONFIG', 'opencl', '', '1', d)}"
> > > > > > +
> > > > >
> > > > > I'd really prefer not to have the rust inherit unconditionally. I have
> > > > > some ideas about how we could fix this in bitbake so we may need to
> > > > > wait for that if we can't avoid the PACKAGECONFIG issue from appends...
> > > >
> > > > Well, it's not just appends. Extending PACKAGECONFIG from local.conf
> > > > also doesn't work. In fact even adding "opencl" to the default
> > > > PACKAGECONFIG doesn't work unless I move `inherit
> > > > @{bb.utils.contains....` after the PACKAGECONFIG definition. Using
> > > > `INHIBIT_DEFAULT_RUST_DEPS` works around that issue, but yes, it has a
> > > > drawback of including rust unconditionally.
> > >
> > > PACKAGECONFIG:append:pn-mesa = " opencl"
> >
> > Yes, I tried that. I got an error about rust tools not being defined.
> > I think the :append: and overrides are handled after the inherit
> > argument is handled. So it is either PACKAGECONFIG being fully defined
> > before inherit (literally before), or inherit ends up with an empty
> > argument.
>
> The append and overrides would be expanded at the time the expression
> in the inherit statement is evaluated so if that didn't work there is
> something else at play...

I did not attempt debugging the bitbake itself. However I can see that
with this line in local.conf, PACKAGECONFIG is updated, but the RUSTC
is not defined (which means that rust.bbclass was not inherited). Then
I tried adding opencl to the default PACKAGECONFIG in mesa.inc. If
inherit comes before PACKAGECONFIG being set, it is not honoured. If
inherit comes after PACKAGECONFIG, it works as expected (and RUSTC
gets defined).
Böszörményi Zoltán Jan. 12, 2024, 10:21 a.m. UTC | #7
2024. 01. 02. 23:57 keltezéssel, Dmitry Baryshkov írta:
> On Tue, 2 Jan 2024 at 17:30, Richard Purdie
> <richard.purdie@linuxfoundation.org> wrote:
>> On Tue, 2024-01-02 at 17:25 +0200, Dmitry Baryshkov wrote:
>>> On Tue, 2 Jan 2024 at 13:40, Richard Purdie
>>> <richard.purdie@linuxfoundation.org> wrote:
>>>> On Tue, 2024-01-02 at 12:32 +0200, Dmitry Baryshkov wrote:
>>>>> On Sat, 30 Dec 2023 at 23:02, Richard Purdie
>>>>> <richard.purdie@linuxfoundation.org> wrote:
>>>>>> On Sat, 2023-12-30 at 21:14 +0200, Dmitry Baryshkov wrote:
>>>>>>> From: Zoltán Böszörményi <zboszor@gmail.com>
>>>>>>>
>>>>>>> Mesa now has two OpenCL implementations: Clover (older one) and RustiCL
>>>>>>> (newer one). Extend the "opencl" package config to include both
>>>>>>> implementations into the libopencl-mesa (-dev) packages. As the Clover
>>>>>>> implementation is in maintenance mode and is expected to be removed at
>>>>>>> some point, it doesn't make sense to split the packages or to provide
>>>>>>> two config options.
>>>>>>>
>>>>>>> Signed-off-by: Zoltán Böszörményi <zboszor@gmail.com>
>>>>>>> [DB: reworked rust class inheritance]
>>>>>>> [DB: merged "rusticl" and "clover" back to "opencl"]
>>>>>>> Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
>>>>>>> ---
>>>>>>>   meta/recipes-graphics/mesa/mesa.inc | 21 ++++++++++++++++-----
>>>>>>>   1 file changed, 16 insertions(+), 5 deletions(-)
>>>>>>>
>>>>>>> diff --git a/meta/recipes-graphics/mesa/mesa.inc b/meta/recipes-graphics/mesa/mesa.inc
>>>>>>> index efbce5caade5..a192562a7935 100644
>>>>>>> --- a/meta/recipes-graphics/mesa/mesa.inc
>>>>>>> +++ b/meta/recipes-graphics/mesa/mesa.inc
>>>>>>> @@ -48,6 +48,12 @@ PROVIDES = " \
>>>>>>>
>>>>>>>   inherit meson pkgconfig python3native gettext features_check
>>>>>>>
>>>>>>> +# We can not include rust conditionally, otherwise it can not be overriden by
>>>>>>> +# the bbappends.  Instead always include it, but remove the dependencies by
>>>>>>> +# default.
>>>>>>> +inherit rust
>>>>>>> +INHIBIT_DEFAULT_RUST_DEPS = "${@bb.utils.contains('PACKAGECONFIG', 'opencl', '', '1', d)}"
>>>>>>> +
>>>>>> I'd really prefer not to have the rust inherit unconditionally. I have
>>>>>> some ideas about how we could fix this in bitbake so we may need to
>>>>>> wait for that if we can't avoid the PACKAGECONFIG issue from appends...
>>>>> Well, it's not just appends. Extending PACKAGECONFIG from local.conf
>>>>> also doesn't work. In fact even adding "opencl" to the default
>>>>> PACKAGECONFIG doesn't work unless I move `inherit
>>>>> @{bb.utils.contains....` after the PACKAGECONFIG definition. Using
>>>>> `INHIBIT_DEFAULT_RUST_DEPS` works around that issue, but yes, it has a
>>>>> drawback of including rust unconditionally.
>>>> PACKAGECONFIG:append:pn-mesa = " opencl"
>>> Yes, I tried that. I got an error about rust tools not being defined.
>>> I think the :append: and overrides are handled after the inherit
>>> argument is handled. So it is either PACKAGECONFIG being fully defined
>>> before inherit (literally before), or inherit ends up with an empty
>>> argument.
>> The append and overrides would be expanded at the time the expression
>> in the inherit statement is evaluated so if that didn't work there is
>> something else at play...
> I did not attempt debugging the bitbake itself. However I can see that
> with this line in local.conf, PACKAGECONFIG is updated, but the RUSTC
> is not defined (which means that rust.bbclass was not inherited). Then
> I tried adding opencl to the default PACKAGECONFIG in mesa.inc. If
> inherit comes before PACKAGECONFIG being set, it is not honoured. If
> inherit comes after PACKAGECONFIG, it works as expected (and RUSTC
> gets defined).

Something like this should work:

inherit ${@bb.utils.contains('PACKAGECONFIG', 'opencl', 'rust', '', d)}

E.g. the libxml2 recipe does it, although for a different bbclass.

Best regards,
Zoltán Böszörményi
Dmitry Baryshkov Jan. 13, 2024, 6:12 a.m. UTC | #8
On Fri, 12 Jan 2024 at 12:21, Böszörményi Zoltán <zboszor@gmail.com> wrote:
>
> 2024. 01. 02. 23:57 keltezéssel, Dmitry Baryshkov írta:
> > On Tue, 2 Jan 2024 at 17:30, Richard Purdie
> > <richard.purdie@linuxfoundation.org> wrote:
> >> On Tue, 2024-01-02 at 17:25 +0200, Dmitry Baryshkov wrote:
> >>> On Tue, 2 Jan 2024 at 13:40, Richard Purdie
> >>> <richard.purdie@linuxfoundation.org> wrote:
> >>>> On Tue, 2024-01-02 at 12:32 +0200, Dmitry Baryshkov wrote:
> >>>>> On Sat, 30 Dec 2023 at 23:02, Richard Purdie
> >>>>> <richard.purdie@linuxfoundation.org> wrote:
> >>>>>> On Sat, 2023-12-30 at 21:14 +0200, Dmitry Baryshkov wrote:
> >>>>>>> From: Zoltán Böszörményi <zboszor@gmail.com>
> >>>>>>>
> >>>>>>> Mesa now has two OpenCL implementations: Clover (older one) and RustiCL
> >>>>>>> (newer one). Extend the "opencl" package config to include both
> >>>>>>> implementations into the libopencl-mesa (-dev) packages. As the Clover
> >>>>>>> implementation is in maintenance mode and is expected to be removed at
> >>>>>>> some point, it doesn't make sense to split the packages or to provide
> >>>>>>> two config options.
> >>>>>>>
> >>>>>>> Signed-off-by: Zoltán Böszörményi <zboszor@gmail.com>
> >>>>>>> [DB: reworked rust class inheritance]
> >>>>>>> [DB: merged "rusticl" and "clover" back to "opencl"]
> >>>>>>> Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
> >>>>>>> ---
> >>>>>>>   meta/recipes-graphics/mesa/mesa.inc | 21 ++++++++++++++++-----
> >>>>>>>   1 file changed, 16 insertions(+), 5 deletions(-)
> >>>>>>>
> >>>>>>> diff --git a/meta/recipes-graphics/mesa/mesa.inc b/meta/recipes-graphics/mesa/mesa.inc
> >>>>>>> index efbce5caade5..a192562a7935 100644
> >>>>>>> --- a/meta/recipes-graphics/mesa/mesa.inc
> >>>>>>> +++ b/meta/recipes-graphics/mesa/mesa.inc
> >>>>>>> @@ -48,6 +48,12 @@ PROVIDES = " \
> >>>>>>>
> >>>>>>>   inherit meson pkgconfig python3native gettext features_check
> >>>>>>>
> >>>>>>> +# We can not include rust conditionally, otherwise it can not be overriden by
> >>>>>>> +# the bbappends.  Instead always include it, but remove the dependencies by
> >>>>>>> +# default.
> >>>>>>> +inherit rust
> >>>>>>> +INHIBIT_DEFAULT_RUST_DEPS = "${@bb.utils.contains('PACKAGECONFIG', 'opencl', '', '1', d)}"
> >>>>>>> +
> >>>>>> I'd really prefer not to have the rust inherit unconditionally. I have
> >>>>>> some ideas about how we could fix this in bitbake so we may need to
> >>>>>> wait for that if we can't avoid the PACKAGECONFIG issue from appends...
> >>>>> Well, it's not just appends. Extending PACKAGECONFIG from local.conf
> >>>>> also doesn't work. In fact even adding "opencl" to the default
> >>>>> PACKAGECONFIG doesn't work unless I move `inherit
> >>>>> @{bb.utils.contains....` after the PACKAGECONFIG definition. Using
> >>>>> `INHIBIT_DEFAULT_RUST_DEPS` works around that issue, but yes, it has a
> >>>>> drawback of including rust unconditionally.
> >>>> PACKAGECONFIG:append:pn-mesa = " opencl"
> >>> Yes, I tried that. I got an error about rust tools not being defined.
> >>> I think the :append: and overrides are handled after the inherit
> >>> argument is handled. So it is either PACKAGECONFIG being fully defined
> >>> before inherit (literally before), or inherit ends up with an empty
> >>> argument.
> >> The append and overrides would be expanded at the time the expression
> >> in the inherit statement is evaluated so if that didn't work there is
> >> something else at play...
> > I did not attempt debugging the bitbake itself. However I can see that
> > with this line in local.conf, PACKAGECONFIG is updated, but the RUSTC
> > is not defined (which means that rust.bbclass was not inherited). Then
> > I tried adding opencl to the default PACKAGECONFIG in mesa.inc. If
> > inherit comes before PACKAGECONFIG being set, it is not honoured. If
> > inherit comes after PACKAGECONFIG, it works as expected (and RUSTC
> > gets defined).
>
> Something like this should work:
>
> inherit ${@bb.utils.contains('PACKAGECONFIG', 'opencl', 'rust', '', d)}
>
> E.g. the libxml2 recipe does it, although for a different bbclass.

This way enabling opencl in .bbappend is not honoured.
Böszörményi Zoltán Jan. 15, 2024, 9:58 a.m. UTC | #9
2024. 01. 13. 7:12 keltezéssel, Dmitry Baryshkov írta:
> On Fri, 12 Jan 2024 at 12:21, Böszörményi Zoltán <zboszor@gmail.com> wrote:
>> 2024. 01. 02. 23:57 keltezéssel, Dmitry Baryshkov írta:
>>> On Tue, 2 Jan 2024 at 17:30, Richard Purdie
>>> <richard.purdie@linuxfoundation.org> wrote:
>>>> On Tue, 2024-01-02 at 17:25 +0200, Dmitry Baryshkov wrote:
>>>>> On Tue, 2 Jan 2024 at 13:40, Richard Purdie
>>>>> <richard.purdie@linuxfoundation.org> wrote:
>>>>>> On Tue, 2024-01-02 at 12:32 +0200, Dmitry Baryshkov wrote:
>>>>>>> On Sat, 30 Dec 2023 at 23:02, Richard Purdie
>>>>>>> <richard.purdie@linuxfoundation.org> wrote:
>>>>>>>> On Sat, 2023-12-30 at 21:14 +0200, Dmitry Baryshkov wrote:
>>>>>>>>> From: Zoltán Böszörményi <zboszor@gmail.com>
>>>>>>>>>
>>>>>>>>> Mesa now has two OpenCL implementations: Clover (older one) and RustiCL
>>>>>>>>> (newer one). Extend the "opencl" package config to include both
>>>>>>>>> implementations into the libopencl-mesa (-dev) packages. As the Clover
>>>>>>>>> implementation is in maintenance mode and is expected to be removed at
>>>>>>>>> some point, it doesn't make sense to split the packages or to provide
>>>>>>>>> two config options.
>>>>>>>>>
>>>>>>>>> Signed-off-by: Zoltán Böszörményi <zboszor@gmail.com>
>>>>>>>>> [DB: reworked rust class inheritance]
>>>>>>>>> [DB: merged "rusticl" and "clover" back to "opencl"]
>>>>>>>>> Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
>>>>>>>>> ---
>>>>>>>>>    meta/recipes-graphics/mesa/mesa.inc | 21 ++++++++++++++++-----
>>>>>>>>>    1 file changed, 16 insertions(+), 5 deletions(-)
>>>>>>>>>
>>>>>>>>> diff --git a/meta/recipes-graphics/mesa/mesa.inc b/meta/recipes-graphics/mesa/mesa.inc
>>>>>>>>> index efbce5caade5..a192562a7935 100644
>>>>>>>>> --- a/meta/recipes-graphics/mesa/mesa.inc
>>>>>>>>> +++ b/meta/recipes-graphics/mesa/mesa.inc
>>>>>>>>> @@ -48,6 +48,12 @@ PROVIDES = " \
>>>>>>>>>
>>>>>>>>>    inherit meson pkgconfig python3native gettext features_check
>>>>>>>>>
>>>>>>>>> +# We can not include rust conditionally, otherwise it can not be overriden by
>>>>>>>>> +# the bbappends.  Instead always include it, but remove the dependencies by
>>>>>>>>> +# default.
>>>>>>>>> +inherit rust
>>>>>>>>> +INHIBIT_DEFAULT_RUST_DEPS = "${@bb.utils.contains('PACKAGECONFIG', 'opencl', '', '1', d)}"
>>>>>>>>> +
>>>>>>>> I'd really prefer not to have the rust inherit unconditionally. I have
>>>>>>>> some ideas about how we could fix this in bitbake so we may need to
>>>>>>>> wait for that if we can't avoid the PACKAGECONFIG issue from appends...
>>>>>>> Well, it's not just appends. Extending PACKAGECONFIG from local.conf
>>>>>>> also doesn't work. In fact even adding "opencl" to the default
>>>>>>> PACKAGECONFIG doesn't work unless I move `inherit
>>>>>>> @{bb.utils.contains....` after the PACKAGECONFIG definition. Using
>>>>>>> `INHIBIT_DEFAULT_RUST_DEPS` works around that issue, but yes, it has a
>>>>>>> drawback of including rust unconditionally.
>>>>>> PACKAGECONFIG:append:pn-mesa = " opencl"
>>>>> Yes, I tried that. I got an error about rust tools not being defined.
>>>>> I think the :append: and overrides are handled after the inherit
>>>>> argument is handled. So it is either PACKAGECONFIG being fully defined
>>>>> before inherit (literally before), or inherit ends up with an empty
>>>>> argument.
>>>> The append and overrides would be expanded at the time the expression
>>>> in the inherit statement is evaluated so if that didn't work there is
>>>> something else at play...
>>> I did not attempt debugging the bitbake itself. However I can see that
>>> with this line in local.conf, PACKAGECONFIG is updated, but the RUSTC
>>> is not defined (which means that rust.bbclass was not inherited). Then
>>> I tried adding opencl to the default PACKAGECONFIG in mesa.inc. If
>>> inherit comes before PACKAGECONFIG being set, it is not honoured. If
>>> inherit comes after PACKAGECONFIG, it works as expected (and RUSTC
>>> gets defined).
>> Something like this should work:
>>
>> inherit ${@bb.utils.contains('PACKAGECONFIG', 'opencl', 'rust', '', d)}
>>
>> E.g. the libxml2 recipe does it, although for a different bbclass.
> This way enabling opencl in .bbappend is not honoured.

Yes, I remember now, that's what I was fighting with, too. Pity.

I wonder why, though. Isn't the .bb and all .bbappend files
loaded, merged then parsed as a whole entity with the variable
dependency graph used for the inherit lines?
Antoine Coutant Jan. 23, 2024, 2:34 p.m. UTC | #10
On 30/12/2023 22:02, Richard Purdie wrote:
> On Sat, 2023-12-30 at 21:14 +0200, Dmitry Baryshkov wrote:
>> From: Zoltán Böszörményi<zboszor@gmail.com>
>>
>> Mesa now has two OpenCL implementations: Clover (older one) and RustiCL
>> (newer one). Extend the "opencl" package config to include both
>> implementations into the libopencl-mesa (-dev) packages. As the Clover
>> implementation is in maintenance mode and is expected to be removed at
>> some point, it doesn't make sense to split the packages or to provide
>> two config options.
>>
>> Signed-off-by: Zoltán Böszörményi<zboszor@gmail.com>
>> [DB: reworked rust class inheritance]
>> [DB: merged "rusticl" and "clover" back to "opencl"]
>> Signed-off-by: Dmitry Baryshkov<dmitry.baryshkov@linaro.org>
>> ---
>>   meta/recipes-graphics/mesa/mesa.inc | 21 ++++++++++++++++-----
>>   1 file changed, 16 insertions(+), 5 deletions(-)
>>
>> diff --git a/meta/recipes-graphics/mesa/mesa.inc b/meta/recipes-graphics/mesa/mesa.inc
>> index efbce5caade5..a192562a7935 100644
>> --- a/meta/recipes-graphics/mesa/mesa.inc
>> +++ b/meta/recipes-graphics/mesa/mesa.inc
>> @@ -48,6 +48,12 @@ PROVIDES = " \
>>   
>>   inherit meson pkgconfig python3native gettext features_check
>>   
>> +# We can not include rust conditionally, otherwise it can not be overriden by
>> +# the bbappends.  Instead always include it, but remove the dependencies by
>> +# default.
>> +inherit rust
>> +INHIBIT_DEFAULT_RUST_DEPS ="${@bb.utils.contains('PACKAGECONFIG', 'opencl', '', '1', d)}"
>> +
> I'd really prefer not to have the rust inherit unconditionally. I have
> some ideas about how we could fix this in bitbake so we may need to
> wait for that if we can't avoid the PACKAGECONFIG issue from appends...
>
> Cheers,
>
> Richard
>
Richard, All,


Thanks for your work.


I tried to build rusticl with inherit_defer[1][2]. Inherit_defer worked 
well but I got an error message:


ERROR: mesa-native-2_23.3.2-r0 do_prepare_recipe_sysroot: The file 
/usr/bin/llvm-tblgen17.0.6 is installed by both llvm-native and 
clang-native, aborting


It seems that llvm-native and clang-native are in conflict. llvm-native 
is a dependency of mesa-native. clang-native is inherited from the 
rust-llvm recipe (this inheritance is added by rust-llvm_%.bbappend in  
meta-clang).


Here is my configuration:


Build Configuration:

BB_VERSION = "2.7.1"

BUILD_SYS = "x86_64-linux"

NATIVELSBSTRING = "universal"

TARGET_SYS = "x86_64-poky-linux"

MACHINE = "qemux86-64"

DISTRO = "poky"

DISTRO_VERSION = "4.3+snapshot-5ed5d717f122078dd908cce86a0c625c2c64f32a"

TUNE_FEATURES = "m64 core2"

TARGET_FPU = ""

meta

meta-poky

meta-yocto-bsp = "master:5ed5d717f122078dd908cce86a0c625c2c64f32a"

meta-clang = "master:beffde692f3d365678f5fdf60b473b93045d4161"


I also tried the build on the Nanbield version and I got the same message.


[1] : 
https://git.yoctoproject.org/poky/commit/?h=master-next&id=859832795040ad04d6136732e4275da443409110 
<https://git.yoctoproject.org/poky/commit/?h=master-next&id=859832795040ad04d6136732e4275da443409110>

[2] : 
https://git.yoctoproject.org/poky/commit/?h=master-next&id=7ef978a7e66d5ebd2986b890488eeb52d4e2af2e 
<https://git.yoctoproject.org/poky/commit/?h=master-next&id=7ef978a7e66d5ebd2986b890488eeb52d4e2af2e>

---

Regards,

Antoine Coutant
diff mbox series

Patch

diff --git a/meta/recipes-graphics/mesa/mesa.inc b/meta/recipes-graphics/mesa/mesa.inc
index efbce5caade5..a192562a7935 100644
--- a/meta/recipes-graphics/mesa/mesa.inc
+++ b/meta/recipes-graphics/mesa/mesa.inc
@@ -48,6 +48,12 @@  PROVIDES = " \
 
 inherit meson pkgconfig python3native gettext features_check
 
+# We can not include rust conditionally, otherwise it can not be overriden by
+# the bbappends.  Instead always include it, but remove the dependencies by
+# default.
+inherit rust
+INHIBIT_DEFAULT_RUST_DEPS = "${@bb.utils.contains('PACKAGECONFIG', 'opencl', '', '1', d)}"
+
 BBCLASSEXTEND = "native nativesdk"
 
 ANY_OF_DISTRO_FEATURES = "opengl vulkan"
@@ -139,8 +145,13 @@  PACKAGECONFIG[gles] = "-Dgles1=enabled -Dgles2=enabled, -Dgles1=disabled -Dgles2
 # "egl" requires "opengl"
 PACKAGECONFIG[egl] = "-Degl=enabled, -Degl=disabled"
 
-# "opencl" requires libclc from meta-clang and spirv-tools from OE-Core
-PACKAGECONFIG[opencl] = "-Dgallium-opencl=icd -Dopencl-spirv=true,-Dgallium-opencl=disabled -Dopencl-spirv=false,libclc spirv-tools python3-ply-native"
+# "clover" requires libclc from meta-clang and python3-ply-native and spirv-tools from OE-Core
+# "rusticl" requires libclc, spirv-llvm-translator and bindgen-cli-native from meta-clang and spirv-tools from OE-Core
+PACKAGECONFIG[opencl] = "\
+    -Dgallium-opencl=icd -Dopencl-spirv=true -Dgallium-rusticl=true -Drust_std=2021, \
+    -Dgallium-opencl=disabled -Dopencl-spirv=false -Dgallium-rusticl=false, \
+    libclc spirv-tools bindgen-cli-native python3-ply-native"
+#PACKAGECONFIG[opencl] = ",,spirv-llvm-translator"
 
 PACKAGECONFIG[broadcom] = ""
 PACKAGECONFIG[etnaviv] = ""
@@ -221,7 +232,7 @@  DEV_PKG_DEPENDENCY = ""
 # development package of libgles3.
 RDEPENDS:libgles3-mesa-dev += "libgles2-mesa-dev"
 
-RDEPENDS:libopencl-mesa += "${@bb.utils.contains('PACKAGECONFIG', 'opencl', 'libclc spirv-tools', '', d)}"
+RDEPENDS:libopencl-mesa += "${@bb.utils.contains('PACKAGECONFIG', 'opencl', 'libclc spirv-tools spirv-llvm-translator', '', d)}"
 
 PACKAGES =+ "libegl-mesa libegl-mesa-dev \
              libosmesa libosmesa-dev \
@@ -332,7 +343,7 @@  FILES:libgles1-mesa = "${libdir}/libGLESv1*.so.*"
 FILES:libgles2-mesa = "${libdir}/libGLESv2.so.*"
 FILES:libgl-mesa = "${libdir}/libGL.so.*"
 FILES:libglx-mesa = "${libdir}/libGLX*.so.*"
-FILES:libopencl-mesa = "${libdir}/libMesaOpenCL.so.* ${libdir}/gallium-pipe/*.so ${sysconfdir}/OpenCL/vendors/mesa.icd"
+FILES:libopencl-mesa = "${libdir}/lib*OpenCL.so.* ${libdir}/gallium-pipe/*.so ${sysconfdir}/OpenCL/vendors/*.icd"
 FILES:libglapi = "${libdir}/libglapi.so.*"
 FILES:libosmesa = "${libdir}/libOSMesa.so.*"
 FILES:libxatracker = "${libdir}/libxatracker.so.*"
@@ -346,7 +357,7 @@  FILES:libglapi-dev = "${libdir}/libglapi.*"
 FILES:libgles1-mesa-dev = "${libdir}/libGLESv1*.* ${includedir}/GLES ${libdir}/pkgconfig/glesv1*.pc"
 FILES:libgles2-mesa-dev = "${libdir}/libGLESv2.* ${includedir}/GLES2 ${libdir}/pkgconfig/glesv2.pc"
 FILES:libgles3-mesa-dev = "${includedir}/GLES3"
-FILES:libopencl-mesa-dev = "${libdir}/libMesaOpenCL.so"
+FILES:libopencl-mesa-dev = "${libdir}/lib*OpenCL.so"
 FILES:libosmesa-dev = "${libdir}/libOSMesa.* ${includedir}/GL/osmesa.h ${libdir}/pkgconfig/osmesa.pc"
 FILES:libxatracker-dev = "${libdir}/libxatracker.so ${libdir}/libxatracker.la \
                           ${includedir}/xa_tracker.h ${includedir}/xa_composite.h ${includedir}/xa_context.h \