Skip to contentSkip to conversation

mesa: don't build empty libgles3-mesa in GLVND case

PATCH In review Dmitry Baryshkov 2 participants 7 messages May 20, 2025 – May 21, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/5 mesa: don't build empty libgles3-mesa in GLVND case

If GLVND is enabled, there is no libgles2-mesa package to depend on libgles3-mesa. Stop building unused empty package in this case.

---
 meta/recipes-graphics/mesa/mesa.inc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
meta/recipes-graphics/mesa/mesa.inc +1 -1
index 288027bbb996..89ae71595991 100644
@@ -247,7 +247,7 @@ RDEPENDS:libgles3-mesa-dev += "libgles2-mesa-dev"
 # GLES2 and GLES3 implementations are packaged in a single library in libgles2-mesa.
 # Add a dependency so the GLES3 dev package is associated with its implementation.
 RDEPENDS:libgles2-mesa += "libgles3-mesa"
-ALLOW_EMPTY:libgles3-mesa = "1"
+ALLOW_EMPTY:libgles3-mesa = "${@bb.utils.contains('PACKAGECONFIG', 'glvnd', '', '1', d)}"
 
 RDEPENDS:libopencl-mesa += "${@bb.utils.contains('PACKAGECONFIG', 'opencl', 'libclc spirv-tools spirv-llvm-translator', '', d)}"
 
Signature · 1 line
2.39.5
#1 lore raw

PATCH 2/5 mesa: drop the libopencl-mesa-dev package

Thre is no "development" package for libopencl-mesa. The main package contains Installable Client Drivers, for which there are no headers and the extra .so file isn't supposed to be linked with anything.

Drop the useless and confusing libopencl-mesa-dev package.

---
 meta/recipes-graphics/mesa/mesa.inc | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
meta/recipes-graphics/mesa/mesa.inc +5 -3
index 89ae71595991..02e502e58737 100644
@@ -261,7 +261,7 @@ PACKAGES =+ "libegl-mesa libegl-mesa-dev \
              libgles1-mesa libgles1-mesa-dev \
              libgles2-mesa libgles2-mesa-dev \
              libgles3-mesa libgles3-mesa-dev \
-             libopencl-mesa libopencl-mesa-dev \
+             libopencl-mesa \
              libxatracker libxatracker-dev \
              mesa-megadriver mesa-vulkan-drivers \
              mesa-vdpau-drivers mesa-tools \
@@ -349,7 +349,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}/lib*OpenCL.so.* ${libdir}/gallium-pipe/*.so ${sysconfdir}/OpenCL/vendors/*.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.*"
@@ -363,7 +363,6 @@ 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}/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 \
@@ -375,6 +374,9 @@ ALLOW_EMPTY:${PN}-tools = "1"
 # All DRI drivers are symlinks to libdril_dri.so
 INSANE_SKIP:${PN}-megadriver += "dev-so"
 
+# OpenCL ICDs package also ship correspondig .so files, there is no -dev package
+INSANE_SKIP:libopencl-mesa += "dev-so"
+
 # Fix upgrade path from mesa to mesa-megadriver
 RREPLACES:mesa-megadriver = "mesa"
 RCONFLICTS:mesa-megadriver = "mesa"
Signature · 1 line
2.39.5
#2 lore raw

PATCH 3/5 mesa: don't add extra tags to the libopencl-mesa package

In reply to Dmitry Baryshkov

The libopencl-mesa package provides OpenCL ICDs (Installable Client Drivers). As such, there is no conflict between several packages providing ICDs for different vendors. Split the loop that modifies package metadata and stop adding extra RPROVIDES / RCONFLICTS / RREPLACES tags to the libopencl-mesa package.

---
 meta/recipes-graphics/mesa/mesa.inc | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)
meta/recipes-graphics/mesa/mesa.inc +9 -6
index 02e502e58737..fdebae7977e4 100644
@@ -278,29 +278,32 @@ do_install:append () {
 # RPROVIDEs/RCONFLICTs on the generic libgl name.
 python __anonymous() {
     pkgconfig = (d.getVar('PACKAGECONFIG') or "").split()
+    mlprefix = d.getVar("MLPREFIX")
     suffix = ""
     if "-native" in d.getVar("PN"):
         suffix = "-native"
+
+    for p in ("libegl", "libgl", "libglx", "libgles1", "libgles2", "libgles3", "libopencl"):
+        fullp = mlprefix + p[1] + "-mesa" + suffix
+        d.appendVar("RRECOMMENDS:" + fullp, " ${MLPREFIX}mesa-megadriver" + suffix)
+
+    d.setVar("DEBIAN_NOAUTONAME:%slibopencl-mesa%s" % (mlprefix, suffix), "1")
+
     for p in (("egl", "libegl", "libegl1"),
               ("opengl", "libgl", "libgl1"),
               ("glvnd", "libglx",),
               ("gles", "libgles1", "libglesv1-cm1"),
               ("gles", "libgles2", "libglesv2-2"),
-              ("gles", "libgles3",),
-              ("opencl", "libopencl",)):
+              ("gles", "libgles3",)):
         if not p[0] in pkgconfig:
             continue
-        mlprefix = d.getVar("MLPREFIX")
         fullp = mlprefix + p[1] + "-mesa" + suffix
-        mlprefix = d.getVar("MLPREFIX")
         pkgs = " " + " ".join(mlprefix + x + suffix for x in p[1:])
         d.setVar("DEBIAN_NOAUTONAME:" + fullp, "1")
         d.appendVar("RREPLACES:" + fullp, pkgs)
         d.appendVar("RPROVIDES:" + fullp, pkgs)
         d.appendVar("RCONFLICTS:" + fullp, pkgs)
 
-        d.appendVar("RRECOMMENDS:" + fullp, " ${MLPREFIX}mesa-megadriver" + suffix)
-
         # For -dev, the first element is both the Debian and original name
         fullp = mlprefix + p[1] + "-mesa-dev" + suffix
         pkgs = " " + mlprefix + p[1] + "-dev" + suffix
Signature · 1 line
2.39.5
#3 lore raw

PATCH 4/5 mesa: don't set RCONFLICTS / PROVIDES if glvnd is enabled

In reply to Dmitry Baryshkov

If glvnd is enabled, mesa packages do not provide full library implementations (instead it provides two ICDs, one for EGL, one for GLX). This means that there is no more conflict between mesa packages and other vendor packages. Stop setting those extra tags for mesa packages.

---
 meta/recipes-graphics/mesa/mesa.inc | 44 ++++++++++++++---------------
 1 file changed, 22 insertions(+), 22 deletions(-)
meta/recipes-graphics/mesa/mesa.inc +22 -22
index fdebae7977e4..53f77b98c898 100644
@@ -289,28 +289,28 @@ python __anonymous() {
 
     d.setVar("DEBIAN_NOAUTONAME:%slibopencl-mesa%s" % (mlprefix, suffix), "1")
 
-    for p in (("egl", "libegl", "libegl1"),
-              ("opengl", "libgl", "libgl1"),
-              ("glvnd", "libglx",),
-              ("gles", "libgles1", "libglesv1-cm1"),
-              ("gles", "libgles2", "libglesv2-2"),
-              ("gles", "libgles3",)):
-        if not p[0] in pkgconfig:
-            continue
-        fullp = mlprefix + p[1] + "-mesa" + suffix
-        pkgs = " " + " ".join(mlprefix + x + suffix for x in p[1:])
-        d.setVar("DEBIAN_NOAUTONAME:" + fullp, "1")
-        d.appendVar("RREPLACES:" + fullp, pkgs)
-        d.appendVar("RPROVIDES:" + fullp, pkgs)
-        d.appendVar("RCONFLICTS:" + fullp, pkgs)
-
-        # For -dev, the first element is both the Debian and original name
-        fullp = mlprefix + p[1] + "-mesa-dev" + suffix
-        pkgs = " " + mlprefix + p[1] + "-dev" + suffix
-        d.setVar("DEBIAN_NOAUTONAME:" + fullp, "1")
-        d.appendVar("RREPLACES:" + fullp, pkgs)
-        d.appendVar("RPROVIDES:" + fullp, pkgs)
-        d.appendVar("RCONFLICTS:" + fullp, pkgs)
+    if 'glvnd' not in pkgconfig:
+        for p in (("egl", "libegl", "libegl1"),
+                  ("opengl", "libgl", "libgl1"),
+                  ("gles", "libgles1", "libglesv1-cm1"),
+                  ("gles", "libgles2", "libglesv2-2"),
+                  ("gles", "libgles3",)):
+            if not p[0] in pkgconfig:
+                continue
+            fullp = mlprefix + p[1] + "-mesa" + suffix
+            pkgs = " " + " ".join(mlprefix + x + suffix for x in p[1:])
+            d.setVar("DEBIAN_NOAUTONAME:" + fullp, "1")
+            d.appendVar("RREPLACES:" + fullp, pkgs)
+            d.appendVar("RPROVIDES:" + fullp, pkgs)
+            d.appendVar("RCONFLICTS:" + fullp, pkgs)
+
+            # For -dev, the first element is both the Debian and original name
+            fullp = mlprefix + p[1] + "-mesa-dev" + suffix
+            pkgs = " " + mlprefix + p[1] + "-dev" + suffix
+            d.setVar("DEBIAN_NOAUTONAME:" + fullp, "1")
+            d.appendVar("RREPLACES:" + fullp, pkgs)
+            d.appendVar("RPROVIDES:" + fullp, pkgs)
+            d.appendVar("RCONFLICTS:" + fullp, pkgs)
 }
 
 python mesa_populate_packages() {
Signature · 1 line
2.39.5
#4 lore raw

PATCH 5/5 mesa: sort out PROVIDES for the glvnd case

In reply to Dmitry Baryshkov

If mesa is built with GLVND enabled, it doesn't provide GL / GL ES / EGL libraries directly. Instead it provides two ICD libraries: libEGL_mesa.0 and libGLX_mesa.so.0. Remove virtual provides from the glvnd case (dropping incorrect virtual/libglx provider while we are at it) and replace those with runtime providers (to be used by libglvnd in order to pull corresponding ICDs).

---
 meta/conf/distro/include/default-providers.inc |  3 ++-
 meta/recipes-graphics/mesa/mesa.inc            | 12 +++++++++---
 2 files changed, 11 insertions(+), 4 deletions(-)
meta/conf/distro/include/default-providers.inc +2 -1
index ee91af87968f..4f094163546c 100644
@@ -7,8 +7,9 @@ PREFERRED_PROVIDER_virtual/xserver-xf86 ?= "xserver-xorg"
 PREFERRED_PROVIDER_virtual/libsdl2 ?= "libsdl2"
 PREFERRED_PROVIDER_virtual/libsdl2-native ?= "libsdl2-native"
 PREFERRED_PROVIDER_virtual/egl ?= "mesa"
+PREFERRED_PROVIDER_virtual/libegl-icd ?= "mesa"
 PREFERRED_PROVIDER_virtual/libgl ?= "mesa"
-PREFERRED_PROVIDER_virtual/libglx ?= "mesa"
+PREFERRED_PROVIDER_virtual/libglx-icd ?= "mesa"
 PREFERRED_PROVIDER_virtual/libgl-native ?= "mesa-native"
 PREFERRED_PROVIDER_virtual/nativesdk-libgl ?= "nativesdk-mesa"
 PREFERRED_PROVIDER_virtual/libgles1 ?= "mesa"
meta/recipes-graphics/mesa/mesa.inc +9 -3
index 53f77b98c898..dca706efec68 100644
@@ -39,11 +39,13 @@ do_install:append() {
 
 DEPENDS = "expat makedepend-native flex-native bison-native libxml2-native zlib chrpath-replacement-native python3-mako-native gettext-native python3-pyyaml-native"
 EXTRANATIVEPATH += "chrpath-native"
-PROVIDES = " \
+GLPROVIDES = " \
     ${@bb.utils.contains('PACKAGECONFIG', 'opengl', 'virtual/libgl', '', d)} \
-    ${@bb.utils.contains('PACKAGECONFIG', 'glvnd', 'virtual/libglx', '', d)} \
     ${@bb.utils.contains('PACKAGECONFIG', 'gles', 'virtual/libgles1 virtual/libgles2 virtual/libgles3', '', d)} \
     ${@bb.utils.contains('PACKAGECONFIG', 'egl', 'virtual/egl', '', d)} \
+"
+PROVIDES = " \
+    ${@bb.utils.contains('PACKAGECONFIG', 'glvnd', '', d.getVar('GLPROVIDES'), d)} \
     ${@bb.utils.contains('PACKAGECONFIG', 'gbm', 'virtual/libgbm', '', d)} \
     virtual/mesa \
     "
@@ -289,7 +291,11 @@ python __anonymous() {
 
     d.setVar("DEBIAN_NOAUTONAME:%slibopencl-mesa%s" % (mlprefix, suffix), "1")
 
-    if 'glvnd' not in pkgconfig:
+    if 'glvnd' in pkgconfig:
+        for p in ("libegl", "libglx"):
+            fullp = mlprefix + p + "-mesa" + suffix
+            d.appendVar("RPROVIDES:" + fullp, '%s-icd' % p)
+    else:
         for p in (("egl", "libegl", "libegl1"),
                   ("opengl", "libgl", "libgl1"),
                   ("gles", "libgles1", "libglesv1-cm1"),
Signature · 1 line
2.39.5
#5 lore raw
In reply to Dmitry Baryshkov

2025. 05. 20. 19:45 keltezéssel, Dmitry Baryshkov via lists.openembedded.org írta:

Quoted 13 lines

If GLVND is enabled, there is no libgles2-mesa package to depend on libgles3-mesa. Stop building unused empty package in this case.

---
  meta/recipes-graphics/mesa/mesa.inc | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
meta/recipes-graphics/mesa/mesa.inc +0 -0
index 288027bbb996..89ae71595991 100644

meta/recipes-graphics/mesa/mesa.inc RDEPENDS:libgles3-mesa-dev += "libgles2-mesa-dev" · line 250

Quoted 5 lines
meta/recipes-graphics/mesa/mesa.inc +1 -1
@@ -247,7 +247,7 @@ RDEPENDS:libgles3-mesa-dev += "libgles2-mesa-dev"
  # GLES2 and GLES3 implementations are packaged in a single library in libgles2-mesa.
  # Add a dependency so the GLES3 dev package is associated with its implementation.
  RDEPENDS:libgles2-mesa += "libgles3-mesa"
-ALLOW_EMPTY:libgles3-mesa = "1"
+ALLOW_EMPTY:libgles3-mesa = "${@bb.utils.contains('PACKAGECONFIG', 'glvnd', '', '1', d)}"

Why not merge the two packages instead?
The GLES implementation in Mesa includes both 2.x and 3.x, regardless of being standalone lib or ICD.

#6 lore raw
Quoted 9 lines · Böszörményi Zoltán

2025. 05. 20. 19:45 keltezéssel, Dmitry Baryshkov via lists.openembedded.org írta:

Quoted 8 lines

If GLVND is enabled, there is no libgles2-mesa package to depend on libgles3-mesa. Stop building unused empty package in this case.

---
  meta/recipes-graphics/mesa/mesa.inc | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 14 lines

meta/recipes-graphics/mesa/mesa.inc RDEPENDS:libgles3-mesa-dev += "libgles2-mesa-dev" · line 250

Quoted 10 lines
meta/recipes-graphics/mesa/mesa.inc +1 -1
index 288027bbb996..89ae71595991 100644
@@ -247,7 +247,7 @@ RDEPENDS:libgles3-mesa-dev += "libgles2-mesa-dev"
  # GLES2 and GLES3 implementations are packaged in a single library in libgles2-mesa.
  # Add a dependency so the GLES3 dev package is associated with its implementation.
  RDEPENDS:libgles2-mesa += "libgles3-mesa"
-ALLOW_EMPTY:libgles3-mesa = "1"
+ALLOW_EMPTY:libgles3-mesa = "${@bb.utils.contains('PACKAGECONFIG', 'glvnd', '', '1', d)}"

Why not merge the two packages instead?
The GLES implementation in Mesa includes both 2.x and 3.x, regardless of being standalone lib or ICD.

Might be a good idea, indeed.

Signature · 2 lines
With best wishes
Dmitry