From 72b09cfd897204c43d3e0fdb2d948e1c75574ccb Mon Sep 17 00:00:00 2001 From: Sergei Trofimovich Date: Sat, 29 Jun 2024 16:52:47 +0100 Subject: [PATCH] libliftoff_0_4: backport gcc-14 build fix Without the change `gcc-14` build fails as: $ nix build --impure --expr 'with import ./. {}; libliftoff_0_4.override { stdenv = gcc14Stdenv; }' ... libliftoff> ../layer.c: In function 'liftoff_layer_create': libliftoff> ../layer.c:20:48: error: 'calloc' sizes specified with 'sizeof' in the earlier argument and not in the later argument [-Werror=calloc-transposed-args] libliftoff> 20 | layer->candidate_planes = calloc(sizeof(layer->candidate_planes[0]), libliftoff> | ^ --- .../libraries/libliftoff/default.nix | 33 ++++++++++++++++--- .../libraries/libliftoff/generic.nix | 3 +- 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/pkgs/development/libraries/libliftoff/default.nix b/pkgs/development/libraries/libliftoff/default.nix index 8d695b2b9afd..87a2458bdc8c 100644 --- a/pkgs/development/libraries/libliftoff/default.nix +++ b/pkgs/development/libraries/libliftoff/default.nix @@ -1,9 +1,17 @@ -{ callPackage, fetchFromGitLab, ... }: +{ + callPackage, + fetchFromGitLab, + fetchpatch, +}: let mkVariant = - version: hash: + { + version, + hash, + patches ? [ ], + }: callPackage ./generic.nix { - inherit version; + inherit version patches; src = fetchFromGitLab { domain = "gitlab.freedesktop.org"; owner = "emersion"; @@ -14,6 +22,21 @@ let }; in { - libliftoff_0_4 = mkVariant "0.4.1" "sha256-NPwhsd6IOQ0XxNQQNdaaM4kmwoLftokV86WYhoa5csY="; - libliftoff_0_5 = mkVariant "0.5.0" "sha256-PcQY8OXPqfn8C30+GAYh0Z916ba5pik8U0fVpZtFb5g="; + libliftoff_0_4 = mkVariant { + version = "0.4.1"; + hash = "sha256-NPwhsd6IOQ0XxNQQNdaaM4kmwoLftokV86WYhoa5csY="; + patches = [ + # Pull gcc-14 fix: + # https://gitlab.freedesktop.org/emersion/libliftoff/-/merge_requests/78 + (fetchpatch { + name = "libliftoff-gcc-14-calloc.patch"; + url = "https://gitlab.freedesktop.org/emersion/libliftoff/-/commit/29a06add8ef184f85e37ff8abdc34fbaa2f4ee1e.patch"; + hash = "sha256-Y8x1RK3o/I9bs/ZOLeC4t9AIK78l0QnlBWHhiVC+sz8="; + }) + ]; + }; + libliftoff_0_5 = mkVariant { + version = "0.5.0"; + hash = "sha256-PcQY8OXPqfn8C30+GAYh0Z916ba5pik8U0fVpZtFb5g="; + }; } diff --git a/pkgs/development/libraries/libliftoff/generic.nix b/pkgs/development/libraries/libliftoff/generic.nix index 0f347a6a9b00..5e846cd6eb2b 100644 --- a/pkgs/development/libraries/libliftoff/generic.nix +++ b/pkgs/development/libraries/libliftoff/generic.nix @@ -3,11 +3,12 @@ , libdrm , version , src +, patches }: stdenv.mkDerivation (finalAttrs: { pname = "libliftoff"; - inherit version src; + inherit version src patches; nativeBuildInputs = [ meson pkg-config ninja ];