package/mesa3d: fix build on m68k
authorGiulio Benetti <giulio.benetti@benettiengineering.com>
Sun, 19 Sep 2021 00:51:54 +0000 (02:51 +0200)
committerYann E. MORIN <yann.morin.1998@free.fr>
Sun, 19 Sep 2021 08:08:24 +0000 (10:08 +0200)
mesa3d uses very big switch statements, which causes the build to fail
on m68k, beause the offsets there are only 16-bit.

We fix that by using -mlong-jump-table-offsets on m68k, to use 32-bit
offsets for switch statements, but this is only available starting with
gcc 7 [0] [1].

Fixes:
http://autobuild.buildroot.net/results/60c4653c2a93125edbdd0beb43cd47301643464a/

Note: we have two packages that select mesa3d, but:
    package/intel-mediadriver/
        -> already depends on x86_64, so implies !m68k

    package/x11r7/xdriver_xf86-video-imx-viv/
        -> imx is an ARM, but xdriver_xf86-video-imx-viv is missing
           a depends on BR2_arm (although the comments do have that
           dependency). However, it depends on other imx related
           packages, and they depend on either arm or aarch64, so
           that implies !m68k.

As such, we do not need to propagate that new dependency.

[0] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=57583#c15
[1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=57583#c16

Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com>
[yann.morin.1998@free.fr:
  - add comment
  - reword commit log, add BZ references, add non-propagation notes
]
Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
package/mesa3d/Config.in
package/mesa3d/mesa3d.mk

index eb7c1eef467f4399597325ae4f7461a352e9d63d..82a40511f13cef941c83de053fe807d5f8a2dcbe 100644 (file)
@@ -4,6 +4,7 @@ menuconfig BR2_PACKAGE_MESA3D
        depends on !BR2_STATIC_LIBS
        depends on BR2_TOOLCHAIN_HAS_SYNC_1
        depends on BR2_TOOLCHAIN_HAS_THREADS_NPTL
+       depends on !BR2_m68k || BR2_TOOLCHAIN_GCC_AT_LEAST_7 # m68k needs gcc >= 7.x
        select BR2_PACKAGE_EXPAT
        select BR2_PACKAGE_LIBDRM
        select BR2_PACKAGE_WAYLAND_PROTOCOLS if BR2_PACKAGE_WAYLAND
@@ -441,3 +442,7 @@ comment "mesa3d needs a toolchain w/ C++, NPTL, dynamic library"
        depends on !BR2_INSTALL_LIBSTDCPP || !BR2_TOOLCHAIN_HAS_THREADS_NPTL || \
                BR2_STATIC_LIBS
        depends on BR2_TOOLCHAIN_HAS_SYNC_1
+
+comment "mesa3d needs a toolchain w/ gcc >= 7"
+       depends on BR2_m68k
+       depends on !BR2_TOOLCHAIN_GCC_AT_LEAST_7
index 1a9e355641ce98763564a085cb2b78155a19f757..f1862aed690bbabc234ef77ca45d07f02211de0d 100644 (file)
@@ -259,4 +259,13 @@ else
 MESA3D_CONF_OPTS += -Dzstd=disabled
 endif
 
+MESA3D_CFLAGS = $(TARGET_CFLAGS)
+
+# m68k needs 32-bit offsets in switch tables to build
+ifeq ($(BR2_m68k),y)
+MESA3D_CFLAGS += -mlong-jump-table-offsets
+endif
+
+MESA3D_CONF_OPTS += -DCMAKE_C_FLAGS="$(MESA3D_CFLAGS)"
+
 $(eval $(meson-package))