Igalia / meta-webkit

Yocto / OpenEmbedded layer for WebKit based engines and browsers
MIT License
127 stars 70 forks source link

webkitgtk: Build issue on i.MX6 with wayland target #331

Closed dharanlinux closed 1 year ago

dharanlinux commented 2 years ago

Hi Team,

While building with wayland target, facing below build issue.

The default yocto build passing the '-DWL_EGL_PLATFORM' options, still we facing the issue.

Hardware: imx6qsabresd

                  -fdebug-prefix-map=/home/linux/Download/imx-yocto-bsp/build-weston/tmp/work/cortexa9t2hf-neon-mx6qdl-poky-linux-gnueabi/webkitgtk/2.34.1-r0/recipe-sysroot-native=  -fvisibility-inlines-hidden  -mthumb -mfpu=neon -mfloat-abi=hard -mcpu=cortex-a9 -fstack-protector-strong  -O2 -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security  --sysroot=/home/linux/Download/imx-yocto-bsp/build-weston/tmp/work/cortexa9t2hf-neon-mx6qdl-poky-linux-gnueabi/webkitgtk/2.34.1-r0/recipe-sysroot -fno-strict-aliasing -fno-exceptions -fno-rtti -DNDEBUG -fPIC -DLINUX -DWL_EGL_PLATFORM -pthread -std=c++17 -MD -MT Source/WebCore/CMakeFiles/WebCore.dir/platform/graphics/egl/GLContextEGL.cpp.o -MF Source/WebCore/CMakeFiles/WebCore.dir/platform/graphics/egl/GLContextEGL.cpp.o.d -o Source/WebCore/CMakeFiles/WebCore.dir/platform/graphics/egl/GLContextEGL.cpp.o -c /home/linux/Download/imx-yocto-bsp/build-weston/tmp/work/cortexa9t2hf-neon-mx6qdl-poky-linux-gnueabi/webkitgtk/2.34.1-r0/webkitgtk-2.34.1/Source/WebCore/platform/graphics/egl/GLContextEGL.cpp
| /home/linux/Download/imx-yocto-bsp/build-weston/tmp/work/cortexa9t2hf-neon-mx6qdl-poky-linux-gnueabi/webkitgtk/2.34.1-r0/webkitgtk-2.34.1/Source/WebCore/platform/graphics/egl/GLContextEGL.cpp: In static member function 'static std::unique_ptr<WebCore::GLContextEGL> WebCore::GLContextEGL::createWindowContext(GLNativeWindowType, WebCore::PlatformDisplay&, EGLContext)':
| /home/linux/Download/imx-yocto-bsp/build-weston/tmp/work/cortexa9t2hf-neon-mx6qdl-poky-linux-gnueabi/webkitgtk/2.34.1-r0/webkitgtk-2.34.1/Source/WebCore/platform/graphics/egl/GLContextEGL.cpp:198:59: error: invalid 'static_cast' from type 'GLNativeWindowType' {aka 'long long unsigned int'} to type 'EGLNativeWindowType' {aka 'wl_egl_window*'}
|   198 |         surface = eglCreateWindowSurface(display, config, static_cast<EGLNativeWindowType>(window), nullptr);
|       |                                                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| In file included from /home/linux/Download/imx-yocto-bsp/build-weston/tmp/work/cortexa9t2hf-neon-mx6qdl-poky-linux-gnueabi/webkitgtk/2.34.1-r0/webkitgtk-2.34.1/Source/WebCore/platform/graphics/egl/GLContextEGL.cpp:20:
| /home/linux/Download/imx-yocto-bsp/build-weston/tmp/work/cortexa9t2hf-neon-mx6qdl-poky-linux-gnueabi/webkitgtk/2.34.1-r0/webkitgtk-2.34.1/Source/WebCore/platform/graphics/egl/GLContextEGL.h:32:8: note: class type 'wl_egl_window' is incomplete
|    32 | struct wl_egl_window;
psaavedra commented 2 years ago

Can you share here the Build Configuration Bitbake output and also de local.conf?

dharanlinux commented 2 years ago

