diff mbox series

[RFC,3/4] mesa: lighten up libclc dependencies for the target

Message ID 20250624-mesa-libclc-panfrost-v1-3-9ed8ca980e21@cherry.de
State New
Headers show
Series mesa: lighten up target's libclc dependencies and fix panfrost support | expand

Commit Message

Quentin Schulz June 24, 2025, 12:44 p.m. UTC
From: Quentin Schulz <quentin.schulz@cherry.de>

By using mesa-native mesa-clc instead of libclc, we do not actually need
most of the heavy dependencies of the libclc PACKAGECONFIG as we simply
need to use the natively compiled mesa-clc instead. We thus can simply
depend on mesa-native for the target recipe.

libclc however is still required if opencl (rusticl) is selected.

Because asahi drivers are only enabled when libclc is also selected, we
can now remove the explicit dependency on MESA_NATIVE.
We do the same for panfrost even though libclc isn't enforced yet for
mesa for the target. Support for panfrost has been broken for a while
already anyway (because of the possibly missing libclc) but we'll fix it
in a later commit.

Signed-off-by: Quentin Schulz <quentin.schulz@cherry.de>
---
 meta/recipes-graphics/mesa/mesa.inc | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

Comments

Dmitry Baryshkov June 24, 2025, 1:35 p.m. UTC | #1
On Tue, Jun 24, 2025 at 02:44:26PM +0200, Quentin Schulz wrote:
> From: Quentin Schulz <quentin.schulz@cherry.de>
> 
> By using mesa-native mesa-clc instead of libclc, we do not actually need
> most of the heavy dependencies of the libclc PACKAGECONFIG as we simply
> need to use the natively compiled mesa-clc instead. We thus can simply
> depend on mesa-native for the target recipe.
> 
> libclc however is still required if opencl (rusticl) is selected.
> 
> Because asahi drivers are only enabled when libclc is also selected, we
> can now remove the explicit dependency on MESA_NATIVE.
> We do the same for panfrost even though libclc isn't enforced yet for
> mesa for the target. Support for panfrost has been broken for a while
> already anyway (because of the possibly missing libclc) but we'll fix it
> in a later commit.
> 
> Signed-off-by: Quentin Schulz <quentin.schulz@cherry.de>
> ---
>  meta/recipes-graphics/mesa/mesa.inc | 19 +++++++++++--------
>  1 file changed, 11 insertions(+), 8 deletions(-)
> 
> diff --git a/meta/recipes-graphics/mesa/mesa.inc b/meta/recipes-graphics/mesa/mesa.inc
> index 330a04f1b098a2d3a6874f40feabe8836dd4cb37..eafe1697c48edc661b33a54c5856d8e577608fd5 100644
> --- a/meta/recipes-graphics/mesa/mesa.inc
> +++ b/meta/recipes-graphics/mesa/mesa.inc
> @@ -158,7 +158,7 @@ PACKAGECONFIG[egl] = "-Degl=enabled, -Degl=disabled"
>  
>  # "opencl" also requires libclc and gallium-llvm to be present in PKGCONFIG!
>  # Be sure to enable them both for the target and for the native build.
> -PACKAGECONFIG[opencl] = "-Dgallium-rusticl=true, -Dgallium-rusticl=false, bindgen-cli-native"
> +PACKAGECONFIG[opencl] = "-Dgallium-rusticl=true, -Dgallium-rusticl=false, bindgen-cli-native libclc spirv-tools spirv-llvm-translator"
>  
>  PACKAGECONFIG[broadcom] = ""
>  PACKAGECONFIG[etnaviv] = ",,python3-pycparser-native"
> @@ -201,19 +201,21 @@ MESA_CLC = "system"
>  MESA_CLC:class-native = "enabled"
>  INSTALL_MESA_CLC = "false"
>  INSTALL_MESA_CLC:class-native = "true"
> -MESA_NATIVE = "mesa-native"
> -MESA_NATIVE:class-native = ""
> +# Reuse libclc from mesa-native instead of bringing heavy dependencies
> +LIBCLC_DEPS = "mesa-native"
> +LIBCLC_DEPS:class-native = "libclc spirv-tools spirv-llvm-translator"
>  
>  PACKAGECONFIG[gallium] = "-Dgallium-drivers=${@strip_comma('${GALLIUMDRIVERS}')}, -Dgallium-drivers='', libdrm"
>  PACKAGECONFIG[gallium-llvm] = "-Dllvm=enabled -Dshared-llvm=enabled, -Dllvm=disabled, llvm llvm-native elfutils"
> -PACKAGECONFIG[libclc] = "-Dmesa-clc=${MESA_CLC} -Dinstall-mesa-clc=${INSTALL_MESA_CLC} -Dmesa-clc-bundle-headers=enabled,,libclc spirv-tools spirv-llvm-translator ${MESA_NATIVE}"
> +PACKAGECONFIG[libclc] = "-Dmesa-clc=${MESA_CLC} -Dinstall-mesa-clc=${INSTALL_MESA_CLC} -Dmesa-clc-bundle-headers=enabled,,${LIBCLC_DEPS}"

