community
community copied to clipboard
Fails to build with clang 17 and GCC 14 due to -Wincompatible-pointer-types
When building 2.3.0 with clang, the following error occurs:
/mnt/b/yoe/master/build/tmp/work/core2-64-yoe-linux-musl/python3-kivy/2.3.0/git/kivy/graphics/cgl_backend/cgl_gl.c:4549:52: error: incompatible function pointer types assigning to 'void (*)(GLuint, GLsizei, const GLchar **, const GLint *)' (aka 'void (*)(unsigned int, int, const char **, const int *)') from 'void (GLuint, GLsizei, const GLchar *const *, const GLint *)' (aka 'void (unsigned int, int, const char *const *, const int *)') [-Wincompatible-function-pointer-types]
4549 | __pyx_v_4kivy_8graphics_3cgl_cgl->glShaderSource = glShaderSource;
| ^ ~~~~~~~~~~~~~~
Full build log: https://sprunge.us/lq5PKS
Hi @kanavin ,
This one could be related: https://github.com/kivy/kivy/pull/8415
Can you please confirm your clang version?
Hi @kanavin ,
This one could be related: #8415
Can you please confirm your clang version?
@kraj I think this was this with 17.x?
Hi @kanavin , This one could be related: #8415 Can you please confirm your clang version?
@kraj I think this was this with 17.x?
yes, 17.0.6 to be precise
As pointed out by @glaubitz in #8746 , the same issue is happening on GCC 14. (Issue title updated)
I just tried to have a go at this and tried the following change:
diff -Nru kivy-2.3.0.orig/kivy/core/window/_window_sdl2.pyx kivy-2.3.0/kivy/core/window/_window_sdl2.pyx
--- kivy-2.3.0.orig/kivy/core/window/_window_sdl2.pyx 2024-01-05 10:40:12.000000000 +0100
+++ kivy-2.3.0/kivy/core/window/_window_sdl2.pyx 2024-06-11 09:59:18.605347161 +0200
@@ -263,7 +263,7 @@
for joy_i in range(SDL_NumJoysticks()):
SDL_JoystickOpen(joy_i)
- SDL_SetEventFilter(<SDL_EventFilter *>_event_filter, <void *>self)
+ SDL_SetEventFilter(<SDL_EventFilter>_event_filter, <void *>self)
SDL_EventState(SDL_DROPFILE, SDL_ENABLE)
SDL_EventState(SDL_DROPTEXT, SDL_ENABLE)
But that doesn't work, but I am also not very familiar with Cython. Could someone with Cython expertise please have a look at this?
The kivy package is otherwise on the risk of being removed from distributions if it doesn't build with GCC 14.
Any news on this?
I think the fix in #8415 is/was incorrect. The author points to the GL4 documentation, which indeed shows the function definition,
void glShaderSource(
GLuint shader,
GLsizei count,
const GLchar **string,
const GLint *length
);
However, the kivy source file comment links to the ES2 documentation which has function definition,
void glShaderSource(
GLuint shader,
GLsizei count,
const GLchar * const *string,
const GLint *length
);
Since kivy seems to include GLES2/gl2.h, I believe that (part of) the correct
response for the current issue is to revert a0ec8ff79fcbc1b82391132a89c8fc21ef1c5c55.
In the Debian build, this fixes the -Wincompatible-pointer-types error in
4562 | __pyx_v_4kivy_8graphics_3cgl_cgl->glShaderSource = glShaderSource;
This leaves
# kivy/core/window/_window_sdl2.pyx line 266
SDL_SetEventFilter(<SDL_EventFilter *>_event_filter, <void *>self)
Which produces error,
8756 | SDL_SetEventFilter(((SDL_EventFilter *)(&__pyx_f_4kivy_4core_6window_12_window_sdl2__event_filter)), ((void *)__pyx_v_self));
| ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| |
| int (**)(void *, SDL_Event *)
In file included from /usr/include/SDL2/SDL.h:41,
from /build/kivy-2.3.0/kivy/core/window/_window_sdl2.c:1302:
/usr/include/SDL2/SDL_events.h:1017:65: note: expected 'SDL_EventFilter' {aka 'int (*)(void *, SDL_Event *)'} but argument is of type 'int (**)(void *, SDL_Event *)'
1017 | extern DECLSPEC void SDLCALL SDL_SetEventFilter(SDL_EventFilter filter,
| ~~~~~~~~~~~~~~~~^~~~~~
Which I'm not sure how to fix.
Additional testing may be needed to determine whether #8415 can be replicated.
Sorry, I missed that kivy can compile using either GLES or GL, so it appears as though the glShaderSource definitions need to conditionally choose between const GLchar** and const GLchar* const* depending on the __USE_OPENGL_ES2 flag.