Please check the below details:

Build Configuration:
BB_VERSION           = "1.50.0"
BUILD_SYS            = "x86_64-linux"
NATIVELSBSTRING      = "ubuntu-18.04"
TARGET_SYS           = "arm-poky-linux-gnueabi"
MACHINE              = "imx6qsabresd"
DISTRO               = "fsl-imx-xwayland"
DISTRO_VERSION       = "5.10-hardknott"
TUNE_FEATURES        = "arm vfp cortexa9 neon thumb callconvention-hard"
TARGET_FPU           = "hard"
meta                 
meta-poky            = "HEAD:14c5392fded42f17962e1cc07fcc0446881b4fa0"
meta-oe              
meta-multimedia      
meta-python          = "HEAD:5a4b2ab29d38c02535f24d5308cc40615739f557"
meta-freescale       = "HEAD:2027a8045384463b7c793381dd887b0591037e2f"
meta-freescale-3rdparty = "HEAD:060967a7df43e8505568aa3d54fd8addcecab98d"
meta-freescale-distro = "HEAD:916df6d24c0a33a3b1533bde70b6a2724ec77af4"
meta-bsp             
meta-sdk             
meta-ml              
meta-v2x             = "HEAD:426311a3f4e6936125c0599a34d8f6133dd2460d"
meta-nxp-demo-experience = "HEAD:71d85758f4189a065e69b10527e4014e998d0a80"
meta-chromium        = "HEAD:8be1d3a0ba0cf32e61144900597207af5698c10d"
meta-clang           = "HEAD:7ef47d048267cf755c496a3962b34314f6f1f1e1"
meta-gnome           
meta-networking      
meta-filesystems     = "HEAD:5a4b2ab29d38c02535f24d5308cc40615739f557"
meta-qt5             = "HEAD:a00af3eae082b772469d9dd21b2371dd4d237684"
meta-python2         = "HEAD:8db9e4f6ceae33d7a4f55453d31e69f9858af4eb"
meta-webkit          = "main:9b1b84048fd12f92b6b506a96fe1fdec18c178b1"

Initialising tasks: 100%

The local.conf file:

MACHINE ??= 'imx6qsabresd'
DISTRO ?= 'fsl-imx-xwayland'
PACKAGE_CLASSES ?= 'package_rpm'
EXTRA_IMAGE_FEATURES ?= "debug-tweaks"
USER_CLASSES ?= "buildstats image-mklibs image-prelink"
PATCHRESOLVE = "noop"
BB_DISKMON_DIRS ??= "\
    STOPTASKS,${TMPDIR},1G,100K \
    STOPTASKS,${DL_DIR},1G,100K \
    STOPTASKS,${SSTATE_DIR},1G,100K \
    STOPTASKS,/tmp,100M,100K \
    ABORT,${TMPDIR},100M,1K \
    ABORT,${DL_DIR},100M,1K \
    ABORT,${SSTATE_DIR},100M,1K \
    ABORT,/tmp,10M,1K"
PACKAGECONFIG_append_pn-qemu-system-native = " sdl"
CONF_VERSION = "1"

DL_DIR ?= "${BSPDIR}/downloads/"
ACCEPT_FSL_EULA = "1"

IMAGE_INSTALL_append = " webkitgtk-bin"

# Switch to Debian packaging and include package-management in the image
PACKAGE_CLASSES = "package_deb"
EXTRA_IMAGE_FEATURES += "package-management"
dharanlinux commented 2 years ago

Hi Team,

Do we have fixup for this issue?

psaavedra commented 2 years ago

Sorry I didn't tested that yet. Let me first try to reproduce the issue in local.

psaavedra commented 2 years ago

It seems that the EGLNativeWindowType changes depending on the EGL implementation. In https://bugs.webkit.org/show_bug.cgi?id=178090 @aperezdc uses a plain C cast expression. The reason is because a plain C cast expression works in all cases. On the contrary, reinterpret_cast for pointers (only if they are 64-bit wide and not for other cases) and static_cast for numeric types (and when needed they get extended to 64-bit) but not for pointers. However in the error pasted above, it looks like the 'wl_egl_window' definition is incomplete. Some missing header (struct defined in egl/wayland-egl-backend.h). This error could point directly to some missing dependency or some particular case because the wayland library version in use.