I think it might be easier to drop this completely and to move meson
arguments to EXTRA_OEMESON (next to precomp-compiler options that you've
added). This way native builds will always build a full configuration
with mesa-clc, precomp compilers and other required drivers, while the
targets builds can be really optimal and won't require 'foo libclc'
hurdle.

>  PACKAGECONFIG[va] = "-Dgallium-va=enabled,-Dgallium-va=disabled,libva-initial"
>  PACKAGECONFIG[vdpau] = "-Dgallium-vdpau=enabled,-Dgallium-vdpau=disabled,libvdpau"
>  
>  PACKAGECONFIG[imagination] = "-Dimagination-srv=true,-Dimagination-srv=false"
>  
> -# Asahi requires precompiled compilers from mesa-native
> -PACKAGECONFIG[asahi] = ",,${MESA_NATIVE}"
> +# Asahi requires precompiled compilers and libclc from mesa-native
> +# Make sure libclc is in mesa-native AND mesa PACKAGECONFIG
> +PACKAGECONFIG[asahi] = ""
>  
>  PACKAGECONFIG[intel] = ""
>  GALLIUMDRIVERS:append = "${@bb.utils.contains('PACKAGECONFIG', 'intel', ',i915,crocus', '', d)}"
> @@ -221,8 +223,9 @@ GALLIUMDRIVERS:append = "${@bb.utils.contains('PACKAGECONFIG', 'intel', ',i915,c
>  PACKAGECONFIG[lima] = ""
>  GALLIUMDRIVERS:append = "${@bb.utils.contains('PACKAGECONFIG', 'lima', ',lima', '', d)}"
>  
> -# Panfrost requires precompiled compilers from mesa-native
> -PACKAGECONFIG[panfrost] = ",,${MESA_NATIVE}"
> +# Panfrost requires precompiled compilers and libclc from mesa-native
> +# Make sure libclc is in mesa-native AND mesa PACKAGECONFIG
> +PACKAGECONFIG[panfrost] = ""
>  GALLIUMDRIVERS:append = "${@bb.utils.contains('PACKAGECONFIG', 'panfrost', ',panfrost', '', d)}"
>  
>  PACKAGECONFIG[tegra] = ""
> 
> -- 
> 2.49.0
> 
>
Quentin Schulz June 24, 2025, 2:55 p.m. UTC | #2
Hi Dmitry,

