From 14477808c771f5a817d209f1d4c543e88e59c760 Mon Sep 17 00:00:00 2001 From: whispers Date: Sun, 5 Jul 2026 23:18:27 -0400 Subject: [PATCH] pegtl: apply upstream workaround for gcc 16 bug gcc 16.1.0 resurfaced a bug from gcc 9.1/9.2 where `__PRETTY_FUNCTION__` could end up truncated, which breaks the build of pegtl. upstream pegtl has re-enabled the workaround from gcc 9.1/9.2 for gcc 16, and while we can't fetch that as a patch since the codebase has changed substantially since v3.2.8, we apply approximately the same trick. see: - https://github.com/taocpp/PEGTL/issues/382 - https://github.com/taocpp/PEGTL/commit/0176e87da3a02d0ab40ce39f03e0e4108d1bbba5 - https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91155 --- pkgs/by-name/pe/pegtl/package.nix | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/pkgs/by-name/pe/pegtl/package.nix b/pkgs/by-name/pe/pegtl/package.nix index 28052ee7513b..545dc76681b8 100644 --- a/pkgs/by-name/pe/pegtl/package.nix +++ b/pkgs/by-name/pe/pegtl/package.nix @@ -18,6 +18,20 @@ stdenv.mkDerivation (finalAttrs: { hash = "sha256-nPWSO2wPl/qenUQgvQDQu7Oy1dKa/PnNFSclmkaoM8A="; }; + # GCC 16.1.0 has a bug with `__PRETTY_FUNCTION__` that leads to static + # assertions in PEGTL failing. Upstream has enabled a workaround for GCC 16 + # specifically instead, and the bug was fixed for GCC 17+. The upstream patch + # does not apply cleanly since the codebase has changed substantially since + # v3.2.8, but it's trivial to apply a similar trick on our own. + # https://github.com/taocpp/PEGTL/issues/382 + # https://github.com/taocpp/PEGTL/commit/0176e87da3a02d0ab40ce39f03e0e4108d1bbba5 + # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91155 + postPatch = '' + substituteInPlace include/tao/pegtl/demangle.hpp --replace-fail \ + "#elif( __GNUC__ == 9 ) && ( __GNUC_MINOR__ < 3 )" \ + "#elif ( ( __GNUC__ == 9 ) && ( __GNUC_MINOR__ < 3 ) ) || ( __GNUC__ == 16 )" + ''; + nativeBuildInputs = [ cmake ninja