aperezdc commented 2 years ago

In this case the incomplete definition of wl_egl_window is intended, note how in GLContextEGL.h there is a forward-declaration:

#if PLATFORM(WAYLAND)
#include "WlUniquePtr.h"
struct wl_egl_window;
#endif

Indeed if one tries to compile the following reduced case with g++ -c it fails with a similar error:

struct wl_egl_window;            // Forward declaration
extern long long unsigned value; // The type of GLNativeWindowType

// Type definition from the EGL khrplatform.h header
typedef struct wl_egl_window* EGLNativeWindowType;

int main() {                                                                                
    return static_cast<EGLNativeWindowType>(value) == 0;                         
}
aperezdc commented 2 years ago

This is where GLNativeWindowType gets defined, in GLContext.h (slightly reformatted for clarity):

#if USE(EGL) && !PLATFORM(GTK)
    #if PLATFORM(WPE)
        // FIXME: For now default to the GBM EGL platform, but this should really be
        // somehow deducible from the build configuration.
        #define __GBM__ 1
    #endif // PLATFORM(WPE)

    #include <EGL/eglplatform.h>
    typedef EGLNativeWindowType GLNativeWindowType;

#else // !USE(EGL) || PLATFORM(GTK)
    typedef uint64_t GLNativeWindowType;
#endif

Which means we have a case here where GLNativeWindowType is defined to be an integer instead of a pointer for the GTK port. While that is okay on X11/GLX where windows are represented by their XID (an integer), for builds where we have GTK with Wayland support but no X11 then I think this might be a problem.

aperezdc commented 2 years ago

@dharanlinux Could you share the CMake command from the tmp/work/*/wpewebkit/2.34.*/temp/run.do_configure file? That way we would know exactly how the build is being configured.

dharanlinux commented 2 years ago

@aperezdc Please check the below details. If you need further info please let me know.

-DPORT=GTK -DENABLE_INTROSPECTION=OFF -DENABLE_GTKDOC=OFF -DENABLE_MINIBROWSER=ON -DUSE_SOUP2=ON -G Ninja -DENABLE_BUBBLEWRAP_SANDBOX=OFF -DENABLE_SPELLCHECK=ON -DENABLE_GAMEPAD=OFF -DENABLE_GEOLOCATION=OFF -DENABLE_GLES2=ON -DUSE_LD_GOLD=ON -DENABLE_JIT=ON -DENABLE_C_LOOP=OFF -DUSE_LIBHYPHEN=OFF -DUSE_LIBNOTIFY=OFF -DUSE_LIBSECRET=ON -DENABLE_OPENGL=ON -DUSE_OPENJPEG=ON -DCMAKE_BUILD_TYPE=Release -DUSE_SYSTEMD=ON -DENABLE_VIDEO=ON -DENABLE_WAYLAND_TARGET=ON -DENABLE_WEB_CRYPTO=ON -DENABLE_WEBGL=ON -DUSE_WOFF2=ON -DUSE_WPE_RENDERER=ON -DENABLE_X11_TARGET=ON \
dharanlinux commented 2 years ago

Hi @aperezdc , any update on this issue. Do we need further information from my build setup?

adahl5 commented 2 years ago

I've also just run into this exact issue. I don't know enough about C(++) to grasp what's going on. I've tried just de-referencing the 'window' variable from the wl_egl_window* type (likely a bad idea) but that hasn't worked. Is there a missing dependency I'm overlooking? I've seen plenty of examples of people building webkitgtk for the iMX6, so it'd be odd for it to suddenly break.

I'm also getting dozens of -Wcast-align warnings but I'm not sure if that's related.

adahl5 commented 2 years ago

I was able to get webkitgtk to compile by changing surface = eglCreateWindowSurface(display, config, static_cast<EGLNativeWindowType>(window), nullptr); to surface = eglCreateWindowSurface(display, config, reinterpret_cast<EGLNativeWindowType>(window), nullptr); in Source/WebCore/platform/graphics/egl/GLContextEGL.cpp

