Bug 271520

Summary: graphics/sdl_image: fix build with clang 16
Product: Ports & Packages Reporter: Dimitry Andric <dim>
Component: Individual Port(s)Assignee: Dmitry Marakasov <amdmi3>
Status: Closed FIXED    
Severity: Affects Some People Flags: bugzilla: maintainer-feedback? (amdmi3)
Priority: ---    
Version: Latest   
Hardware: Any   
OS: Any   
Bug Depends on:    
Bug Blocks: 271047    
Attachments:
Description Flags
graphics/sdl_image: fix build with clang 16 none

Description Dimitry Andric freebsd_committer freebsd_triage 2023-05-19 20:16:14 UTC
Clang 16 has a new error about incompatible function types, which shows
up when building graphics/sdl_image:

  IMG_png.c:266:30: error: incompatible function pointer types assigning to 'png_infop (*)(png_structp)' (aka 'struct png_info_def *(*)(struct png_struct_def *)') from 'png_infop (png_const_structrp)' (aka 'struct png_info_def *(const struct png_struct_def *restrict)') [-Wincompatible-function-pointer-types]
                  lib.png_create_info_struct = png_create_info_struct;
                                             ^ ~~~~~~~~~~~~~~~~~~~~~~
  IMG_png.c:269:20: error: incompatible function pointer types assigning to 'png_uint_32 (*)(png_structp, png_infop, png_uint_32 *, png_uint_32 *, int *, int *, int *, int *, int *)' (aka 'unsigned int (*)(struct png_struct_def *, struct png_info_def *, unsigned int *, unsigned int *, int *, int *, int *, int *, int *)') from 'png_uint_32 (png_const_structrp, png_const_inforp, png_uint_32 *, png_uint_32 *, int *, int *, int *, int *, int *)' (aka 'unsigned int (const struct png_struct_def *restrict, const struct png_info_def *restrict, unsigned int *, unsigned int *, int *, int *, int *, int *, int *)') [-Wincompatible-function-pointer-types]
                  lib.png_get_IHDR = png_get_IHDR;
                                   ^ ~~~~~~~~~~~~

Similar errors occur for IMG_webp.c. I backported a few changes from
SDL_image 2 that fix the prototypes to be compatible with the versions
of graphics/png and and graphics/webp.
Comment 1 Dimitry Andric freebsd_committer freebsd_triage 2023-05-19 20:16:35 UTC
Created attachment 242287 [details]
graphics/sdl_image: fix build with clang 16
Comment 2 Dmitry Marakasov freebsd_committer freebsd_triage 2023-05-24 14:36:32 UTC
Thanks! I've used simpler IMG_png patch, we don't need to check for older png versions.
Comment 3 commit-hook freebsd_committer freebsd_triage 2023-05-24 14:36:42 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=9b762306ec7d96352d13eb62f42697c2ad65a23f

commit 9b762306ec7d96352d13eb62f42697c2ad65a23f
Author:     Dmitry Marakasov <amdmi3@FreeBSD.org>
AuthorDate: 2023-05-24 14:32:38 +0000
Commit:     Dmitry Marakasov <amdmi3@FreeBSD.org>
CommitDate: 2023-05-24 14:33:49 +0000

    graphics/sdl_image: fix build with clang 16

    Use correct png and webp function prototypes

    PR:             271520
    Submitted by:   dim

 graphics/sdl_image/files/patch-IMG__png.c (new)  | 55 ++++++++++++++++++++++++
 graphics/sdl_image/files/patch-IMG__webp.c (new) | 15 +++++++
 2 files changed, 70 insertions(+)