summaryrefslogtreecommitdiff
path: root/dev-libs/protobuf-c
diff options
context:
space:
mode:
authorV3n3RiX <venerix@koprulu.sector>2023-08-21 21:44:48 +0100
committerV3n3RiX <venerix@koprulu.sector>2023-08-21 21:44:48 +0100
commitd51fe7680c5270ddf8d324bbe11caab6d1e27ade (patch)
treea895b5889d79dbbb9aa52995fcac4816acfa07c1 /dev-libs/protobuf-c
parent7d52991b5dce3a07be15d3cbbf06abb3fc08cb9c (diff)
gentoo auto-resync : 21:08:2023 - 21:44:47
Diffstat (limited to 'dev-libs/protobuf-c')
-rw-r--r--dev-libs/protobuf-c/Manifest2
-rw-r--r--dev-libs/protobuf-c/files/protobuf-c-1.4.1-protobuf-22.patch501
-rw-r--r--dev-libs/protobuf-c/protobuf-c-1.4.1-r1.ebuild56
3 files changed, 559 insertions, 0 deletions
diff --git a/dev-libs/protobuf-c/Manifest b/dev-libs/protobuf-c/Manifest
index 29a0c0bac77d..9af79e8dcdf6 100644
--- a/dev-libs/protobuf-c/Manifest
+++ b/dev-libs/protobuf-c/Manifest
@@ -1,7 +1,9 @@
AUX protobuf-c-1.3.0-no-build-tests.patch 1020 BLAKE2B adda0e4764283d00093709bc97500187521c1d099c6a057513cd4c4ab3b595479f62e7f90bc28ee062f7cae8a760445c78334468f25291320b74d46a5bb454cc SHA512 c6b6f37d8d0fb1ac14e650cc521034267b0af06525249078cc81fc8a3d551dc446bb5285228ca349ce18581979ea88eb9765233154cfbbedd8c4a937987d2684
AUX protobuf-c-1.4.0-include-path.patch 8092 BLAKE2B d1abcadbaf41789a882427cbae6d34e481f4bb66af95d95f0e33909bf25978b6adf80ba33094688e8a56ab51a7c0ee2b7aaba02ec591c286e824358ce671c212 SHA512 162b23bfd165c1dadaeb0f6c9eddc68819b5454c856def2d7a09d50d5694eaf5174ee6402197ff0d2e4465eb8f3130e0ef009f7f4d6de9fdbbd7af5fcf937ffb
+AUX protobuf-c-1.4.1-protobuf-22.patch 17194 BLAKE2B 711d3913f391775501f823af7ffd25fb5bffe748d255d88ebab7be406b2165e57d3197d15d3f08774745c4615a9a54fb8b051d3e801563a1ceeca1b8a5101175 SHA512 745e012a553c84a379a1c047147ba4fc9b06882561876a594546144d88d79cac9ff4327480a67808949957d158b5bc18aa7f94960856d07da43b2027d76a3067
DIST protobuf-c-1.4.0.tar.gz 505251 BLAKE2B 5f53238c064f82de87012eb739bf6a44c202d0dbf2fc5af394accdc52a9934d1fb9cea2bb4a4d529fdf98959546aaa672c1c991a9a7016803d16f65accc907cd SHA512 6a2e5031b85b5986e863661437dea002eba217257a50a27db88d29fa1a3db1014ed6ec7c21d89df700d181b18e169d1037146cb6475c10cd5a068a91e522e3c3
DIST protobuf-c-1.4.1.tar.gz 513596 BLAKE2B b5e87a3154863581b81790a26b6b522c2b3ad138e966053f20c6264b4a7677d6c5bff8e27faa7c6cfa9e982b72b06e2f518a3def9f6db13241c3cb3ee9afc8f6 SHA512 190a4aa5c607853e6bf860b0974deb21e4f7f6209e810251eaca9612b59ea676779b0ca217fb1572914ffb8de3315a7d24f162b14d447ee671a9adc5b1271e41
EBUILD protobuf-c-1.4.0-r1.ebuild 1140 BLAKE2B 0789c5324e6ea659307381050a63eb9e0ee33b5eab24f759dbf11be661f613820b9c3ca724ba4b4a7d234ac4545e96c1c8d2ca6f8fe0cc0c57c2a10e7599b182 SHA512 72a4d5a3c1d572ee3d8b946b97e99460868644d8400cf10c51dd161eab881307f54b53c00253fddf9db6a4faf0da453b7279656ed7f4ddc510daa19a074896e8
+EBUILD protobuf-c-1.4.1-r1.ebuild 1195 BLAKE2B 0bddbe7339106f394a4988a67a6e629b9d316174ae0f6fe21615444dc90928a59d7558c55bfddfa179e844ed620eebd916b776fe187d7de224bbdf18a937f946 SHA512 5eaf81919773b7b17434769c47d8c03604efffe4a5ecce6acb9bfb7bba157fb2abada46f721da74f74fffde8d68fd44c1b4c131d5862eec9c0e4a7c6dec9915a
EBUILD protobuf-c-1.4.1.ebuild 1147 BLAKE2B a0250ab24396e95117b93fd1ca36bfba7d253f8f02e726278e45c695bdecef2b994b70c43328e60e649a4c3974915994ffe00b0c7840be8511ef044695b6ffa7 SHA512 a0555be30fe6a76d3a2d19b991730b0b028729e011219062a561cb73e89cf4c721a45cc3d2c3f72c2541116b81d09ecb3b05e5680b5bb9f727a8584d512c5865
MISC metadata.xml 259 BLAKE2B 650e53279ca9375b8dcdec83d1065b370b820ee770225c753fc93d8600781aa4c191fe2a8016e34f5a24b4f9a94b922bc48eb75550c25a2d85672674866c0b62 SHA512 12f8cbcc9bac27c99a9a80b6f9ae803a8cde6b765ce0487a08cf76e83347bf0ac9793d50cc00d692a6069906d0e98af684c7b060262ec95f57621850ca47677c
diff --git a/dev-libs/protobuf-c/files/protobuf-c-1.4.1-protobuf-22.patch b/dev-libs/protobuf-c/files/protobuf-c-1.4.1-protobuf-22.patch
new file mode 100644
index 000000000000..5e53899aee3d
--- /dev/null
+++ b/dev-libs/protobuf-c/files/protobuf-c-1.4.1-protobuf-22.patch
@@ -0,0 +1,501 @@
+https://bugs.gentoo.org/912775
+https://github.com/protobuf-c/protobuf-c/issues/679
+https://github.com/protobuf-c/protobuf-c/issues/544
+https://github.com/protobuf-c/protobuf-c/pull/673
+
+From ad48868dfe77592c4bacf936ade208f384a26b09 Mon Sep 17 00:00:00 2001
+From: Robert Edmonds <edmonds@users.noreply.github.com>
+Date: Sun, 2 Jul 2023 17:48:18 -0400
+Subject: [PATCH 1/7] protoc-c: Remove GOOGLE_DISALLOW_EVIL_CONSTRUCTORS macro
+ invocations
+
+protobuf has removed the definition of this macro as of commit
+1595417dd3859bbff7d3d61ad0b6e39044d47489, so the invocation of this
+macro in protobuf-c breaks the build when building agaist the protobuf
+22.x or 23.x series.
+
+Simply removing the macro invocations seems to be safe and doesn't break
+the build on Debian's protobuf 3.21.12 nor Debian's protobuf 3.6.1.3.
+---
+ protoc-c/c_bytes_field.h | 2 --
+ protoc-c/c_enum.h | 2 --
+ protoc-c/c_enum_field.h | 2 --
+ protoc-c/c_extension.h | 2 --
+ protoc-c/c_field.h | 5 -----
+ protoc-c/c_file.h | 2 --
+ protoc-c/c_generator.h | 3 ---
+ protoc-c/c_message.h | 2 --
+ protoc-c/c_message_field.h | 4 ----
+ protoc-c/c_primitive_field.h | 4 ----
+ protoc-c/c_service.h | 2 --
+ protoc-c/c_string_field.h | 2 --
+ 12 files changed, 32 deletions(-)
+
+diff --git a/protoc-c/c_bytes_field.h b/protoc-c/c_bytes_field.h
+index bf873f0f..df91ef73 100644
+--- a/protoc-c/c_bytes_field.h
++++ b/protoc-c/c_bytes_field.h
+@@ -87,8 +87,6 @@ class BytesFieldGenerator : public FieldGenerator {
+
+ private:
+ std::map<std::string, std::string> variables_;
+-
+- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(BytesFieldGenerator);
+ };
+
+
+diff --git a/protoc-c/c_enum.h b/protoc-c/c_enum.h
+index 9c34b697..089c3366 100644
+--- a/protoc-c/c_enum.h
++++ b/protoc-c/c_enum.h
+@@ -106,8 +106,6 @@ class EnumGenerator {
+ private:
+ const EnumDescriptor* descriptor_;
+ std::string dllexport_decl_;
+-
+- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(EnumGenerator);
+ };
+
+ } // namespace c
+diff --git a/protoc-c/c_enum_field.h b/protoc-c/c_enum_field.h
+index 3f8c005d..e0c96adf 100644
+--- a/protoc-c/c_enum_field.h
++++ b/protoc-c/c_enum_field.h
+@@ -85,8 +85,6 @@ class EnumFieldGenerator : public FieldGenerator {
+
+ private:
+ std::map<std::string, std::string> variables_;
+-
+- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(EnumFieldGenerator);
+ };
+
+
+diff --git a/protoc-c/c_extension.h b/protoc-c/c_extension.h
+index 95413885..bda0bc55 100644
+--- a/protoc-c/c_extension.h
++++ b/protoc-c/c_extension.h
+@@ -98,8 +98,6 @@ class ExtensionGenerator {
+ const FieldDescriptor* descriptor_;
+ std::string type_traits_;
+ std::string dllexport_decl_;
+-
+- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ExtensionGenerator);
+ };
+
+ } // namespace c
+diff --git a/protoc-c/c_field.h b/protoc-c/c_field.h
+index 3cad35d3..623a872e 100644
+--- a/protoc-c/c_field.h
++++ b/protoc-c/c_field.h
+@@ -103,9 +103,6 @@ class FieldGenerator {
+ const std::string &type_macro,
+ const std::string &descriptor_addr) const;
+ const FieldDescriptor *descriptor_;
+-
+- private:
+- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(FieldGenerator);
+ };
+
+ // Convenience class which constructs FieldGenerators for a Descriptor.
+@@ -121,8 +118,6 @@ class FieldGeneratorMap {
+ std::unique_ptr<std::unique_ptr<FieldGenerator>[]> field_generators_;
+
+ static FieldGenerator* MakeGenerator(const FieldDescriptor* field);
+-
+- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(FieldGeneratorMap);
+ };
+
+ } // namespace c
+diff --git a/protoc-c/c_file.h b/protoc-c/c_file.h
+index 8dfd8ba0..db1866cd 100644
+--- a/protoc-c/c_file.h
++++ b/protoc-c/c_file.h
+@@ -103,8 +103,6 @@ class FileGenerator {
+ std::unique_ptr<std::unique_ptr<EnumGenerator>[]> enum_generators_;
+ std::unique_ptr<std::unique_ptr<ServiceGenerator>[]> service_generators_;
+ std::unique_ptr<std::unique_ptr<ExtensionGenerator>[]> extension_generators_;
+-
+- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(FileGenerator);
+ };
+
+ } // namespace c
+diff --git a/protoc-c/c_generator.h b/protoc-c/c_generator.h
+index ac1ffafe..b8b44aaa 100644
+--- a/protoc-c/c_generator.h
++++ b/protoc-c/c_generator.h
+@@ -93,9 +93,6 @@ class PROTOC_C_EXPORT CGenerator : public CodeGenerator {
+ const std::string& parameter,
+ OutputDirectory* output_directory,
+ std::string* error) const;
+-
+- private:
+- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(CGenerator);
+ };
+
+ } // namespace c
+diff --git a/protoc-c/c_message.h b/protoc-c/c_message.h
+index ea1c3ab3..0d8c6440 100644
+--- a/protoc-c/c_message.h
++++ b/protoc-c/c_message.h
+@@ -136,8 +136,6 @@ class MessageGenerator {
+ std::unique_ptr<std::unique_ptr<MessageGenerator>[]> nested_generators_;
+ std::unique_ptr<std::unique_ptr<EnumGenerator>[]> enum_generators_;
+ std::unique_ptr<std::unique_ptr<ExtensionGenerator>[]> extension_generators_;
+-
+- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MessageGenerator);
+ };
+
+ } // namespace c
+diff --git a/protoc-c/c_message_field.h b/protoc-c/c_message_field.h
+index 39b8d999..e485921a 100644
+--- a/protoc-c/c_message_field.h
++++ b/protoc-c/c_message_field.h
+@@ -82,10 +82,6 @@ class MessageFieldGenerator : public FieldGenerator {
+ void GenerateDescriptorInitializer(io::Printer* printer) const;
+ std::string GetDefaultValue(void) const;
+ void GenerateStaticInit(io::Printer* printer) const;
+-
+- private:
+-
+- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MessageFieldGenerator);
+ };
+
+
+diff --git a/protoc-c/c_primitive_field.h b/protoc-c/c_primitive_field.h
+index a9eb893b..aa7079f9 100644
+--- a/protoc-c/c_primitive_field.h
++++ b/protoc-c/c_primitive_field.h
+@@ -82,10 +82,6 @@ class PrimitiveFieldGenerator : public FieldGenerator {
+ void GenerateDescriptorInitializer(io::Printer* printer) const;
+ std::string GetDefaultValue(void) const;
+ void GenerateStaticInit(io::Printer* printer) const;
+-
+- private:
+-
+- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(PrimitiveFieldGenerator);
+ };
+
+ } // namespace c
+diff --git a/protoc-c/c_service.h b/protoc-c/c_service.h
+index 27125a60..b51472f9 100644
+--- a/protoc-c/c_service.h
++++ b/protoc-c/c_service.h
+@@ -100,8 +100,6 @@ class ServiceGenerator {
+
+ const ServiceDescriptor* descriptor_;
+ std::map<std::string, std::string> vars_;
+-
+- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ServiceGenerator);
+ };
+
+ } // namespace c
+diff --git a/protoc-c/c_string_field.h b/protoc-c/c_string_field.h
+index 513cea75..b3a1a7ff 100644
+--- a/protoc-c/c_string_field.h
++++ b/protoc-c/c_string_field.h
+@@ -87,8 +87,6 @@ class StringFieldGenerator : public FieldGenerator {
+
+ private:
+ std::map<std::string, std::string> variables_;
+-
+- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(StringFieldGenerator);
+ };
+
+
+
+From 7b90330bff40ab555bb3f0c5ee43ae208a275104 Mon Sep 17 00:00:00 2001
+From: Robert Edmonds <edmonds@users.noreply.github.com>
+Date: Sun, 2 Jul 2023 19:35:43 -0400
+Subject: [PATCH 2/7] Use GOOGLE_LOG(FATAL) instead of GOOGLE_LOG(DFATAL)
+
+Looking at where these identifiers are ultimately defined [0], it looks
+like "DFATAL" means either "ERROR" or "FATAL" depending on whether
+NDEBUG is defined. However, looking at the actual code sites in protoc-c
+where DFATAL is used, it's not clear why we couldn't just use FATAL
+unconditionally.
+
+This is aimed at supporting newer versions of protobuf where the DFATAL
+identifier apparently no longer exists.
+
+[0] https://github.com/protocolbuffers/protobuf/blob/v21.12/src/google/protobuf/stubs/logging.h#L61-L65
+---
+ protoc-c/c_message.cc | 4 ++--
+ protoc-c/c_primitive_field.cc | 2 +-
+ 2 files changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/protoc-c/c_message.cc b/protoc-c/c_message.cc
+index 37e8bf8b..af2974ca 100755
+--- a/protoc-c/c_message.cc
++++ b/protoc-c/c_message.cc
+@@ -499,7 +499,7 @@ GenerateMessageDescriptor(io::Printer* printer, bool gen_init) {
+ // NOTE: not supported by protobuf
+ vars["maybe_static"] = "";
+ vars["field_dv_ctype"] = "{ ... }";
+- GOOGLE_LOG(DFATAL) << "Messages can't have default values!";
++ GOOGLE_LOG(FATAL) << "Messages can't have default values!";
+ break;
+ case FieldDescriptor::CPPTYPE_STRING:
+ if (fd->type() == FieldDescriptor::TYPE_BYTES || opt.string_as_bytes())
+@@ -521,7 +521,7 @@ GenerateMessageDescriptor(io::Printer* printer, bool gen_init) {
+ break;
+ }
+ default:
+- GOOGLE_LOG(DFATAL) << "Unknown CPPTYPE";
++ GOOGLE_LOG(FATAL) << "Unknown CPPTYPE";
+ break;
+ }
+ if (!already_defined)
+diff --git a/protoc-c/c_primitive_field.cc b/protoc-c/c_primitive_field.cc
+index 6990893f..1727af38 100644
+--- a/protoc-c/c_primitive_field.cc
++++ b/protoc-c/c_primitive_field.cc
+@@ -143,7 +143,7 @@ std::string PrimitiveFieldGenerator::GetDefaultValue() const
+ case FieldDescriptor::CPPTYPE_BOOL:
+ return descriptor_->default_value_bool() ? "1" : "0";
+ default:
+- GOOGLE_LOG(DFATAL) << "unexpected CPPTYPE in c_primitive_field";
++ GOOGLE_LOG(FATAL) << "unexpected CPPTYPE in c_primitive_field";
+ return "UNEXPECTED_CPPTYPE";
+ }
+ }
+
+From 8d334a7204d98874cbf970cb96ab0c7b52e06695 Mon Sep 17 00:00:00 2001
+From: Robert Edmonds <edmonds@users.noreply.github.com>
+Date: Sun, 2 Jul 2023 19:42:19 -0400
+Subject: [PATCH 3/7] Work around GOOGLE_* changes in protobuf >= 22.0
+
+According to the protobuf migration guide as of June 2023 [0], protobuf
+22.0 (aka 4.22.0) took a dependency on something called "abseil" and as
+a result the "stubs" have been removed. This apparently caused all the
+uses of GOOGLE_* identifiers in protoc-c to fail when building against
+newer versions of protobuf.
+
+This commit introduces compatibility definitions when building against
+protobuf >= 4.22.0 so that protobuf-c can build against older and newer
+versions of protobuf.
+
+[0] https://web.archive.org/web/20230611151200/https://protobuf.dev/support/migration/#abseil
+---
+ protoc-c/c_helpers.h | 10 ++++++++++
+ 1 file changed, 10 insertions(+)
+
+diff --git a/protoc-c/c_helpers.h b/protoc-c/c_helpers.h
+index 7598a4e1..adc7ee21 100644
+--- a/protoc-c/c_helpers.h
++++ b/protoc-c/c_helpers.h
+@@ -178,6 +178,16 @@ inline int FieldSyntax(const FieldDescriptor* field) {
+ #endif
+ }
+
++// Work around changes in protobuf >= 22.x without breaking compilation against
++// older protobuf versions.
++#if GOOGLE_PROTOBUF_VERSION >= 4022000
++# define GOOGLE_ARRAYSIZE ABSL_ARRAYSIZE
++# define GOOGLE_CHECK_EQ ABSL_CHECK_EQ
++# define GOOGLE_CHECK_EQ ABSL_CHECK_EQ
++# define GOOGLE_DCHECK_GE ABSL_DCHECK_GE
++# define GOOGLE_LOG ABSL_LOG
++#endif
++
+ } // namespace c
+ } // namespace compiler
+ } // namespace protobuf
+
+From 23d2246e0f6ebfc69232ab29b6c6325d8009d1f7 Mon Sep 17 00:00:00 2001
+From: Robert Edmonds <edmonds@users.noreply.github.com>
+Date: Sun, 2 Jul 2023 19:48:17 -0400
+Subject: [PATCH 4/7] configure.ac: Require C++17 when building against
+ protobuf >= 4.22.0
+
+It's unclear from looking at the online protobuf documentation whether
+C++14 or C++17 is now required when building against newer versions of
+protobuf (or perhaps I'm looking in the wrong place), but experimentally
+it did not work for me with C++14.
+
+This commit rewrites the versioned PKG_CHECK_MODULES checks in
+configure.ac to enforce the following policies:
+
+ * Require protobuf >= 2.6.0.
+ * On protobuf >= 3.0.0, require C++11.
+ * On protobuf >= 4.22.0, require C++17.
+---
+ configure.ac | 26 ++++++++++++++++++++------
+ 1 file changed, 20 insertions(+), 6 deletions(-)
+
+diff --git a/configure.ac b/configure.ac
+index 94d01dca..fa024b6a 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -76,12 +76,26 @@ AC_ARG_ENABLE([protoc],
+ if test "x$enable_protoc" != "xno"; then
+ AC_LANG_PUSH([C++])
+
+- AX_CXX_COMPILE_STDCXX(11, noext, mandatory)
+-
+- PKG_CHECK_MODULES([protobuf], [protobuf >= 3.0.0],
+- [proto3_supported=yes],
+- [PKG_CHECK_MODULES([protobuf], [protobuf >= 2.6.0])]
+- )
++ # PKG_CHECK_MODULES(prefix, list-of-modules, action-if-found, action-if-not-found)
++ PKG_CHECK_MODULES(
++ [protobuf],
++ [protobuf >= 4.22.0],
++ [
++ proto3_supported=yes
++ AX_CXX_COMPILE_STDCXX(17, noext, mandatory)
++ ],
++ [
++ PKG_CHECK_MODULES(
++ [protobuf],
++ [protobuf >= 3.0.0],
++ [
++ proto3_supported=yes
++ AX_CXX_COMPILE_STDCXX(11, noext, mandatory)
++ ],
++ [
++ PKG_CHECK_MODULES([protobuf], [protobuf >= 2.6.0])
++ ])
++ ])
+
+ save_CPPFLAGS="$CPPFLAGS"
+ CPPFLAGS="$save_CPPFLAGS $protobuf_CFLAGS"
+
+From 1937ba946b0a7a62c0f534e60f4d4799d7e0daed Mon Sep 17 00:00:00 2001
+From: Robert Edmonds <edmonds@users.noreply.github.com>
+Date: Sun, 2 Jul 2023 22:57:57 -0400
+Subject: [PATCH 5/7] protoc-c: Use FileDescriptorLegacy to obtain proto syntax
+ version on protobuf >= 23.0
+
+Use the newer "legacy" way of determining whether a file descriptor is
+using proto2 or proto3 syntax on protobuf >= 23.0.
+
+Based on
+https://github.com/protobuf-c/protobuf-c/pull/556/commits/66574f3fd85a205eb7c90b790477d5415364209e
+but continues to support older versions of protobuf.
+
+Unfortunately, since this is a "deprecated", "legacy" API it'll probably
+disappear in about five seconds.
+---
+ protoc-c/c_file.cc | 4 ++++
+ protoc-c/c_helpers.h | 8 ++++++++
+ 2 files changed, 12 insertions(+)
+
+diff --git a/protoc-c/c_file.cc b/protoc-c/c_file.cc
+index 59c1824e..d211a3da 100644
+--- a/protoc-c/c_file.cc
++++ b/protoc-c/c_file.cc
+@@ -119,7 +119,11 @@ void FileGenerator::GenerateHeader(io::Printer* printer) {
+
+ int min_header_version = 1000000;
+ #if defined(HAVE_PROTO3)
++# if GOOGLE_PROTOBUF_VERSION >= 4023000
++ if (FileDescriptorLegacy(file_).syntax() == FileDescriptorLegacy::SYNTAX_PROTO3) {
++# else
+ if (file_->syntax() == FileDescriptor::SYNTAX_PROTO3) {
++#endif
+ min_header_version = 1003000;
+ }
+ #endif
+diff --git a/protoc-c/c_helpers.h b/protoc-c/c_helpers.h
+index adc7ee21..055528bf 100644
+--- a/protoc-c/c_helpers.h
++++ b/protoc-c/c_helpers.h
+@@ -70,6 +70,10 @@
+ #include <protobuf-c/protobuf-c.pb.h>
+ #include <google/protobuf/io/printer.h>
+
++#if GOOGLE_PROTOBUF_VERSION >= 4023000
++# include <google/protobuf/descriptor_legacy.h>
++#endif
++
+ namespace google {
+ namespace protobuf {
+ namespace compiler {
+@@ -172,7 +176,11 @@ int compare_name_indices_by_name(const void*, const void*);
+ // This wrapper is needed to be able to compile against protobuf2.
+ inline int FieldSyntax(const FieldDescriptor* field) {
+ #ifdef HAVE_PROTO3
++# if GOOGLE_PROTOBUF_VERSION >= 4023000
++ return FileDescriptorLegacy(field->file()).syntax() == FileDescriptorLegacy::SYNTAX_PROTO3 ? 3 : 2;
++# else
+ return field->file()->syntax() == FileDescriptor::SYNTAX_PROTO3 ? 3 : 2;
++# endif
+ #else
+ return 2;
+ #endif
+
+From 7582b6e7d640636bf24c0f9dd2b386ed6fd41919 Mon Sep 17 00:00:00 2001
+From: Robert Edmonds <edmonds@users.noreply.github.com>
+Date: Sun, 2 Jul 2023 22:58:48 -0400
+Subject: [PATCH 6/7] cmake: Require C++17
+
+Newer versions of protobuf apparently don't build with older versions of
+the C++ standard.
+---
+ build-cmake/CMakeLists.txt | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/build-cmake/CMakeLists.txt b/build-cmake/CMakeLists.txt
+index 95f561c0..c71dd899 100644
+--- a/build-cmake/CMakeLists.txt
++++ b/build-cmake/CMakeLists.txt
+@@ -96,7 +96,7 @@ if (MSVC AND NOT BUILD_SHARED_LIBS)
+ endif (MSVC AND NOT BUILD_SHARED_LIBS)
+
+ IF(BUILD_PROTOC)
+-SET(CMAKE_CXX_STANDARD 11)
++SET(CMAKE_CXX_STANDARD 17)
+ SET(CMAKE_CXX_STANDARD_REQUIRED ON)
+ SET(CMAKE_CXX_EXTENSIONS OFF)
+ ADD_CUSTOM_COMMAND(OUTPUT protobuf-c/protobuf-c.pb.cc protobuf-c/protobuf-c.pb.h
+
+From 5b0661f1e8a0e03f75cc6f53b8d42507e95403c9 Mon Sep 17 00:00:00 2001
+From: Robert Edmonds <edmonds@users.noreply.github.com>
+Date: Mon, 3 Jul 2023 01:10:28 -0400
+Subject: [PATCH 7/7] configure.ac: Require C++17
+
+There are some recent reports of strange build failures that might have
+been fixed by compiling in C++17 mode, so it might be a good idea to use
+C++17 in general, and not just when building against very recent
+protobuf versions.
+
+Since it looks like we've lost protobuf < 3.0.0 support, configure.ac
+can be simplified a bit if we just use C++17 by default.
+---
+ configure.ac | 23 ++---------------------
+ 1 file changed, 2 insertions(+), 21 deletions(-)
+
+diff --git a/configure.ac b/configure.ac
+index fa024b6a..586ac3c0 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -75,27 +75,8 @@ AC_ARG_ENABLE([protoc],
+ AS_HELP_STRING([--disable-protoc], [Disable building protoc_c (also disables tests)]))
+ if test "x$enable_protoc" != "xno"; then
+ AC_LANG_PUSH([C++])
+-
+- # PKG_CHECK_MODULES(prefix, list-of-modules, action-if-found, action-if-not-found)
+- PKG_CHECK_MODULES(
+- [protobuf],
+- [protobuf >= 4.22.0],
+- [
+- proto3_supported=yes
+- AX_CXX_COMPILE_STDCXX(17, noext, mandatory)
+- ],
+- [
+- PKG_CHECK_MODULES(
+- [protobuf],
+- [protobuf >= 3.0.0],
+- [
+- proto3_supported=yes
+- AX_CXX_COMPILE_STDCXX(11, noext, mandatory)
+- ],
+- [
+- PKG_CHECK_MODULES([protobuf], [protobuf >= 2.6.0])
+- ])
+- ])
++ AX_CXX_COMPILE_STDCXX(17, noext, mandatory)
++ PKG_CHECK_MODULES([protobuf], [protobuf >= 3.0.0], [proto3_supported=yes])
+
+ save_CPPFLAGS="$CPPFLAGS"
+ CPPFLAGS="$save_CPPFLAGS $protobuf_CFLAGS"
diff --git a/dev-libs/protobuf-c/protobuf-c-1.4.1-r1.ebuild b/dev-libs/protobuf-c/protobuf-c-1.4.1-r1.ebuild
new file mode 100644
index 000000000000..edb57577cfd9
--- /dev/null
+++ b/dev-libs/protobuf-c/protobuf-c-1.4.1-r1.ebuild
@@ -0,0 +1,56 @@
+# Copyright 1999-2023 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+inherit autotools multilib-minimal
+
+MY_PV="${PV/_/-}"
+MY_P="${PN}-${MY_PV}"
+
+DESCRIPTION="Protocol Buffers implementation in C"
+HOMEPAGE="https://github.com/protobuf-c/protobuf-c"
+SRC_URI="https://github.com/${PN}/${PN}/releases/download/v${MY_PV}/${MY_P}.tar.gz"
+S="${WORKDIR}/${MY_P}"
+
+LICENSE="BSD-2"
+# Subslot == SONAME version
+SLOT="0/1.0.0"
+KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~loong ~mips ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86"
+IUSE="static-libs test"
+RESTRICT="!test? ( test )"
+
+BDEPEND="
+ >=dev-libs/protobuf-3:0
+ virtual/pkgconfig
+"
+DEPEND=">=dev-libs/protobuf-3:0=[${MULTILIB_USEDEP}]"
+RDEPEND="${DEPEND}"
+
+PATCHES=(
+ "${FILESDIR}"/${PN}-1.4.0-include-path.patch
+ "${FILESDIR}"/${P}-protobuf-22.patch
+)
+
+src_prepare() {
+ default
+
+ if ! use test; then
+ eapply "${FILESDIR}"/${PN}-1.3.0-no-build-tests.patch
+ fi
+
+ eautoreconf
+}
+
+multilib_src_configure() {
+ local myeconfargs=(
+ $(use_enable static-libs static)
+ )
+
+ ECONF_SOURCE="${S}" econf "${myeconfargs[@]}"
+}
+
+multilib_src_install_all() {
+ find "${ED}" -name '*.la' -type f -delete || die
+ einstalldocs
+}