I based this change on GLContextEGLWayland.cpp found in the same directory as GLContextEGL.cpp. I'm not sure why I needed to manually make the change, but it compiled; though I don't seem to have hardware accelerated graphics. Not sure if that's related.

ShinraYamato commented 2 years ago

Facing the exact same problem on a LS1028ARDB, did @adahl5's trick, package now compiles

github-actions[bot] commented 1 year ago

This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 7 days.

matteoscordino commented 1 year ago

I am having a very similar issue on webkit 2.38.3, building for i.MX8, so this shouldn't be marked as stale.

| /mnt//work/compulab-nxp-bsp/build-ucm-imx8m-plus/tmp/work/armv8a-mx8mp-poky-linux/webkitgtk/2.38.3-r0/webkitgtk-2.38.3/Source/WebCore/platform/graphics/egl/GLContextEGL.cpp: In static member function 'static std::unique_ptr<WebCore::GLContextEGL> WebCore::GLContextEGL::createWindowContext(GLNativeWindowType, WebCore::PlatformDisplay&, EGLContext)':                                                        
| /mnt//work/compulab-nxp-bsp/build-ucm-imx8m-plus/tmp/work/armv8a-mx8mp-poky-linux/webkitgtk/2.38.3-r0/webkitgtk-2.38.3/Source/WebCore/platform/graphics/egl/GLContextEGL.cpp:198:59: error: invalid 'static_cast' from type 'GLNativeWindowType' {aka 'long unsigned int'} to type 'EGLNativeWindowType' {aka 'wl_egl_window*'}                                                                                       
|   198 |         surface = eglCreateWindowSurface(display, config, static_cast<EGLNativeWindowType>(window), nullptr);                                                                                              
|       |                                                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~                                                                                                         
| In file included from /mnt//work/compulab-nxp-bsp/build-ucm-imx8m-plus/tmp/work/armv8a-mx8mp-poky-linux/webkitgtk/2.38.3-r0/webkitgtk-2.38.3/Source/WebCore/platform/graphics/egl/GLContextEGL.cpp:20:                                                                                                                                                                               
| /mnt//work/compulab-nxp-bsp/build-ucm-imx8m-plus/tmp/work/armv8a-mx8mp-poky-linux/webkitgtk/2.38.3-r0/webkitgtk-2.38.3/Source/WebCore/platform/graphics/egl/GLContextEGL.h:32:8: note: class type 'wl_egl_window' is incomplete                                                                                                                                                                                       
|    32 | struct wl_egl_window;                                                                                                                                                                                      
|       |        ^~~~~~~~~~~~~ 
github-actions[bot] commented 1 year ago

This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 7 days.

github-actions[bot] commented 1 year ago

This issue was closed because it has been stale for 7 days with no activity.

aperezdc commented 1 year ago

I've hit this while trying to build with the Mali driver (sunxi-mali-utgard in Buildroot, patched to allow installing the Wayland variant). So I double-checked things again: this happens when GTK3 itself is built only with Wayland support but no X11; the fix in bug #178090 fixed a location where EGLNativeWindowType (a.k.a. struct wl_egl_window*) is cast to a 64-bit integer, but in GLContextEGL.cpp (or GLContext.cpp in newer WebKit versions) there is a cast for the opposite conversion which needs a similar treatment.

I have reported this upstream, and I will make a version of the patch that people can apply to the releases from the 2.38 branch. There is also one more issue with 2.38.x and drivers which are strictly OpenGL ES 2, without ES 3 features:

aperezdc commented 1 year ago

Combined patch for 2.38.x here: https://github.com/WebKit/WebKit/pull/13084

Patch for “main”, to be backported to 2.40.x after it lands, here: https://github.com/WebKit/WebKit/pull/13083

github-actions[bot] commented 1 year ago

This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 7 days.

github-actions[bot] commented 1 year ago

This issue was closed because it has been stale for 7 days with no activity.