[Webkit-unassigned] [Bug 223684] New: [WPE] Build error in ARMv7 invalid 'static_cast' for GLNativeWindowType
bugzilla-daemon at webkit.org
bugzilla-daemon at webkit.org
Wed Mar 24 02:43:16 PDT 2021
https://bugs.webkit.org/show_bug.cgi?id=223684
Bug ID: 223684
Summary: [WPE] Build error in ARMv7 invalid 'static_cast' for
GLNativeWindowType
Product: WebKit
Version: WebKit Nightly Build
Hardware: Unspecified
OS: Unspecified
Status: NEW
Severity: Normal
Priority: P2
Component: WPE WebKit
Assignee: webkit-unassigned at lists.webkit.org
Reporter: psaavedra at igalia.com
CC: bugs-noreply at webkitgtk.org
I'm getting the a similar issue building wpewebkit (main) for ARMv7 than the one reported in https://bugs.webkit.org/show_bug.cgi?id=223577#c2:
```
/home/bot/yocto-rpi3-manual/builds/raspberrypi3-mesa-wpe-nightly/tmp/work/cortexa7t2hf-neon-vfpv4-poky-linux-gnueabi/wpewebkit/trunk+gitAUTOINC+e90a458604-r0/git/Source/WebKit/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp:93:23: error: invalid 'static_cast' from type 'uintptr_t' {aka 'unsigned int'} to type 'GLNativeWindowType' {aka 'void*'}
```
GLNativeWindowType is defined in Source/WebCore/platform/graphics/GLContext.h like this:
```
#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
```
>From https://bug-178090-attachments.webkit.org/attachment.cgi?id=323356:
+ EGLNativeWindowType can be aliased to a different type depending (at least) on the EGL
+ implementation, its build options, and the libepoxy build options. Using "static_cast"
+ works when it is a numeric value and the width of the value needs to be optionally
+ extended to 64 bits (e.g. the EGL type is "int" in a 32-bit CPU) but not for pointers,
+ and using "reinterpret_cast" works when the size of a pointer is 64 bits but not in other
+ cases. Therefore it seems reasonable to use a plain C cast expression to solve this
+ particular situation.
...
+ // EGLNativeWindowType changes depending on the EGL implementation: reinterpret_cast works
+ // 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. Using
+ // a plain C cast expression in this one instance works in all cases.
+ static_assert(sizeof(EGLNativeWindowType) <= sizeof(uint64_t), "EGLNativeWindowType must not be longer than 64 bits.");
+ return (uint64_t) wpe_renderer_backend_egl_target_get_native_window(m_backend);
The build has not problems by replicating the solution from 178090:
```
diff --git a/Source/WebKit/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp b/Source/WebKit/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp
index f56cb9ce80f9..92d2f8476355 100644
--- a/Source/WebKit/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp
+++ b/Source/WebKit/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp
@@ -90,7 +90,8 @@ void ThreadedCompositor::createGLContext()
auto windowType = reinterpret_cast<GLNativeWindowType>(m_nativeSurfaceHandle);
#else
// On 32-bit platforms GLNativeWindowType is an integer type, which cannot be casted with reinterpret_cast.
- auto windowType = static_cast<GLNativeWindowType>(m_nativeSurfaceHandle);
+ static_assert(sizeof(GLNativeWindowType) <= sizeof(uint64_t), "GLNativeWindowType must not be longer than 64 bits.");
+ auto windowType = (GLNativeWindowType) m_nativeSurfaceHandle;
#endif
m_context = GLContext::createContextForWindow(windowType, &PlatformDisplay::sharedDisplayForCompositing());
if (m_context)
```
--
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20210324/3cdbd2cb/attachment.htm>
More information about the webkit-unassigned
mailing list