On 6/24/25 3:35 PM, Dmitry Baryshkov wrote:
> On Tue, Jun 24, 2025 at 02:44:26PM +0200, Quentin Schulz wrote:
>> From: Quentin Schulz <quentin.schulz@cherry.de>
>>
>> By using mesa-native mesa-clc instead of libclc, we do not actually need
>> most of the heavy dependencies of the libclc PACKAGECONFIG as we simply
>> need to use the natively compiled mesa-clc instead. We thus can simply
>> depend on mesa-native for the target recipe.
>>
>> libclc however is still required if opencl (rusticl) is selected.
>>
>> Because asahi drivers are only enabled when libclc is also selected, we
>> can now remove the explicit dependency on MESA_NATIVE.
>> We do the same for panfrost even though libclc isn't enforced yet for
>> mesa for the target. Support for panfrost has been broken for a while
>> already anyway (because of the possibly missing libclc) but we'll fix it
>> in a later commit.
>>
>> Signed-off-by: Quentin Schulz <quentin.schulz@cherry.de>
>> ---
>>   meta/recipes-graphics/mesa/mesa.inc | 19 +++++++++++--------
>>   1 file changed, 11 insertions(+), 8 deletions(-)
>>
>> diff --git a/meta/recipes-graphics/mesa/mesa.inc b/meta/recipes-graphics/mesa/mesa.inc
>> index 330a04f1b098a2d3a6874f40feabe8836dd4cb37..eafe1697c48edc661b33a54c5856d8e577608fd5 100644
>> --- a/meta/recipes-graphics/mesa/mesa.inc
>> +++ b/meta/recipes-graphics/mesa/mesa.inc
>> @@ -158,7 +158,7 @@ PACKAGECONFIG[egl] = "-Degl=enabled, -Degl=disabled"
>>   
>>   # "opencl" also requires libclc and gallium-llvm to be present in PKGCONFIG!
>>   # Be sure to enable them both for the target and for the native build.
>> -PACKAGECONFIG[opencl] = "-Dgallium-rusticl=true, -Dgallium-rusticl=false, bindgen-cli-native"
>> +PACKAGECONFIG[opencl] = "-Dgallium-rusticl=true, -Dgallium-rusticl=false, bindgen-cli-native libclc spirv-tools spirv-llvm-translator"
>>   
>>   PACKAGECONFIG[broadcom] = ""
>>   PACKAGECONFIG[etnaviv] = ",,python3-pycparser-native"
>> @@ -201,19 +201,21 @@ MESA_CLC = "system"
>>   MESA_CLC:class-native = "enabled"
>>   INSTALL_MESA_CLC = "false"
>>   INSTALL_MESA_CLC:class-native = "true"
>> -MESA_NATIVE = "mesa-native"
>> -MESA_NATIVE:class-native = ""
>> +# Reuse libclc from mesa-native instead of bringing heavy dependencies
>> +LIBCLC_DEPS = "mesa-native"
>> +LIBCLC_DEPS:class-native = "libclc spirv-tools spirv-llvm-translator"
>>   
>>   PACKAGECONFIG[gallium] = "-Dgallium-drivers=${@strip_comma('${GALLIUMDRIVERS}')}, -Dgallium-drivers='', libdrm"
>>   PACKAGECONFIG[gallium-llvm] = "-Dllvm=enabled -Dshared-llvm=enabled, -Dllvm=disabled, llvm llvm-native elfutils"
>> -PACKAGECONFIG[libclc] = "-Dmesa-clc=${MESA_CLC} -Dinstall-mesa-clc=${INSTALL_MESA_CLC} -Dmesa-clc-bundle-headers=enabled,,libclc spirv-tools spirv-llvm-translator ${MESA_NATIVE}"
>> +PACKAGECONFIG[libclc] = "-Dmesa-clc=${MESA_CLC} -Dinstall-mesa-clc=${INSTALL_MESA_CLC} -Dmesa-clc-bundle-headers=enabled,,${LIBCLC_DEPS}"
> 
> I think it might be easier to drop this completely and to move meson
> arguments to EXTRA_OEMESON (next to precomp-compiler options that you've
> added). This way native builds will always build a full configuration
> with mesa-clc, precomp compilers and other required drivers, while the
> targets builds can be really optimal and won't require 'foo libclc'
> hurdle.
> 

