Skip to content

libobs-opengl: Fix compile error on GCC 14+ and i686 #12057

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

oreo639
Copy link

@oreo639 oreo639 commented Apr 17, 2025

Description

Under the public gl_egl_query_dmabuf_modifiers_for_format, n_modifiers is defined as size_t, however in the static query_dmabuf_modifiers function, it is defined as EGLuint64KHR.

Since query_dmabuf_modifiers is only called by gl_egl_query_dmabuf_modifiers_for_format and n_modifiers is assigned from an EGLint, make it size_t for both.

This fixes building on i686 with gcc14.

Motivation and Context

On i686 with gcc14, the following compile error is outputted:

 [309/422] Building C object libobs-opengl/CMakeFiles/libobs-opengl.dir/gl-egl-common.c.o
FAILED: libobs-opengl/CMakeFiles/libobs-opengl.dir/gl-egl-common.c.o 
/usr/bin/cc -DENABLE_HEVC -DHAVE_OBSCONFIG_H -DSIMDE_ENABLE_OPENMP -Dlibobs_opengl_EXPORTS -I/builddir/obs-31.0.2/build/libobs-opengl -I/builddir/obs-31.0.2/libobs-opengl -I/builddir/obs-31.0.2/build/config -I/builddir/obs-31.0.2/libobs -I/builddir/obs-31.0.2/deps/glad/include -DNDEBUG -fstack-clash-protection -D_FORTIFY_SOURCE=2 -mtune=i686 -O2    -ffile-prefix-map=/builddir/obs-31.0.2/build=. -std=gnu17 -fPIC -fvisibility=hidden -fopenmp-simd -fno-strict-aliasing -Wdeprecated-declarations -Wempty-body -Wenum-conversion -Werror=return-type -Wextra -Wformat -Wformat-security -Wno-conversion -Wno-float-conversion -Wno-implicit-fallthrough -Wno-missing-braces -Wno-missing-field-initializers -Wno-shadow -Wno-sign-conversion -Wno-trigraphs -Wno-unknown-pragmas -Wno-unused-function -Wno-unused-label -Wparentheses -Wswitch -Wuninitialized -Wunreachable-code -Wunused-parameter -Wunused-value -Wunused-variable -Wvla -Wint-conversion -Wno-missing-prototypes -Wno-strict-prototypes -Wpointer-sign -Wno-error=maybe-uninitialized -Winfinite-recursion -Wno-stringop-overflow -MD -MT libobs-opengl/CMakeFiles/libobs-opengl.dir/gl-egl-common.c.o -MF libobs-opengl/CMakeFiles/libobs-opengl.dir/gl-egl-common.c.o.d -o libobs-opengl/CMakeFiles/libobs-opengl.dir/gl-egl-common.c.o -c /builddir/obs-31.0.2/libobs-opengl/gl-egl-common.c
/builddir/obs-31.0.2/libobs-opengl/gl-egl-common.c: In function 'gl_egl_query_dmabuf_modifiers_for_format':
/builddir/obs-31.0.2/libobs-opengl/gl-egl-common.c:387:73: error: passing argument 4 of 'query_dmabuf_modifiers' from incompatible pointer type [-Wincompatible-pointer-types]
  387 |         if (!query_dmabuf_modifiers(egl_display, drm_format, modifiers, n_modifiers)) {
      |                                                                         ^~~~~~~~~~~
      |                                                                         |
      |                                                                         size_t * {aka unsigned int *}
/builddir/obs-31.0.2/libobs-opengl/gl-egl-common.c:349:57: note: expected 'EGLuint64KHR *' {aka 'long long unsigned int *'} but argument is of type 'size_t *' {aka 'unsigned int *'}
  349 |                                           EGLuint64KHR *n_modifiers)
      |                                           ~~~~~~~~~~~~~~^~~~~~~~~~~

How Has This Been Tested?

This was compiled with gcc 14 and glibc 2.41 on Void Linux.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)

Checklist:

  • My code has been run through clang-format.
  • I have read the contributing document.
  • My code is not on the master branch.
  • The code has been tested.
  • All commit messages are properly formatted and commits squashed where appropriate.
  • I have included updates to all appropriate documentation.

@kkartaltepe
Copy link
Collaborator

nack on this solution.

If you want to maintain 32bit support consider converting to fixed size types at the api borders instead of introducing architecture dependent types here. Though I think someone else submitted this a while back and we didnt have any active contributors who cared about 32bit and preferred to leave dealing it to active 32bit communities like legacy distros instead.

@oreo639
Copy link
Author

oreo639 commented Apr 17, 2025

If you want to maintain 32bit support consider converting to fixed size types at the api borders

Makes sense.

@norihiro
Copy link
Contributor

Though I think someone else submitted this a while back

It was #11349, but #11349 has a buffer overrun in the 32-bit size_t type system.

Under the public gl_egl_query_dmabuf_modifiers_for_format, n_modifiers
is defined as size_t, however in the static query_dmabuf_modifiers
function, it is defined as EGLuint64KHR.

Assign from EGLint to size_t in gl_egl_query_dmabuf_modifiers_for_format.

This fixes building on i686 with gcc14.
@WizardCM WizardCM added the Bug Fix Non-breaking change which fixes an issue label Apr 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Fix Non-breaking change which fixes an issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants