From 97d56a33653ad1ed78a36c92f9509756f8940ea1 Mon Sep 17 00:00:00 2001 From: Randy Eckenrode Date: Wed, 24 Jul 2024 20:50:23 -0400 Subject: [PATCH] SDL_image: fix build with clang 16 Use the correct function pointer types to avoid incompatible function pointer type assignment errors with clang 16. Also disable `webp-shared` like the other image formats already do and add it as an explicit dependency. --- .../sd/SDL_image/clang16-webp-errors.patch | 16 ++++++++++++++++ pkgs/by-name/sd/SDL_image/package.nix | 13 ++++++++++--- 2 files changed, 26 insertions(+), 3 deletions(-) create mode 100644 pkgs/by-name/sd/SDL_image/clang16-webp-errors.patch diff --git a/pkgs/by-name/sd/SDL_image/clang16-webp-errors.patch b/pkgs/by-name/sd/SDL_image/clang16-webp-errors.patch new file mode 100644 index 000000000000..b696dcc9904c --- /dev/null +++ b/pkgs/by-name/sd/SDL_image/clang16-webp-errors.patch @@ -0,0 +1,16 @@ +diff -ur a/IMG_webp.c b/IMG_webp.c +--- a/IMG_webp.c 2012-01-20 20:51:33.000000000 -0500 ++++ b/IMG_webp.c 2024-07-24 20:48:58.697398200 -0400 +@@ -47,9 +47,9 @@ + static struct { + int loaded; + void *handle; +- int/*VP8StatuCode*/ (*webp_get_features_internal) (const uint8_t *data, uint32_t data_size, WebPBitstreamFeatures* const features, int decoder_abi_version); +- uint8_t* (*webp_decode_rgb_into) (const uint8_t* data, uint32_t data_size, uint8_t* output_buffer, int output_buffer_size, int output_stride); +- uint8_t* (*webp_decode_rgba_into) (const uint8_t* data, uint32_t data_size, uint8_t* output_buffer, int output_buffer_size, int output_stride); ++ VP8StatusCode (*webp_get_features_internal) (const uint8_t *data, size_t data_size, WebPBitstreamFeatures* const features, int decoder_abi_version); ++ uint8_t* (*webp_decode_rgb_into) (const uint8_t* data, size_t data_size, uint8_t* output_buffer, size_t output_buffer_size, int output_stride); ++ uint8_t* (*webp_decode_rgba_into) (const uint8_t* data, size_t data_size, uint8_t* output_buffer, size_t output_buffer_size, int output_stride); + } lib; + + #ifdef LOAD_WEBP_DYNAMIC diff --git a/pkgs/by-name/sd/SDL_image/package.nix b/pkgs/by-name/sd/SDL_image/package.nix index c49e195f970f..ce6824b09d0b 100644 --- a/pkgs/by-name/sd/SDL_image/package.nix +++ b/pkgs/by-name/sd/SDL_image/package.nix @@ -8,6 +8,7 @@ libjpeg, libpng, libtiff, + libwebp, pkg-config, stdenv, }: @@ -29,6 +30,8 @@ stdenv.mkDerivation (finalAttrs: { includes = [ "IMG_xcf.c" ]; hash = "sha256-Z0nyEtE1LNGsGsN9SFG8ZyPDdunmvg81tUnEkrJQk5w="; }) + # Fixes incompatible function pointer type errors with clang 16 + ./clang16-webp-errors.patch ]; configureFlags = [ @@ -37,6 +40,7 @@ stdenv.mkDerivation (finalAttrs: { (lib.enableFeature false "jpg-shared") (lib.enableFeature false "png-shared") (lib.enableFeature false "tif-shared") + (lib.enableFeature false "webp-shared") (lib.enableFeature (!stdenv.isDarwin) "sdltest") ]; @@ -52,9 +56,13 @@ stdenv.mkDerivation (finalAttrs: { libjpeg libpng libtiff + libwebp ]; - outputs = [ "out" "dev" ]; + outputs = [ + "out" + "dev" + ]; strictDeps = true; @@ -62,8 +70,7 @@ stdenv.mkDerivation (finalAttrs: { homepage = "http://www.libsdl.org/projects/SDL_image/"; description = "SDL image library"; license = lib.licenses.zlib; - maintainers = lib.teams.sdl.members - ++ (with lib.maintainers; [ ]); + maintainers = lib.teams.sdl.members ++ (with lib.maintainers; [ ]); inherit (SDL.meta) platforms; }; })