We actually talked about that and I eventually decided against, and 
forgot to explain, sorry about that.

Having libclc always on for the target mesa will require mesa-native be 
a dependency of mesa, which I'm not entirely sure is the best of ideas 
since nothing else in mesa requires mesa-native as far as I could tell? 
That's quite the dependency to always bring in, what do you think?

Cheers,
Quentin
Dmitry Baryshkov June 24, 2025, 7:36 p.m. UTC | #3
On Tue, 24 Jun 2025 at 17:55, Quentin Schulz <quentin.schulz@cherry.de> wrote:
>
> Hi Dmitry,
>
> On 6/24/25 3:35 PM, Dmitry Baryshkov wrote:
> > On Tue, Jun 24, 2025 at 02:44:26PM +0200, Quentin Schulz wrote:
> >> From: Quentin Schulz <quentin.schulz@cherry.de>
> >>
> >> By using mesa-native mesa-clc instead of libclc, we do not actually need
> >> most of the heavy dependencies of the libclc PACKAGECONFIG as we simply
> >> need to use the natively compiled mesa-clc instead. We thus can simply
> >> depend on mesa-native for the target recipe.
> >>
> >> libclc however is still required if opencl (rusticl) is selected.
> >>
> >> Because asahi drivers are only enabled when libclc is also selected, we
> >> can now remove the explicit dependency on MESA_NATIVE.
> >> We do the same for panfrost even though libclc isn't enforced yet for
> >> mesa for the target. Support for panfrost has been broken for a while
> >> already anyway (because of the possibly missing libclc) but we'll fix it
> >> in a later commit.
> >>
> >> Signed-off-by: Quentin Schulz <quentin.schulz@cherry.de>
> >> ---
> >>   meta/recipes-graphics/mesa/mesa.inc | 19 +++++++++++--------
> >>   1 file changed, 11 insertions(+), 8 deletions(-)
> >>
> >> diff --git a/meta/recipes-graphics/mesa/mesa.inc b/meta/recipes-graphics/mesa/mesa.inc
> >> index 330a04f1b098a2d3a6874f40feabe8836dd4cb37..eafe1697c48edc661b33a54c5856d8e577608fd5 100644
> >> --- a/meta/recipes-graphics/mesa/mesa.inc
> >> +++ b/meta/recipes-graphics/mesa/mesa.inc
> >> @@ -158,7 +158,7 @@ PACKAGECONFIG[egl] = "-Degl=enabled, -Degl=disabled"
> >>
> >>   # "opencl" also requires libclc and gallium-llvm to be present in PKGCONFIG!
> >>   # Be sure to enable them both for the target and for the native build.
> >> -PACKAGECONFIG[opencl] = "-Dgallium-rusticl=true, -Dgallium-rusticl=false, bindgen-cli-native"
> >> +PACKAGECONFIG[opencl] = "-Dgallium-rusticl=true, -Dgallium-rusticl=false, bindgen-cli-native libclc spirv-tools spirv-llvm-translator"
> >>
> >>   PACKAGECONFIG[broadcom] = ""
> >>   PACKAGECONFIG[etnaviv] = ",,python3-pycparser-native"
> >> @@ -201,19 +201,21 @@ MESA_CLC = "system"
> >>   MESA_CLC:class-native = "enabled"
> >>   INSTALL_MESA_CLC = "false"
> >>   INSTALL_MESA_CLC:class-native = "true"
> >> -MESA_NATIVE = "mesa-native"
> >> -MESA_NATIVE:class-native = ""
> >> +# Reuse libclc from mesa-native instead of bringing heavy dependencies
> >> +LIBCLC_DEPS = "mesa-native"
> >> +LIBCLC_DEPS:class-native = "libclc spirv-tools spirv-llvm-translator"
> >>
> >>   PACKAGECONFIG[gallium] = "-Dgallium-drivers=${@strip_comma('${GALLIUMDRIVERS}')}, -Dgallium-drivers='', libdrm"
> >>   PACKAGECONFIG[gallium-llvm] = "-Dllvm=enabled -Dshared-llvm=enabled, -Dllvm=disabled, llvm llvm-native elfutils"
> >> -PACKAGECONFIG[libclc] = "-Dmesa-clc=${MESA_CLC} -Dinstall-mesa-clc=${INSTALL_MESA_CLC} -Dmesa-clc-bundle-headers=enabled,,libclc spirv-tools spirv-llvm-translator ${MESA_NATIVE}"
> >> +PACKAGECONFIG[libclc] = "-Dmesa-clc=${MESA_CLC} -Dinstall-mesa-clc=${INSTALL_MESA_CLC} -Dmesa-clc-bundle-headers=enabled,,${LIBCLC_DEPS}"
> >
> > I think it might be easier to drop this completely and to move meson
> > arguments to EXTRA_OEMESON (next to precomp-compiler options that you've
> > added). This way native builds will always build a full configuration
> > with mesa-clc, precomp compilers and other required drivers, while the
> > targets builds can be really optimal and won't require 'foo libclc'
> > hurdle.
> >
>
> We actually talked about that and I eventually decided against, and
> forgot to explain, sorry about that.
>
> Having libclc always on for the target mesa will require mesa-native be
> a dependency of mesa, which I'm not entirely sure is the best of ideas
> since nothing else in mesa requires mesa-native as far as I could tell?
> That's quite the dependency to always bring in, what do you think?

