Skip to contentSkip to conversation

package/wayland: tweak wayland-scanner.pc after installation to fix SDL2 build issue

PATCH Applied Thomas Petazzoni via buildroot 1 participant 4 messages Aug 23, 2025 – Sep 4, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 package/wayland: tweak wayland-scanner.pc after installation to fix SDL2 build issue

Some packages such as SDL2 do this:

WAYLAND_SCANNER=$PKG_CONFIG --variable=wayland_scanner wayland-scanner

to find the path to the wayland-scanner tool.

Of course, since SDL2 is compiled for the target, it does that using the pkg-config configured for cross-compilation, which looks at $(STAGING_DIR)/usr/lib/pkgconfig/wayland-scanner.pc.

Since it looks at the variable wayland_scanner, which doesn't get prefixed by PKG_CONFIG_SYSROOT_DIR, the SDL2 configure script is told that wayland-scanner is in /usr/bin/wayland-scanner causing this kind of build failure:

/bin/bash: line 1: /usr/bin/wayland-scanner: No such file or directory /bin/bash: line 1: /usr/bin/wayland-scanner: No such file or directory

when building SDL2.

The target wayland package depends on host-wayland, which most notably is responsible for installing wayland-scanner in $(HOST_DIR)/bin.

So in order to fix the SDL2 build issue but in a global way (possibly helping other packages), what this patch does is tweak the wayland-scanner.pc installed by the target wayland so that its wayland_scanner variable points to the host wayland-scanner executable. We find this a better solution than passing a WAYLAND_SCANNER variable to each and every package that needs wayland-scanner.

The issue is not visible in the autobuilders, but can be reproduced using the following defconfig:

BR2_arm=y
BR2_cortex_a9=y
BR2_ARM_ENABLE_VFP=y
BR2_TOOLCHAIN_EXTERNAL=y
BR2_TOOLCHAIN_EXTERNAL_BOOTLIN=y
BR2_INIT_NONE=y
BR2_SYSTEM_BIN_SH_NONE=y
# BR2_PACKAGE_BUSYBOX is not set
BR2_PACKAGE_SDL2=y
BR2_PACKAGE_SDL2_WAYLAND=y
BR2_PACKAGE_SDL2_OPENGLES=y
BR2_PACKAGE_RPI_USERLAND=y
BR2_PACKAGE_WAYLAND=y
# BR2_TARGET_ROOTFS_TAR is not set

The issue probably exists since WAYLAND_SCANNER was retrieved using pkg-config in SDL2's configure.ac script, in upstream commit 19d3500ae19636f3f410e270f12e0bc5e83410d4, which got first introduced in release-2.0.5 of SDL2.

---
Note: the above configuration doesn't build due to other issues in rpi-userland, patches are coming.

---
 package/wayland/wayland.mk | 12 ++++++++++++
 1 file changed, 12 insertions(+)
package/wayland/wayland.mk +12 -0
index bb5ceabb9c..23903bafcb 100644
@@ -23,5 +23,17 @@ define WAYLAND_TARGET_CLEANUP
 endef
 WAYLAND_POST_INSTALL_TARGET_HOOKS += WAYLAND_TARGET_CLEANUP
 
+# The wayland-scanner.pc installed by the target wayland package is
+# used to find the wayland-scanner tool, which in a cross-compilation
+# context is compiled for the host (and in Buildroot, compiled by
+# host-wayland). Below, we tweak the target wayland-scanner.pc so that
+# when the wayland_scanner variable is requested through pkg-config,
+# it points to the host wayland_scanner tool.
+define WAYLAND_TWEAK_WAYLAND_SCANNER_PATH
+	$(SED) 's%^wayland_scanner=.*%wayland_scanner=$(HOST_DIR)/bin/wayland-scanner%' \
+		$(STAGING_DIR)/usr/lib/pkgconfig/wayland-scanner.pc
+endef
+WAYLAND_POST_INSTALL_TARGET_HOOKS += WAYLAND_TWEAK_WAYLAND_SCANNER_PATH
+
 $(eval $(meson-package))
 $(eval $(host-meson-package))
Signature · 6 lines
2.50.1

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#1 lore raw

Hello Thomas, All,

Le 23/08/2025 à 22:40, Thomas Petazzoni via buildroot a écrit :

Quoted 9 lines

Some packages such as SDL2 do this:

WAYLAND_SCANNER=$PKG_CONFIG --variable=wayland_scanner wayland-scanner

to find the path to the wayland-scanner tool.

Of course, since SDL2 is compiled for the target, it does that using the pkg-config configured for cross-compilation, which looks at $(STAGING_DIR)/usr/lib/pkgconfig/wayland-scanner.pc.

Before this patch:

host/bin/pkg-config --variable=wayland_scanner wayland-scanner /usr/bin/wayland-scanner

After this patch:

host/bin/pkg-config --variable=wayland_scanner wayland-scanner [...]/host/bin/wayland-scanner

Quoted 22 lines

Since it looks at the variable wayland_scanner, which doesn't get prefixed by PKG_CONFIG_SYSROOT_DIR, the SDL2 configure script is told that wayland-scanner is in /usr/bin/wayland-scanner causing this kind of build failure:

/bin/bash: line 1: /usr/bin/wayland-scanner: No such file or directory /bin/bash: line 1: /usr/bin/wayland-scanner: No such file or directory

when building SDL2.

The target wayland package depends on host-wayland, which most notably is responsible for installing wayland-scanner in $(HOST_DIR)/bin.

