diff --git a/pkgs/development/libraries/protobuf/generic.nix b/pkgs/development/libraries/protobuf/generic.nix index 91e6bc878b01..29e4988bf52d 100644 --- a/pkgs/development/libraries/protobuf/generic.nix +++ b/pkgs/development/libraries/protobuf/generic.nix @@ -89,6 +89,14 @@ stdenv.mkDerivation (finalAttrs: { substituteInPlace src/google/protobuf/testing/googletest.cc \ --replace-fail 'tmpnam(b)' '"'$TMPDIR'/foo"' '' + # Adapt https://github.com/protocolbuffers/protobuf/pull/22412 for various + # older versions. sed -z spans newlines, so this can capture and replace + # the full multiline #if macro. + + lib.optionalString (lib.versionOlder version "32") '' + sed -zi 's/\(#if \w*(clang::musttail)\)[^\n]*\(\\\n[^\n]*\)*/'\ + '\1 \&\& (defined(__aarch64__) || defined(__x86_64__) || defined(_M_X64))/' \ + src/google/protobuf/port_def.inc + '' # Keep the sentinel macro non-retained for GCC 15+ to match generated # extension objects in linker arrays and avoid section type conflicts. + lib.optionalString (lib.versionAtLeast version "34") ''