Okay. So we have several cases:
- class-native build. It should depend on libclc & spirv in order to
provide mesa-clc, asahi-clc & panfrost_compile. I don't think we ever
need RustiCL support in this build
- target builds for asahi / panfrost / intel / nouveau. These should
depend only on mesa-native for native progs and specify
-Dmesa-clc=system
- target builds using RustiCL. These should depend on full libclc &
spirv packages

I think the easiest way to handle all these points without too many
troubles is to:
- Enable mesa-clc / prebuild-compilers / asahi / panfost in native builds
- Drop libclc PACKAGECONFIG
- Declare that asahi, panfrost, intel and nouveau PACKAGECONFIGs
depend on mesa-native. Pass -Dmesa-clc=system to these drivers in a
non-native build
- Make opencl PACKAGECONFIG depend on libclc / spirv-tools /
spirv-headers directly.

WDYT?

--
With best wishes
Dmitry
Quentin Schulz June 25, 2025, 8:47 a.m. UTC | #4
Hi Dmitry,

On 6/24/25 9:36 PM, Dmitry Baryshkov wrote:
> On Tue, 24 Jun 2025 at 17:55, Quentin Schulz <quentin.schulz@cherry.de> wrote:
>>
>> Hi Dmitry,
>>
>> On 6/24/25 3:35 PM, Dmitry Baryshkov wrote:
>>> On Tue, Jun 24, 2025 at 02:44:26PM +0200, Quentin Schulz wrote:
>>>> From: Quentin Schulz <quentin.schulz@cherry.de>
>>>>
>>>> By using mesa-native mesa-clc instead of libclc, we do not actually need
>>>> most of the heavy dependencies of the libclc PACKAGECONFIG as we simply
>>>> need to use the natively compiled mesa-clc instead. We thus can simply
>>>> depend on mesa-native for the target recipe.
>>>>
>>>> libclc however is still required if opencl (rusticl) is selected.
>>>>
>>>> Because asahi drivers are only enabled when libclc is also selected, we
>>>> can now remove the explicit dependency on MESA_NATIVE.
>>>> We do the same for panfrost even though libclc isn't enforced yet for
>>>> mesa for the target. Support for panfrost has been broken for a while
>>>> already anyway (because of the possibly missing libclc) but we'll fix it
>>>> in a later commit.
>>>>
>>>> Signed-off-by: Quentin Schulz <quentin.schulz@cherry.de>
>>>> ---
>>>>    meta/recipes-graphics/mesa/mesa.inc | 19 +++++++++++--------
>>>>    1 file changed, 11 insertions(+), 8 deletions(-)
>>>>
>>>> diff --git a/meta/recipes-graphics/mesa/mesa.inc b/meta/recipes-graphics/mesa/mesa.inc
>>>> index 330a04f1b098a2d3a6874f40feabe8836dd4cb37..eafe1697c48edc661b33a54c5856d8e577608fd5 100644
>>>> --- a/meta/recipes-graphics/mesa/mesa.inc
>>>> +++ b/meta/recipes-graphics/mesa/mesa.inc
>>>> @@ -158,7 +158,7 @@ PACKAGECONFIG[egl] = "-Degl=enabled, -Degl=disabled"
>>>>
>>>>    # "opencl" also requires libclc and gallium-llvm to be present in PKGCONFIG!
>>>>    # Be sure to enable them both for the target and for the native build.
>>>> -PACKAGECONFIG[opencl] = "-Dgallium-rusticl=true, -Dgallium-rusticl=false, bindgen-cli-native"
>>>> +PACKAGECONFIG[opencl] = "-Dgallium-rusticl=true, -Dgallium-rusticl=false, bindgen-cli-native libclc spirv-tools spirv-llvm-translator"
>>>>
>>>>    PACKAGECONFIG[broadcom] = ""
>>>>    PACKAGECONFIG[etnaviv] = ",,python3-pycparser-native"
>>>> @@ -201,19 +201,21 @@ MESA_CLC = "system"
>>>>    MESA_CLC:class-native = "enabled"
>>>>    INSTALL_MESA_CLC = "false"
>>>>    INSTALL_MESA_CLC:class-native = "true"
>>>> -MESA_NATIVE = "mesa-native"
>>>> -MESA_NATIVE:class-native = ""
>>>> +# Reuse libclc from mesa-native instead of bringing heavy dependencies
>>>> +LIBCLC_DEPS = "mesa-native"
>>>> +LIBCLC_DEPS:class-native = "libclc spirv-tools spirv-llvm-translator"
>>>>
>>>>    PACKAGECONFIG[gallium] = "-Dgallium-drivers=${@strip_comma('${GALLIUMDRIVERS}')}, -Dgallium-drivers='', libdrm"
>>>>    PACKAGECONFIG[gallium-llvm] = "-Dllvm=enabled -Dshared-llvm=enabled, -Dllvm=disabled, llvm llvm-native elfutils"
>>>> -PACKAGECONFIG[libclc] = "-Dmesa-clc=${MESA_CLC} -Dinstall-mesa-clc=${INSTALL_MESA_CLC} -Dmesa-clc-bundle-headers=enabled,,libclc spirv-tools spirv-llvm-translator ${MESA_NATIVE}"
>>>> +PACKAGECONFIG[libclc] = "-Dmesa-clc=${MESA_CLC} -Dinstall-mesa-clc=${INSTALL_MESA_CLC} -Dmesa-clc-bundle-headers=enabled,,${LIBCLC_DEPS}"
>>>
>>> I think it might be easier to drop this completely and to move meson
>>> arguments to EXTRA_OEMESON (next to precomp-compiler options that you've
>>> added). This way native builds will always build a full configuration
>>> with mesa-clc, precomp compilers and other required drivers, while the
>>> targets builds can be really optimal and won't require 'foo libclc'
>>> hurdle.
>>>
>>
>> We actually talked about that and I eventually decided against, and
>> forgot to explain, sorry about that.
>>
>> Having libclc always on for the target mesa will require mesa-native be
>> a dependency of mesa, which I'm not entirely sure is the best of ideas
>> since nothing else in mesa requires mesa-native as far as I could tell?
>> That's quite the dependency to always bring in, what do you think?
> 
> Okay. So we have several cases:
> - class-native build. It should depend on libclc & spirv in order to
> provide mesa-clc, asahi-clc & panfrost_compile. I don't think we ever
> need RustiCL support in this build

It depends if we need rusticl in qemu for example? But otherwise yes, 
makes sense to me.

I also kind of don't know what to do with the nativesdk case as the 
recipe seems to support it.

> - target builds for asahi / panfrost / intel / nouveau. These should
> depend only on mesa-native for native progs and specify
> -Dmesa-clc=system

And we can know which ones require that by figuring out what can set 
with_clc meson variable to true in the event mesa-clc!=system, so 
shouldn't be TOO difficult to follow what upstream does?

> - target builds using RustiCL. These should depend on full libclc &
> spirv packages
> 
> I think the easiest way to handle all these points without too many
> troubles is to:
> - Enable mesa-clc / prebuild-compilers / asahi / panfost in native builds

Agreed, I believe this is what I've done in this patch.

> - Drop libclc PACKAGECONFIG
> - Declare that asahi, panfrost, intel and nouveau PACKAGECONFIGs
> depend on mesa-native. Pass -Dmesa-clc=system to these drivers in a
> non-native build

I'm wondering if we cannot simply have mesa-clc=system always on (in 
OE_EXTRAMESON), even when we actually don't need clc at all? Is this 
going to hurt us somehow? This would simplify (albeit make it less 
explicit) supporting those drivers as we would only need to add 
mesa-native to the PACKAGECONFIG[<driver>] part?

