Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-116676

EGL and GLESv2 not detected with Rockchip libmali (qtbase)

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P3: Somewhat important
    • None
    • 6.5.2, 6.9
    • Build System: CMake
    • None
    • Linux/Yocto

    Description

      I'm trying to build qtbase from v6.5.2 with Yocto, with meta-qt6 (commit 74d7d77e23b144cbb801cf6af7ec78b9673158f4 (HEAD -> 6.5.2, tag: v6.5.2, origin/6.5.2)) and poky 4.0.7 (Kirkstone), with GPU support on a Rockchip PX30-based platform (therefore Aarch64 CPU, Mali Bifrost G31).

      PACKAGECONFIG variable should contain the appropriate variables:

      $ bitbake-getvar -r qtbase PACKAGECONFIG
      [...]
      # pre-expansion value:
      #   "    ${PACKAGECONFIG_DEFAULT}     ${PACKAGECONFIG_GRAPHICS}     ${PACKAGECONFIG_X11}     ${PACKAGECONFIG_KDE}     ${PACKAGECONFIG_FONTS}     ${PACKAGECONFIG_SYSTEM}     ${PACKAGECONFIG_DISTRO} "
      PACKAGECONFIG="        accessibility     dbus     fontconfig     glib     gui     harfbuzz     icu     jpeg     libinput          openssl      png     udev     widgets     xkbcommon     zlib          zstd               kms gbm gles2 eglfs                      fontconfig           "

      This platform is using Rockchip's libmali (https://github.com/JeffyCN/mirrors/tree/libmali, commit c861959 (HEAD) meson: Support optimize-level option).

      The parameters passed to libmali's meson build system are:

      $ bitbake-getvar -r rockchip-libmali EXTRA_OEMESON
      [...]
      # pre-expansion value:
      #   "   -Dgpu=${MALI_GPU}       -Dversion=${MALI_VERSION}       -Dsubversion=${MALI_SUBVERSION}         -Dplatform=${MALI_PLATFORM}  ${PACKAGECONFIG_CONFARGS}"
      EXTRA_OEMESON="         -Dgpu=bifrost-g31       -Dversion=rxp0  -Dsubversion=none       -Dplatform=gbm  "

      Configuring qtbase with forced gles2 and eglfs fails because the libraries cannot be found.

      This is qtbase configure cmake error output:

       

      $ cat /yocto/build-kirkstone/tmp/work/armv8a-poky-linux/qtbase/6.5.2-r0/qtbase-6.5.2/CMakeFiles/CMakeError.log
      [...]
      Performing C++ SOURCE FILE Test HAVE_EGL failed with the following output:
      Change Dir: /yocto/build-kirkstone/tmp/work/armv8a-poky-linux/qtbase/6.5.2-r0/qtbase-6.5.2/CMakeFiles/CMakeTmpRun Build Command(s):ninja cmTC_ced9e && [1/2] Building CXX object CMakeFiles/cmTC_ced9e.dir/src.cxx.o
      [2/2] Linking CXX executable cmTC_ced9e
      FAILED: cmTC_ced9e
      : && /yocto/build-kirkstone/tmp/work/armv8a-poky-linux/qtbase/6.5.2-r0/recipe-sysroot-native/usr/bin/aarch64-poky-linux/aarch64-poky-linux-g++ -march=armv8-a+crc -fstack-protector-strong  -O2 -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security  --sysroot=/yocto/build-kirkstone/tmp/work/armv8a-poky-linux/qtbase/6.5.2-r0/recipe-sysroot  -O2 -pipe -g -feliminate-unused-debug-types -fmacro-prefix-map=/yocto/build-kirkstone/tmp/work/armv8a-poky-linux/qtbase/6.5.2-r0=/usr/src/debug/qtbase/6.5.2-r0                      -fdebug-prefix-map=/yocto/build-kirkstone/tmp/work/armv8a-poky-linux/qtbase/6.5.2-r0=/usr/src/debug/qtbase/6.5.2-r0                      -fdebug-prefix-map=/yocto/build-kirkstone/tmp/work/armv8a-poky-linux/qtbase/6.5.2-r0/recipe-sysroot=                      -fdebug-prefix-map=/yocto/build-kirkstone/tmp/work/armv8a-poky-linux/qtbase/6.5.2-r0/recipe-sysroot-native=   -fmacro-prefix-map=/yocto/build-kirkstone/tmp/work/armv8a-poky-linux/qtbase/6.5.2-r0/image=  -fvisibility-inlines-hidden  -march=armv8-a+crc -fstack-protector-strong  -O2 -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security  --sysroot=/yocto/build-kirkstone/tmp/work/armv8a-poky-linux/qtbase/6.5.2-r0/recipe-sysroot  -O2 -pipe -g -feliminate-unused-debug-types -fmacro-prefix-map=/yocto/build-kirkstone/tmp/work/armv8a-poky-linux/qtbase/6.5.2-r0=/usr/src/debug/qtbase/6.5.2-r0                      -fdebug-prefix-map=/yocto/build-kirkstone/tmp/work/armv8a-poky-linux/qtbase/6.5.2-r0=/usr/src/debug/qtbase/6.5.2-r0                      -fdebug-prefix-map=/yocto/build-kirkstone/tmp/work/armv8a-poky-linux/qtbase/6.5.2-r0/recipe-sysroot=                      -fdebug-prefix-map=/yocto/build-kirkstone/tmp/work/armv8a-poky-linux/qtbase/6.5.2-r0/recipe-sysroot-native=   -fmacro-prefix-map=/yocto/build-kirkstone/tmp/work/armv8a-poky-linux/qtbase/6.5.2-r0/image=  -fvisibility-inlines-hidden -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed -fmacro-prefix-map=/yocto/build-kirkstone/tmp/work/armv8a-poky-linux/qtbase/6.5.2-r0=/usr/src/debug/qtbase/6.5.2-r0                      -fdebug-prefix-map=/yocto/build-kirkstone/tmp/work/armv8a-poky-linux/qtbase/6.5.2-r0=/usr/src/debug/qtbase/6.5.2-r0                      -fdebug-prefix-map=/yocto/build-kirkstone/tmp/work/armv8a-poky-linux/qtbase/6.5.2-r0/recipe-sysroot=                      -fdebug-prefix-map=/yocto/build-kirkstone/tmp/work/armv8a-poky-linux/qtbase/6.5.2-r0/recipe-sysroot-native=   -fmacro-prefix-map=/yocto/build-kirkstone/tmp/work/armv8a-poky-linux/qtbase/6.5.2-r0/image=  -Wl,-z,relro,-z,now -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed -fmacro-prefix-map=/yocto/build-kirkstone/tmp/work/armv8a-poky-linux/qtbase/6.5.2-r0=/usr/src/debug/qtbase/6.5.2-r0                      -fdebug-prefix-map=/yocto/build-kirkstone/tmp/work/armv8a-poky-linux/qtbase/6.5.2-r0=/usr/src/debug/qtbase/6.5.2-r0                      -fdebug-prefix-map=/yocto/build-kirkstone/tmp/work/armv8a-poky-linux/qtbase/6.5.2-r0/recipe-sysroot=                      -fdebug-prefix-map=/yocto/build-kirkstone/tmp/work/armv8a-poky-linux/qtbase/6.5.2-r0/recipe-sysroot-native=   -fmacro-prefix-map=/yocto/build-kirkstone/tmp/work/armv8a-poky-linux/qtbase/6.5.2-r0/image=  -Wl,-z,relro,-z,now CMakeFiles/cmTC_ced9e.dir/src.cxx.o -o cmTC_ced9e  /yocto/build-kirkstone/tmp/work/armv8a-poky-linux/qtbase/6.5.2-r0/recipe-sysroot/usr/lib/libEGL.so && :
      /yocto/build-kirkstone/tmp/work/armv8a-poky-linux/qtbase/6.5.2-r0/recipe-sysroot-native/usr/bin/aarch64-poky-linux/../../libexec/aarch64-poky-linux/gcc/aarch64-poky-linux/11.3.0/ld: CMakeFiles/cmTC_ced9e.dir/src.cxx.o: in function `main':
      /usr/src/debug/qtbase/6.5.2-r0/qtbase-6.5.2/CMakeFiles/CMakeTmp/src.cxx:6: undefined reference to `eglDestroyContext'
      collect2: error: ld returned 1 exit status
      ninja: build stopped: subcommand failed.
      Source file was:#include <EGL/egl.h>int main(int, char **) {
          EGLint x = 0; EGLDisplay dpy = 0; EGLContext ctx = 0;
          eglDestroyContext(dpy, ctx);
      }
      [...]

      Looking into the usr/lib of the sysroot of the qtbase recipe:

       

       

      $ ls -l libEGL.so* libmali.so*
      lrwxrwxrwx 1 qschulz theobroma       11 Sep  1 15:38 libEGL.so -> libEGL.so.1
      -rwxr-xr-x 3 qschulz theobroma     5792 Sep  1 15:38 libEGL.so.1
      lrwxrwxrwx 1 qschulz theobroma       12 Sep  1 15:38 libmali.so -> libmali.so.1
      lrwxrwxrwx 1 qschulz theobroma       16 Sep  1 15:38 libmali.so.1 -> libmali.so.1.9.0
      -rwxr-xr-x 4 qschulz theobroma 39674032 Sep  1 15:38 libmali.so.1.9.0 

      The symbol does exist though:

       

       

      $ grep -s -l eglDestroyContext *
      libmali-bifrost-g31-rxp0-gbm.so
      libmali.so
      libMali.so
      libmali.so.1
      libMali.so.1
      libmali.so.1.9.0

      Considering that FindEGL.cmake is the one failing, let's look into it (https://code.qt.io/cgit/qt/qtbase.git/tree/cmake/3rdparty/extra-cmake-modules/find-modules/FindEGL.cmake?h=6.5.2)

      [...]
      pkg_check_modules(PKG_EGL QUIET egl)
      
      set(EGL_DEFINITIONS ${PKG_EGL_CFLAGS_OTHER})
      
      find_path(EGL_INCLUDE_DIR
          NAMES
              EGL/egl.h
          HINTS
              ${PKG_EGL_INCLUDE_DIRS}
      )
      find_library(EGL_LIBRARY
          NAMES
              EGL
          HINTS
              ${PKG_EGL_LIBRARY_DIRS}
      ) 
      [...]

      So it is looking for a libEGL.so, which doesn't have the symbol, so makes sense it fails. However:

      $ objdump -x libEGL.so | grep NEEDED
        NEEDED               libgbm.so.1
        NEEDED               libmali.so.1
        NEEDED               libc.so.6 

      libEGL.so does have libmali.so as a NEEDED library.

      So find_library will find libEGL.so just fine, but it's not enough to compile the C validation program because it does not provide the symbol, only one of its dependencies does, and we don't pull it in. We need to have -lmali somewhere in the LDFLAGS for that to work.

      However, there's a find_package for EGL just before, and this somehow returns those because the pkgconfig file provided by Rockchip does specify this dependency:

      $ cat pkgconfig/egl.pc
      prefix=/usr
      libdir=${prefix}/lib
      includedir=${prefix}/includeName: egl
      Description: Mali GPU User-Space Binary Driver Wrappers
      Version: 7.10
      Requires: libdrm
      Libs: -L${libdir} -lmali -lEGL
      Cflags: -I${includedir}

      If I look into PKG_EGL_LIBRARIES and PKG_EGL_LINK_LIBRARIES, libmali does appear in there!

      With the following diff:

      diff --git a/cmake/3rdparty/extra-cmake-modules/find-modules/FindEGL.cmake b/cmake/3rdparty/extra-cmake-modules/find-modules/FindEGL.cmake
      index 0733f1f702..a481e4c501 100644
      --- a/cmake/3rdparty/extra-cmake-modules/find-modules/FindEGL.cmake
      +++ b/cmake/3rdparty/extra-cmake-modules/find-modules/FindEGL.cmake
      @@ -116,7 +116,7 @@ if(EGL_INCLUDE_DIR)
       endif() cmake_push_check_state(RESET)
      -list(APPEND CMAKE_REQUIRED_LIBRARIES "${EGL_LIBRARY}")
      +list(APPEND CMAKE_REQUIRED_LIBRARIES "${PKG_EGL_LINK_LIBRARIES}")
       list(APPEND CMAKE_REQUIRED_INCLUDES "${EGL_INCLUDE_DIR}")
       list(APPEND CMAKE_REQUIRED_DEFINITIONS "${EGL_DEFINITIONS}")

      I managed to get passed FindEGL.cmake failure, but FindGLESv2.cmake fails:

      $ cat /yocto/build-kirkstone/tmp/work/armv8a-poky-linux/qtbase/6.5.2-r0/qtbase-6.5.2/CMakeFiles/CMakeError.log
      [...]
      Performing C++ SOURCE FILE Test HAVE_GLESv2 failed with the following output:
      Change Dir: /yocto/build-kirkstone/tmp/work/armv8a-poky-linux/qtbase/6.5.2-r0/qtbase-6.5.2/CMakeFiles/CMakeTmpRun Build Command(s):ninja cmTC_3c937 && [1/2] Building CXX object CMakeFiles/cmTC_3c937.dir/src.cxx.o
      [2/2] Linking CXX executable cmTC_3c937
      FAILED: cmTC_3c937
      : && /yocto/build-kirkstone/tmp/work/armv8a-poky-linux/qtbase/6.5.2-r0/recipe-sysroot-native/usr/bin/aarch64-poky-linux/aarch64-poky-linux-g++ -march=armv8-a+crc -fstack-protector-strong  -O2 -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security  --sysroot=/yocto/build-kirkstone/tmp/work/armv8a-poky-linux/qtbase/6.5.2-r0/recipe-sysroot  -O2 -pipe -g -feliminate-unused-debug-types -fmacro-prefix-map=/yocto/build-kirkstone/tmp/work/armv8a-poky-linux/qtbase/6.5.2-r0=/usr/src/debug/qtbase/6.5.2-r0                      -fdebug-prefix-map=/yocto/build-kirkstone/tmp/work/armv8a-poky-linux/qtbase/6.5.2-r0=/usr/src/debug/qtbase/6.5.2-r0                      -fdebug-prefix-map=/yocto/build-kirkstone/tmp/work/armv8a-poky-linux/qtbase/6.5.2-r0/recipe-sysroot=                      -fdebug-prefix-map=/yocto/build-kirkstone/tmp/work/armv8a-poky-linux/qtbase/6.5.2-r0/recipe-sysroot-native=   -fmacro-prefix-map=/yocto/build-kirkstone/tmp/work/armv8a-poky-linux/qtbase/6.5.2-r0/image=  -fvisibility-inlines-hidden  -march=armv8-a+crc -fstack-protector-strong  -O2 -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security  --sysroot=/yocto/build-kirkstone/tmp/work/armv8a-poky-linux/qtbase/6.5.2-r0/recipe-sysroot  -O2 -pipe -g -feliminate-unused-debug-types -fmacro-prefix-map=/yocto/build-kirkstone/tmp/work/armv8a-poky-linux/qtbase/6.5.2-r0=/usr/src/debug/qtbase/6.5.2-r0                      -fdebug-prefix-map=/yocto/build-kirkstone/tmp/work/armv8a-poky-linux/qtbase/6.5.2-r0=/usr/src/debug/qtbase/6.5.2-r0                      -fdebug-prefix-map=/yocto/build-kirkstone/tmp/work/armv8a-poky-linux/qtbase/6.5.2-r0/recipe-sysroot=                      -fdebug-prefix-map=/yocto/build-kirkstone/tmp/work/armv8a-poky-linux/qtbase/6.5.2-r0/recipe-sysroot-native=   -fmacro-prefix-map=/yocto/build-kirkstone/tmp/work/armv8a-poky-linux/qtbase/6.5.2-r0/image=  -fvisibility-inlines-hidden -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed -fmacro-prefix-map=/yocto/build-kirkstone/tmp/work/armv8a-poky-linux/qtbase/6.5.2-r0=/usr/src/debug/qtbase/6.5.2-r0                      -fdebug-prefix-map=/yocto/build-kirkstone/tmp/work/armv8a-poky-linux/qtbase/6.5.2-r0=/usr/src/debug/qtbase/6.5.2-r0                      -fdebug-prefix-map=/yocto/build-kirkstone/tmp/work/armv8a-poky-linux/qtbase/6.5.2-r0/recipe-sysroot=                      -fdebug-prefix-map=/yocto/build-kirkstone/tmp/work/armv8a-poky-linux/qtbase/6.5.2-r0/recipe-sysroot-native=   -fmacro-prefix-map=/yocto/build-kirkstone/tmp/work/armv8a-poky-linux/qtbase/6.5.2-r0/image=  -Wl,-z,relro,-z,now -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed -fmacro-prefix-map=/yocto/build-kirkstone/tmp/work/armv8a-poky-linux/qtbase/6.5.2-r0=/usr/src/debug/qtbase/6.5.2-r0                      -fdebug-prefix-map=/yocto/build-kirkstone/tmp/work/armv8a-poky-linux/qtbase/6.5.2-r0=/usr/src/debug/qtbase/6.5.2-r0                      -fdebug-prefix-map=/yocto/build-kirkstone/tmp/work/armv8a-poky-linux/qtbase/6.5.2-r0/recipe-sysroot=                      -fdebug-prefix-map=/yocto/build-kirkstone/tmp/work/armv8a-poky-linux/qtbase/6.5.2-r0/recipe-sysroot-native=   -fmacro-prefix-map=/yocto/build-kirkstone/tmp/work/armv8a-poky-linux/qtbase/6.5.2-r0/image=  -Wl,-z,relro,-z,now CMakeFiles/cmTC_3c937.dir/src.cxx.o -o cmTC_3c937  /yocto/build-kirkstone/tmp/work/armv8a-poky-linux/qtbase/6.5.2-r0/recipe-sysroot/usr/lib/libGLESv2.so  /yocto/build-kirkstone/tmp/work/armv8a-poky-linux/qtbase/6.5.2-r0/recipe-sysroot/usr/lib/libEGL.so && :
      /yocto/build-kirkstone/tmp/work/armv8a-poky-linux/qtbase/6.5.2-r0/recipe-sysroot-native/usr/bin/aarch64-poky-linux/../../libexec/aarch64-poky-linux/gcc/aarch64-poky-linux/11.3.0/ld: CMakeFiles/cmTC_3c937.dir/src.cxx.o: in function `main':
      /usr/src/debug/qtbase/6.5.2-r0/qtbase-6.5.2/CMakeFiles/CMakeTmp/src.cxx:10: undefined reference to `glUniform1f'
      /yocto/build-kirkstone/tmp/work/armv8a-poky-linux/qtbase/6.5.2-r0/recipe-sysroot-native/usr/bin/aarch64-poky-linux/../../libexec/aarch64-poky-linux/gcc/aarch64-poky-linux/11.3.0/ld: /usr/src/debug/qtbase/6.5.2-r0/qtbase-6.5.2/CMakeFiles/CMakeTmp/src.cxx:11: undefined reference to `glClear'
      collect2: error: ld returned 1 exit status
      ninja: build stopped: subcommand failed.
      Source file was:#ifdef __APPLE__
      #  include <OpenGLES/ES2/gl.h>
      #else
      #  define GL_GLEXT_PROTOTYPES
      #  include <GLES2/gl2.h>
      #endifint main(int, char **) {
          glUniform1f(1, GLfloat(1.0));
          glClear(GL_COLOR_BUFFER_BIT);
      }
      [...] 

      I assume this is because FindGLESv2.cmake uses EGL_LIBRARY which only contains libEGL.so and not libmali.so, because:

      $ grep -s -l glClear *
      libmali-bifrost-g31-rxp0-gbm.so
      libmali.so
      libMali.so
      libmali.so.1
      libMali.so.1
      libmali.so.1.9.0 

      libmali.so does have this symbol.

      Any idea how to update FindEGL.cmake and FindGLESv2.cmake to make it work with Rockchip's libmali?

       

      Attachments

        For Gerrit Dashboard: QTBUG-116676
        # Subject Branch Project Status CR V

        Activity

          People

            qtbuildsystem Qt Build System Team
            qschulz Quentin Schulz
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There is 1 open Gerrit change