RE: [OE-core] [PATCH 3/6] mesa: enable a rich set of drivers for native builds

Marko, Peter
2024-08-02T17:52:22Z

> -----Original Message-----
> From: openembedded-core@lists.openembedded.org <openembedded-
> core@lists.openembedded.org> On Behalf Of Alexander Kanavin via
> lists.openembedded.org
> Sent: Thursday, March 16, 2023 10:41
> To: openembedded-core@lists.openembedded.org
> Cc: Kanavin, Alexander (EXT) (Linutronix GmbH) <alex@linutronix.de>
> Subject: [OE-core] [PATCH 3/6] mesa: enable a rich set of drivers for native
> builds
>
> Without this, the only available driver would be swrast
> (without llvmpipe) which is far too slow to be practical,
> and so qemu wouldn't be able to perform accelerated graphics.
>
> The one major dependency pulled in by this change is llvm-native
> which takes just under three minutes on my machine. If this is
> undesitable, opengl can be removed from DISTRO_FEATURES_NATIVE.

I was just hit by this commit when migrating our gui layers from kirkstone to scarthgap.
We include clang-native in our sdk and this creates conflict:
ERROR: product-image-sdk-1.0-r0 do_prepare_recipe_sysroot: The file /usr/bin/llvm-lto2 is installed by both llvm-native and clang-native, aborting

I had to create mesa_%.bbappend which replaces llvm with clang
PACKAGECONFIG[gallium-llvm] = "-Dllvm=enabled -Dshared-llvm=enabled, -Dllvm=disabled, clang clang-native elfutils"

But bbappends are bad idea for config changes and should be only used as last resort so I'd like to solve it via distro config.
Also update-alternatives doesn't work for native recipes I think.

Any idea how to solve this in a nice way?
One idea from me would be to create global LLVM_PROVIDER and LLVM_NATIVE_PROVIDER variables which could be automatically switched in meta-clang.
Wdyt?

>
> Signed-off-by: Alexander Kanavin <alex@linutronix.de>
> ---
> meta/recipes-graphics/mesa/mesa.inc | 20 ++++++++++++++------
> 1 file changed, 14 insertions(+), 6 deletions(-)
>
> diff --git a/meta/recipes-graphics/mesa/mesa.inc b/meta/recipes-
> graphics/mesa/mesa.inc
> index 775aab9297..dd15046438 100644
> --- a/meta/recipes-graphics/mesa/mesa.inc
> +++ b/meta/recipes-graphics/mesa/mesa.inc
> @@ -89,6 +89,8 @@ PACKAGECONFIG = " \
> ${@bb.utils.contains('LICENSE_FLAGS_ACCEPTED', 'commercial',
> 'video-codecs', '', d)} \
> "
>
> +PACKAGECONFIG:append:class-native = "gallium-llvm r600"
> +
> # "gbm" requires "opengl"
> PACKAGECONFIG[gbm] = "-Dgbm=enabled,-Dgbm=disabled"
>
> @@ -102,8 +104,10 @@ PACKAGECONFIG[dri3] = "-Ddri3=enabled, -
> Ddri3=disabled, xorgproto libxshmfence"
> # Vulkan drivers need dri3 enabled
> # amd could be enabled as well but requires gallium-llvm with llvm >= 3.9
> VULKAN_DRIVERS = ""
> -VULKAN_DRIVERS:append:x86:class-target = ",intel"
> -VULKAN_DRIVERS:append:x86-64:class-target = ",intel"
> +VULKAN_DRIVERS:append:x86 = ",intel"
> +VULKAN_DRIVERS:append:x86-64 = ",intel"
> +# i686 is a 32 bit override for mesa-native
> +VULKAN_DRIVERS:append:i686 = ",intel"
> VULKAN_DRIVERS:append ="${@bb.utils.contains('PACKAGECONFIG',
> 'freedreno', ',freedreno', '', d)}"
> VULKAN_DRIVERS:append ="${@bb.utils.contains('PACKAGECONFIG',
> 'broadcom', ',broadcom', '', d)}"
> PACKAGECONFIG[vulkan] = "-Dvulkan-
> drivers=${@strip_comma('${VULKAN_DRIVERS}')}, -Dvulkan-
> drivers='',glslang-native vulkan-loader vulkan-headers"
> @@ -149,8 +153,10 @@ PACKAGECONFIG[zink] = ""
> GALLIUMDRIVERS = "swrast"
> # gallium swrast was found to crash Xorg on startup in x32 qemu
> GALLIUMDRIVERS:x86-x32 = ""
> -GALLIUMDRIVERS:append:x86:class-target = ",i915,iris,crocus"
> -GALLIUMDRIVERS:append:x86-64:class-target = ",i915,iris,crocus"
> +GALLIUMDRIVERS:append:x86 = ",i915,iris,crocus"
> +GALLIUMDRIVERS:append:x86-64 = ",i915,iris,crocus"
> +# i686 is a 32 bit override for mesa-native
> +GALLIUMDRIVERS:append:i686 = ",i915,iris,crocus"
>
> GALLIUMDRIVERS:append ="${@bb.utils.contains('PACKAGECONFIG',
> 'etnaviv', ',etnaviv', '', d)}"
> GALLIUMDRIVERS:append ="${@bb.utils.contains('PACKAGECONFIG',
> 'freedreno', ',freedreno', '', d)}"
> @@ -162,8 +168,10 @@ GALLIUMDRIVERS:append
> ="${@bb.utils.contains('PACKAGECONFIG', 'zink', ',zink', '
> # radeonsi requires LLVM
> GALLIUMDRIVERS_RADEONSI = "${@bb.utils.contains('PACKAGECONFIG',
> 'r600', ',radeonsi', '', d)}"
> GALLIUMDRIVERS_LLVM = "r300,nouveau${GALLIUMDRIVERS_RADEONSI}"
> -GALLIUMDRIVERS_LLVM:append:x86:class-target = ",svga"
> -GALLIUMDRIVERS_LLVM:append:x86-64:class-target = ",svga"
> +GALLIUMDRIVERS_LLVM:append:x86 = ",svga"
> +GALLIUMDRIVERS_LLVM:append:x86-64 = ",svga"
> +# i686 is a 32 bit override for mesa-native
> +GALLIUMDRIVERS_LLVM:append:i686 = ",svga"
>
> PACKAGECONFIG[r600] = ""
> PACKAGECONFIG[virgl] = ""
> --
> 2.30.2