> - Make opencl PACKAGECONFIG depend on libclc / spirv-tools /
> spirv-headers directly.
> 

Agreed, I believe this is what I've done in this patch.

> WDYT?
> 

I would like to avoid having

MESA_CLC = "-Dmesa-clc=system -Dinstall-mesa-clc=false 
-Dmesa-clc-bundle-headers=enabled"
MESA_CLC:class-native = ""

PACKAGECONFIG[nouveau] = "${MESA_CLC},,${MESA_NATIVE}"
PACKAGECONFIG[intel] = "${MESA_CLC},,${MESA_NATIVE}"
...

which actually wouldn't differ that much from what we have today, just 
that we would merge libclc PACKAGECONFIG with PACKAGECONFIG of drivers 
that require it.

And looking at the meson.build from mesa again.. it seems this is only 
required for Intel Iris gallium driver and Intel Vulkan driver (for 
Intel drivers I mean), so Crocus, i915, etc. don't need it and we would 
bring the mesa-native dependency for this as well?

We can start with this though and if people complain about unnecessary 
dependencies, then figure out something more precise and maybe rework 
the PACKAGECONFIG selection system we currently have (but that's a much 
bigger task :) ). This remark also applies if we have mesa-clc=system 
always in OE_EXTRAMESON for the target build.

BTW, it seems like intel also has a precomp-compiler 
(intel-clc/intel_clc) and it's also handled with -Dprecomp-compiler and 
-D install-precomp-compiler options :)

Cheers,
Quentin
diff mbox series

Patch

diff --git a/meta/recipes-graphics/mesa/mesa.inc b/meta/recipes-graphics/mesa/mesa.inc
index 330a04f1b098a2d3a6874f40feabe8836dd4cb37..eafe1697c48edc661b33a54c5856d8e577608fd5 100644
--- a/meta/recipes-graphics/mesa/mesa.inc
+++ b/meta/recipes-graphics/mesa/mesa.inc
@@ -158,7 +158,7 @@  PACKAGECONFIG[egl] = "-Degl=enabled, -Degl=disabled"
 
 # "opencl" also requires libclc and gallium-llvm to be present in PKGCONFIG!
 # Be sure to enable them both for the target and for the native build.
