gdk-pixbuf: fix static

We're unfortunately going to have to patch here, because an equivalent
of static-deps.patch has been submitted upstream at least 3 times at
this point, but these merge requests have all been ignored for more
than a year. I have submitted static-lerc.patch upstream as well, but
I'm not holding out hope…

Alyssa Ross 9b93ca3c 74679747

+123 -6
+13 -6
pkgs/development/libraries/gdk-pixbuf/default.nix
··· 51 51 patches = [ 52 52 # Move installed tests to a separate output 53 53 ./installed-tests-path.patch 54 + 55 + ./static-deps.patch 56 + ./static-lerc.patch 54 57 ]; 55 58 56 59 # gdk-pixbuf-thumbnailer is not wrapped therefore strictDeps will work ··· 88 91 libpng 89 92 ]; 90 93 91 - mesonFlags = [ 92 - "-Dgio_sniffing=false" 93 - (lib.mesonBool "gtk_doc" withIntrospection) 94 - (lib.mesonEnable "introspection" withIntrospection) 95 - (lib.mesonEnable "others" true) 96 - ]; 94 + mesonFlags = 95 + [ 96 + "-Dgio_sniffing=false" 97 + (lib.mesonBool "gtk_doc" withIntrospection) 98 + (lib.mesonEnable "introspection" withIntrospection) 99 + (lib.mesonEnable "others" true) 100 + ] 101 + ++ lib.optionals stdenv.hostPlatform.isStatic [ 102 + "-Dbuiltin_loaders=all" 103 + ]; 97 104 98 105 postPatch = '' 99 106 chmod +x build-aux/* # patchShebangs only applies to executables
+31
pkgs/development/libraries/gdk-pixbuf/static-deps.patch
··· 1 + From 1b7cac1cbdb7078f575a3222be451a9bf1ac35ec Mon Sep 17 00:00:00 2001 2 + From: Alyssa Ross <hi@alyssa.is> 3 + Date: Wed, 31 Jan 2024 15:33:02 +0100 4 + Subject: [PATCH] build: add missing dependency to gdkpixbuf_dep 5 + 6 + This should match the dependencies passed to the library() call that 7 + creates gdkpixbuf. Otherwise, linking the gdkpixbuf_bin executables 8 + will fail if -Ddefault_library=static, because static libraries don't 9 + carry dependency information themselves. 10 + --- 11 + Link: https://gitlab.gnome.org/GNOME/gdk-pixbuf/-/merge_requests/161 12 + 13 + gdk-pixbuf/meson.build | 2 +- 14 + 1 file changed, 1 insertion(+), 1 deletion(-) 15 + 16 + diff --git a/gdk-pixbuf/meson.build b/gdk-pixbuf/meson.build 17 + index a11926eee..450484d68 100644 18 + --- a/gdk-pixbuf/meson.build 19 + +++ b/gdk-pixbuf/meson.build 20 + @@ -269,7 +269,7 @@ endif 21 + gdkpixbuf_dep = declare_dependency( 22 + link_with: gdkpixbuf, 23 + include_directories: root_inc, 24 + - dependencies: gdk_pixbuf_deps, 25 + + dependencies: [ gdk_pixbuf_deps, included_loaders_deps ], 26 + sources: [ gdkpixbuf_enum_h, built_girs ], 27 + ) 28 + meson.override_dependency('gdk-pixbuf-2.0', gdkpixbuf_dep) 29 + -- 30 + GitLab 31 +
+79
pkgs/development/libraries/gdk-pixbuf/static-lerc.patch
··· 1 + From 3bca69d889fe545dda4ed9a8fab8ff3fe38ba487 Mon Sep 17 00:00:00 2001 2 + From: Alyssa Ross <hi@alyssa.is> 3 + Date: Wed, 5 Feb 2025 19:37:27 +0100 4 + Subject: [PATCH] build: fix linking with libtiff with lerc support 5 + 6 + Lerc is written in C++. When C and C++ objects are linked, a C++ 7 + linker should be used to ensure C++-specific things are correctly 8 + handled. See e.g. this comment in the Meson source for reference[1]. 9 + One symptom of using a C linker to link with C++ objects is that 10 + libstdc++ won't be linked when building static executables, causing 11 + link failures. 12 + 13 + Unfortunately, Meson does not know whether dependencies found by 14 + pkg-config are C++, and therefore require a C++ linker, so we have to 15 + tell it ourselves to use a C++ linker. There's no way to check 16 + whether libtiff is built with Lerc support, so we always use a C++ 17 + linker if one is available and libtiff support is enabled. If a C++ 18 + linker ends up being used to link only C objects, it shouldn't do any 19 + harm. 20 + 21 + [1]: https://github.com/mesonbuild/meson/blob/9fd5281befe7881c9d1210c9e6865382bc0f2b08/mesonbuild/build.py#L1558-L1565 22 + --- 23 + Link: https://gitlab.gnome.org/GNOME/gdk-pixbuf/-/merge_requests/181 24 + 25 + gdk-pixbuf/meson.build | 6 ++++++ 26 + meson.build | 6 ++++++ 27 + 2 files changed, 12 insertions(+) 28 + 29 + diff --git a/gdk-pixbuf/meson.build b/gdk-pixbuf/meson.build 30 + index 570625bfe..5cc11355f 100644 31 + --- a/gdk-pixbuf/meson.build 32 + +++ b/gdk-pixbuf/meson.build 33 + @@ -333,6 +333,11 @@ gdkpixbuf_bin = [ 34 + [ 'gdk-pixbuf-query-loaders', [ 'queryloaders.c' ] ], 35 + ] 36 + 37 + +bin_link_language = 'c' 38 + +if loaders_cpp 39 + + bin_link_language = 'cpp' 40 + +endif 41 + + 42 + foreach bin: gdkpixbuf_bin 43 + bin_name = bin[0] 44 + bin_source = bin.get(1, bin_name + '.c') 45 + @@ -342,6 +347,7 @@ foreach bin: gdkpixbuf_bin 46 + dependencies: gdk_pixbuf_deps + [ gdkpixbuf_dep ], 47 + include_directories: [ root_inc, gdk_pixbuf_inc ], 48 + c_args: common_cflags + gdk_pixbuf_cflags, 49 + + link_language : bin_link_language, 50 + install: true) 51 + meson.override_find_program(bin_name, bin) 52 + 53 + diff --git a/meson.build b/meson.build 54 + index f0d4812f4..31b3197fc 100644 55 + --- a/meson.build 56 + +++ b/meson.build 57 + @@ -345,6 +345,8 @@ endif 58 + 59 + # Don't check and build the tiff loader if native_windows_loaders is true 60 + tiff_opt = get_option('tiff') 61 + +tiff_dep = dependency('', required: false) 62 + +loaders_cpp = false 63 + if not tiff_opt.disabled() and not native_windows_loaders 64 + # We currently don't have a fallback subproject, but this handles error 65 + # reporting if tiff_opt is enabled. 66 + @@ -353,6 +355,10 @@ if not tiff_opt.disabled() and not native_windows_loaders 67 + if tiff_dep.found() 68 + enabled_loaders += 'tiff' 69 + loaders_deps += tiff_dep 70 + + 71 + + # If libtiff is built with LERC support, it should be linked with 72 + + # a C++ linker. 73 + + loaders_cpp = loaders_cpp or add_languages('cpp', required: false, native: false) 74 + endif 75 + endif 76 + 77 + -- 78 + GitLab 79 +