diff mbox series

[v4,04/18] ui: avoid warnings about directdb on Alpine / musl libc

Message ID 20211124130150.268230-5-berrange@redhat.com
State New
Headers show
Series tests/docker: start using libvirt-ci's "lcitool" for dockerfiles | expand

Commit Message

Daniel P. Berrangé Nov. 24, 2021, 1:01 p.m. UTC
On Alpine, SDL is built with directfb support and this triggers warnings
during QEMU build

In file included from /usr/include/directfb/direct/thread.h:38,
                 from /usr/include/directfb/direct/debug.h:43,
                 from /usr/include/directfb/direct/interface.h:36,
                 from /usr/include/directfb/directfb.h:49,
                 from /usr/include/SDL2/SDL_syswm.h:80,
                 from /builds/berrange/qemu/include/ui/sdl2.h:8,
                 from ../ui/sdl2-gl.c:31:
/usr/include/directfb/direct/os/waitqueue.h:41:25: error: redundant redeclaration of 'direct_waitqueue_init' [-Werror=redundant-decls]
   41 | DirectResult DIRECT_API direct_waitqueue_init        ( DirectWaitQueue *queue );
      |                         ^~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
---
 include/ui/sdl2.h | 11 +++++++++++
 1 file changed, 11 insertions(+)

Comments

Thomas Huth Nov. 24, 2021, 1:32 p.m. UTC | #1
On 24/11/2021 14.01, Daniel P. Berrangé wrote:
> On Alpine, SDL is built with directfb support and this triggers warnings
> during QEMU build
> 
> In file included from /usr/include/directfb/direct/thread.h:38,
>                   from /usr/include/directfb/direct/debug.h:43,
>                   from /usr/include/directfb/direct/interface.h:36,
>                   from /usr/include/directfb/directfb.h:49,
>                   from /usr/include/SDL2/SDL_syswm.h:80,
>                   from /builds/berrange/qemu/include/ui/sdl2.h:8,
>                   from ../ui/sdl2-gl.c:31:
> /usr/include/directfb/direct/os/waitqueue.h:41:25: error: redundant redeclaration of 'direct_waitqueue_init' [-Werror=redundant-decls]
>     41 | DirectResult DIRECT_API direct_waitqueue_init        ( DirectWaitQueue *queue );
>        |                         ^~~~~~~~~~~~~~~~~~~~~

I think that's a bug in the SDL2 package of Alpine. I've had trouble with 
that one in the past already ... so not sure whether it's our job now to 
work around bugs in that crappy Alpine package... I'd prefer if we simply do 
not compile-test SDL on Alpine instead.

  Thomas
Daniel P. Berrangé Nov. 24, 2021, 1:42 p.m. UTC | #2
On Wed, Nov 24, 2021 at 02:32:56PM +0100, Thomas Huth wrote:
> On 24/11/2021 14.01, Daniel P. Berrangé wrote:
> > On Alpine, SDL is built with directfb support and this triggers warnings
> > during QEMU build
> > 
> > In file included from /usr/include/directfb/direct/thread.h:38,
> >                   from /usr/include/directfb/direct/debug.h:43,
> >                   from /usr/include/directfb/direct/interface.h:36,
> >                   from /usr/include/directfb/directfb.h:49,
> >                   from /usr/include/SDL2/SDL_syswm.h:80,
> >                   from /builds/berrange/qemu/include/ui/sdl2.h:8,
> >                   from ../ui/sdl2-gl.c:31:
> > /usr/include/directfb/direct/os/waitqueue.h:41:25: error: redundant redeclaration of 'direct_waitqueue_init' [-Werror=redundant-decls]
> >     41 | DirectResult DIRECT_API direct_waitqueue_init        ( DirectWaitQueue *queue );
> >        |                         ^~~~~~~~~~~~~~~~~~~~~
> 
> I think that's a bug in the SDL2 package of Alpine. I've had trouble with
> that one in the past already ... so not sure whether it's our job now to
> work around bugs in that crappy Alpine package... I'd prefer if we simply do
> not compile-test SDL on Alpine instead.

It is a harmless bug in directfb headers, which has no ill
effects other than producing a warning when some app uses
-Wredundant-decls.  Of course Alpine would ideally get this
patched, but at the same time it is reasonable for Alpine
users to want SDL and if someone has this package installed
already we don't want QEMU build to break due to -Werror.

Case in point, as we auto-generate dockerfiles to ensure
all pre-requisites are installed in all dockerfiles,  the
Alpine dockerfile gains SDL and exposes this bug. We could
turn off -Werror but that's a overly big hammer compared
to this targetted fix.

Regards,
Daniel
Philippe Mathieu-Daudé Dec. 15, 2021, 11:59 a.m. UTC | #3
On 11/24/21 14:42, Daniel P. Berrangé wrote:
> On Wed, Nov 24, 2021 at 02:32:56PM +0100, Thomas Huth wrote:
>> On 24/11/2021 14.01, Daniel P. Berrangé wrote:
>>> On Alpine, SDL is built with directfb support and this triggers warnings
>>> during QEMU build
>>>
>>> In file included from /usr/include/directfb/direct/thread.h:38,
>>>                   from /usr/include/directfb/direct/debug.h:43,
>>>                   from /usr/include/directfb/direct/interface.h:36,
>>>                   from /usr/include/directfb/directfb.h:49,
>>>                   from /usr/include/SDL2/SDL_syswm.h:80,
>>>                   from /builds/berrange/qemu/include/ui/sdl2.h:8,
>>>                   from ../ui/sdl2-gl.c:31:
>>> /usr/include/directfb/direct/os/waitqueue.h:41:25: error: redundant redeclaration of 'direct_waitqueue_init' [-Werror=redundant-decls]
>>>     41 | DirectResult DIRECT_API direct_waitqueue_init        ( DirectWaitQueue *queue );
>>>        |                         ^~~~~~~~~~~~~~~~~~~~~
>>
>> I think that's a bug in the SDL2 package of Alpine. I've had trouble with
>> that one in the past already ... so not sure whether it's our job now to
>> work around bugs in that crappy Alpine package... I'd prefer if we simply do
>> not compile-test SDL on Alpine instead.
> 
> It is a harmless bug in directfb headers, which has no ill
> effects other than producing a warning when some app uses
> -Wredundant-decls.  Of course Alpine would ideally get this
> patched, but at the same time it is reasonable for Alpine
> users to want SDL and if someone has this package installed
> already we don't want QEMU build to break due to -Werror.

We should avoid adding #pragma directives in generic header,
but I agree -Wredundant-decls is harmless here, so:

Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>

> Case in point, as we auto-generate dockerfiles to ensure
> all pre-requisites are installed in all dockerfiles,  the
> Alpine dockerfile gains SDL and exposes this bug. We could
> turn off -Werror but that's a overly big hammer compared
> to this targetted fix.
> 
> Regards,
> Daniel
>
diff mbox series

Patch

diff --git a/include/ui/sdl2.h b/include/ui/sdl2.h
index f85c117a78..0330978df8 100644
--- a/include/ui/sdl2.h
+++ b/include/ui/sdl2.h
@@ -5,7 +5,18 @@ 
 #undef WIN32_LEAN_AND_MEAN
 
 #include <SDL.h>
+
+/* with Alpine / muslc SDL headers pull in directfb headers
+ * which in turn trigger warning about redundant decls for
+ * direct_waitqueue_deinit.
+ */
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wredundant-decls"
+
 #include <SDL_syswm.h>
+
+#pragma GCC diagnostic pop
+
 #ifdef CONFIG_SDL_IMAGE
 # include <SDL_image.h>
 #endif