-PACKAGECONFIG[opencl] = "-Dgallium-rusticl=true, -Dgallium-rusticl=false, bindgen-cli-native"
+PACKAGECONFIG[opencl] = "-Dgallium-rusticl=true, -Dgallium-rusticl=false, bindgen-cli-native libclc spirv-tools spirv-llvm-translator"
 
 PACKAGECONFIG[broadcom] = ""
 PACKAGECONFIG[etnaviv] = ",,python3-pycparser-native"
@@ -201,19 +201,21 @@  MESA_CLC = "system"
 MESA_CLC:class-native = "enabled"
 INSTALL_MESA_CLC = "false"
 INSTALL_MESA_CLC:class-native = "true"
-MESA_NATIVE = "mesa-native"
-MESA_NATIVE:class-native = ""
+# Reuse libclc from mesa-native instead of bringing heavy dependencies
+LIBCLC_DEPS = "mesa-native"
+LIBCLC_DEPS:class-native = "libclc spirv-tools spirv-llvm-translator"
 
 PACKAGECONFIG[gallium] = "-Dgallium-drivers=${@strip_comma('${GALLIUMDRIVERS}')}, -Dgallium-drivers='', libdrm"
 PACKAGECONFIG[gallium-llvm] = "-Dllvm=enabled -Dshared-llvm=enabled, -Dllvm=disabled, llvm llvm-native elfutils"
-PACKAGECONFIG[libclc] = "-Dmesa-clc=${MESA_CLC} -Dinstall-mesa-clc=${INSTALL_MESA_CLC} -Dmesa-clc-bundle-headers=enabled,,libclc spirv-tools spirv-llvm-translator ${MESA_NATIVE}"
+PACKAGECONFIG[libclc] = "-Dmesa-clc=${MESA_CLC} -Dinstall-mesa-clc=${INSTALL_MESA_CLC} -Dmesa-clc-bundle-headers=enabled,,${LIBCLC_DEPS}"
 PACKAGECONFIG[va] = "-Dgallium-va=enabled,-Dgallium-va=disabled,libva-initial"
 PACKAGECONFIG[vdpau] = "-Dgallium-vdpau=enabled,-Dgallium-vdpau=disabled,libvdpau"
 
 PACKAGECONFIG[imagination] = "-Dimagination-srv=true,-Dimagination-srv=false"
 
-# Asahi requires precompiled compilers from mesa-native
-PACKAGECONFIG[asahi] = ",,${MESA_NATIVE}"
+# Asahi requires precompiled compilers and libclc from mesa-native
+# Make sure libclc is in mesa-native AND mesa PACKAGECONFIG
+PACKAGECONFIG[asahi] = ""
 
 PACKAGECONFIG[intel] = ""
 GALLIUMDRIVERS:append = "${@bb.utils.contains('PACKAGECONFIG', 'intel', ',i915,crocus', '', d)}"
@@ -221,8 +223,9 @@  GALLIUMDRIVERS:append = "${@bb.utils.contains('PACKAGECONFIG', 'intel', ',i915,c
 PACKAGECONFIG[lima] = ""
 GALLIUMDRIVERS:append = "${@bb.utils.contains('PACKAGECONFIG', 'lima', ',lima', '', d)}"
 
-# Panfrost requires precompiled compilers from mesa-native
-PACKAGECONFIG[panfrost] = ",,${MESA_NATIVE}"
+# Panfrost requires precompiled compilers and libclc from mesa-native
+# Make sure libclc is in mesa-native AND mesa PACKAGECONFIG
+PACKAGECONFIG[panfrost] = ""
 GALLIUMDRIVERS:append = "${@bb.utils.contains('PACKAGECONFIG', 'panfrost', ',panfrost', '', d)}"
 
 PACKAGECONFIG[tegra] = ""