So in order to fix the SDL2 build issue but in a global way (possibly helping other packages), what this patch does is tweak the wayland-scanner.pc installed by the target wayland so that its wayland_scanner variable points to the host wayland-scanner executable. We find this a better solution than passing a WAYLAND_SCANNER variable to each and every package that needs wayland-scanner.

Quoted 2 lines

The issue is not visible in the autobuilders, but can be reproduced using the following defconfig:

It seems obvious that /usr/bin/wayland-scanner should not exist on the build machine to reproduce the issue. I didn't checked that before trying to reproduce the issue so sdl2 build fine. Maybe /usr/bin/wayland-scanner is installed on autobuilders?

Quoted 21 lines

BR2_arm=y
BR2_cortex_a9=y
BR2_ARM_ENABLE_VFP=y
BR2_TOOLCHAIN_EXTERNAL=y
BR2_TOOLCHAIN_EXTERNAL_BOOTLIN=y
BR2_INIT_NONE=y
BR2_SYSTEM_BIN_SH_NONE=y
# BR2_PACKAGE_BUSYBOX is not set
BR2_PACKAGE_SDL2=y
BR2_PACKAGE_SDL2_WAYLAND=y
BR2_PACKAGE_SDL2_OPENGLES=y
BR2_PACKAGE_RPI_USERLAND=y
BR2_PACKAGE_WAYLAND=y
# BR2_TARGET_ROOTFS_TAR is not set

The issue probably exists since WAYLAND_SCANNER was retrieved using pkg-config in SDL2's configure.ac script, in upstream commit 19d3500ae19636f3f410e270f12e0bc5e83410d4, which got first introduced in release-2.0.5 of SDL2.

Quoted 4 lines

---
Note: the above configuration doesn't build due to other issues in rpi-userland, patches are coming.

Patch merged:
https://gitlab.com/buildroot.org/buildroot/-/commit/0f20d9a9b8a7520ec747c785de9f522f5f81374d

Applied to master, thanks.

Best regards,
Romain

Quoted 16 lines
---
 package/wayland/wayland.mk | 12 ++++++++++++
 1 file changed, 12 insertions(+)
package/wayland/wayland.mk +4 -0
index bb5ceabb9c..23903bafcb 100644
@@ -23,5 +23,17 @@ define WAYLAND_TARGET_CLEANUP
 endef
 WAYLAND_POST_INSTALL_TARGET_HOOKS += WAYLAND_TARGET_CLEANUP
 
+# The wayland-scanner.pc installed by the target wayland package is
+# used to find the wayland-scanner tool, which in a cross-compilation
+# context is compiled for the host (and in Buildroot, compiled by
+# host-wayland). Below, we tweak the target wayland-scanner.pc so that

package/wayland/wayland.mk define WAYLAND_TARGET_CLEANUP · line 39

Quoted 10 lines
package/wayland/wayland.mk +8 -0
+# when the wayland_scanner variable is requested through pkg-config,
+# it points to the host wayland_scanner tool.
+define WAYLAND_TWEAK_WAYLAND_SCANNER_PATH
+	$(SED) 's%^wayland_scanner=.*%wayland_scanner=$(HOST_DIR)/bin/wayland-scanner%' \
+		$(STAGING_DIR)/usr/lib/pkgconfig/wayland-scanner.pc
+endef
+WAYLAND_POST_INSTALL_TARGET_HOOKS += WAYLAND_TWEAK_WAYLAND_SCANNER_PATH
+
 $(eval $(meson-package))
 $(eval $(host-meson-package))

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

#2 lore raw

Hello Romain,

Quoted 4 lines · On Sun, 24 Aug 2025 14:11:31 +0200 Romain Naour <[email protected]> wrote:

It seems obvious that /usr/bin/wayland-scanner should not exist on the build machine to reproduce the issue. I didn't checked that before trying to reproduce the issue so sdl2 build fine. Maybe /usr/bin/wayland-scanner is installed on autobuilders?

As you're probably aware there is not such thing as a "standard" configuration for the autobuilder workers. Each worker is using its own distro, with some set of installed packages, depending on who runs this worker. So some may have /usr/bin/wayland-scanner installed, some may not.

And this is actually a _good_ thing, as we do want a variety of hosts systems to be used for our testing.

Thomas

Signature · 7 lines
Thomas Petazzoni, co-owner and CEO, Bootlin
Embedded Linux and Kernel engineering and training
https://bootlin.com
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#3 lore raw

Hello Thomas,

Le 04/09/2025 à 09:24, Thomas Petazzoni a écrit :

Quoted 10 lines

Hello Romain,

Quoted 4 lines · On Sun, 24 Aug 2025 14:11:31 +0200 Romain Naour <[email protected]> wrote:

It seems obvious that /usr/bin/wayland-scanner should not exist on the build machine to reproduce the issue. I didn't checked that before trying to reproduce the issue so sdl2 build fine. Maybe /usr/bin/wayland-scanner is installed on autobuilders?

Quoted 8 lines

As you're probably aware there is not such thing as a "standard" configuration for the autobuilder workers. Each worker is using its own distro, with some set of installed packages, depending on who runs this worker. So some may have /usr/bin/wayland-scanner installed, some may not.

And this is actually a _good_ thing, as we do want a variety of hosts systems to be used for our testing.

I'm totally agree. It's just a comment about how to reproduce the issue easily that could be added in the commit log. I'm fine with your patch.

Best regards,
Romain

Quoted 2 lines

Thomas

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot