From c63233b8de560c09307dee5f5309ebf033386562 Mon Sep 17 00:00:00 2001 From: Reno Dakota Date: Mon, 6 Jan 2025 10:13:20 -0800 Subject: [PATCH] pbzip2: fix clang-19 build https://libcxx.llvm.org/ReleaseNotes/19.html#deprecations-and-removals > The base template for std::char_traits has been removed in LLVM 19. If you are using std::char_traits with types other than char, wchar_t, char8_t, char16_t, char32_t or a custom character type for which you specialized std::char_traits, your code will stop working. The Standard does not mandate that a base template is provided, and such a base template is bound to be incorrect for some types, which could currently cause unexpected behavior while going undetected. https://bugs.launchpad.net/pbzip2/+bug/2081588 --- pkgs/by-name/pb/pbzip2/package.nix | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/pkgs/by-name/pb/pbzip2/package.nix b/pkgs/by-name/pb/pbzip2/package.nix index 3348f0b85ee3..b1c3ca022fe1 100644 --- a/pkgs/by-name/pb/pbzip2/package.nix +++ b/pkgs/by-name/pb/pbzip2/package.nix @@ -2,6 +2,7 @@ lib, stdenv, fetchurl, + fetchpatch, bzip2, }: @@ -18,14 +19,30 @@ stdenv.mkDerivation rec { sha256 = "1rnvgcdixjzbrmcr1nv9b6ccrjfrhryaj7jwz28yxxv6lam3xlcg"; }; + patches = [ + # https://libcxx.llvm.org/ReleaseNotes/19.html#deprecations-and-removals + # https://bugs.launchpad.net/pbzip2/+bug/2081588 + (fetchpatch { + url = "https://github.com/freebsd/freebsd-ports/raw/974d3ff054965d2bd2ab884a0579ed06c5a08b07/archivers/pbzip2/files/patch-BZ2StreamScanner.cpp"; + extraPrefix = ""; + hash = "sha256-dvXdp+5S41akavy+mvPGHpUxHxenXS7bbTVBVkIJj0s="; + }) + (fetchpatch { + url = "https://github.com/freebsd/freebsd-ports/raw/974d3ff054965d2bd2ab884a0579ed06c5a08b07/archivers/pbzip2/files/patch-BZ2StreamScanner.h"; + extraPrefix = ""; + hash = "sha256-/twP8HyHP4cAVgb5cUPq0CgDxUgDYPdd9haH9wDOrz8="; + }) + ]; + + postPatch = '' + substituteInPlace pbzip2.cpp \ + --replace-fail '"PRIuMAX"' '" PRIuMAX "' + ''; + buildInputs = [ bzip2 ]; - preBuild = "substituteInPlace Makefile --replace g++ c++"; - installFlags = [ "PREFIX=$(out)" ]; - env.NIX_CFLAGS_COMPILE = lib.optionalString stdenv.cc.isClang "-Wno-error=reserved-user-defined-literal"; - meta = with lib; { homepage = "http://compression.ca/pbzip2/"; description = "Parallel implementation of bzip2 for multi-core machines";