From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 85CB61581C1 for ; Tue, 9 Jul 2024 12:52:38 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 56903E2A3B; Tue, 9 Jul 2024 12:52:37 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 3781DE2A3B for ; Tue, 9 Jul 2024 12:52:37 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 2FFEB343053 for ; Tue, 9 Jul 2024 12:52:36 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 7020A1DFC for ; Tue, 9 Jul 2024 12:52:34 +0000 (UTC) From: "Sam James" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Sam James" Message-ID: <1720529484.3048b6e8c4bc551480e6fd966fe531c0db1d3afc.sam@gentoo> Subject: [gentoo-commits] repo/gentoo:master commit in: dev-libs/protobuf-c/, dev-libs/protobuf-c/files/ X-VCS-Repository: repo/gentoo X-VCS-Files: dev-libs/protobuf-c/files/protobuf-c-1.5.0-Clean-CMake.patch dev-libs/protobuf-c/protobuf-c-1.5.0-r1.ebuild X-VCS-Directories: dev-libs/protobuf-c/ dev-libs/protobuf-c/files/ X-VCS-Committer: sam X-VCS-Committer-Name: Sam James X-VCS-Revision: 3048b6e8c4bc551480e6fd966fe531c0db1d3afc X-VCS-Branch: master Date: Tue, 9 Jul 2024 12:52:34 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: fa913961-d712-4d7d-b9a9-a7e561e541e6 X-Archives-Hash: ad6e017545c6d55e282990240600455f commit: 3048b6e8c4bc551480e6fd966fe531c0db1d3afc Author: Paul Zander gmail com> AuthorDate: Sun Jul 7 15:57:14 2024 +0000 Commit: Sam James gentoo org> CommitDate: Tue Jul 9 12:51:24 2024 +0000 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=3048b6e8 dev-libs/protobuf-c: add 1.5.0-r1 Signed-off-by: Paul Zander gmail.com> Signed-off-by: Sam James gentoo.org> .../files/protobuf-c-1.5.0-Clean-CMake.patch | 169 +++++++++++++++++++++ dev-libs/protobuf-c/protobuf-c-1.5.0-r1.ebuild | 51 +++++++ 2 files changed, 220 insertions(+) diff --git a/dev-libs/protobuf-c/files/protobuf-c-1.5.0-Clean-CMake.patch b/dev-libs/protobuf-c/files/protobuf-c-1.5.0-Clean-CMake.patch new file mode 100644 index 000000000000..f3e55a9c89cc --- /dev/null +++ b/dev-libs/protobuf-c/files/protobuf-c-1.5.0-Clean-CMake.patch @@ -0,0 +1,169 @@ +From a6cf1aa386067e26d582cc1d1e327787595c9f13 Mon Sep 17 00:00:00 2001 +From: Robert Edmonds +Date: Wed, 20 Mar 2024 21:48:10 -0400 +Subject: [PATCH 01/11] FileGenerator::GenerateHeader(): Set + `min_header_version` unconditionally + +Previously, we were conditionally trying to set `min_header_version` to +the lowest possible value, and relying on a "legacy" Google interface to +determine the file descriptor's syntax version as part of that +determination. + +Instead, simply bump the minimum version to 1003000 (1.3.0). This +release was almost 7 years ago. In practice protobuf-c users should not +be shipping pre-compiled .pb-c.c/.pb-c.h files, anyway. +--- + protoc-c/c_file.cc | 9 +-------- + 1 file changed, 1 insertion(+), 8 deletions(-) + +diff --git a/protoc-c/c_file.cc b/protoc-c/c_file.cc +index ca0ad34e..c6d8a240 100644 +--- a/protoc-c/c_file.cc ++++ b/protoc-c/c_file.cc +@@ -117,14 +117,7 @@ FileGenerator::~FileGenerator() {} + void FileGenerator::GenerateHeader(io::Printer* printer) { + std::string filename_identifier = FilenameIdentifier(file_->name()); + +- int min_header_version = 1000000; +-#if GOOGLE_PROTOBUF_VERSION >= 4023000 +- if (FileDescriptorLegacy(file_).syntax() == FileDescriptorLegacy::SYNTAX_PROTO3) { +-#else +- if (file_->syntax() == FileDescriptor::SYNTAX_PROTO3) { +-#endif +- min_header_version = 1003000; +- } ++ const int min_header_version = 1003000; + + // Generate top of header. + printer->Print( + +From ee3d9e5423c93ee6b828fdda8e7fef13a77634eb Mon Sep 17 00:00:00 2001 +From: Robert Edmonds +Date: Wed, 20 Mar 2024 22:25:54 -0400 +Subject: [PATCH 02/11] Reimplement FieldSyntax() to maximize compatibility + across protobuf versions + +Recent versions of Google protobuf have broken the interfaces for +determining the syntax version of a .proto file. The current protobuf-c +1.5.0 release does not compile with Google protobuf 26.0 due to the most +recentage breakage. There is a possible workaround involving the Google +protobuf `FileDescriptorLegacy` class, which is documented as: + +// TODO Remove this deprecated API entirely. + +So we probably shouldn't rely on it. + +Instead, this commit obtains the `FileDescriptorProto` corresponding +to the passed in `FieldDescriptor` and interrogates the `syntax` field +directly. This is a single implementation with no version-specific +workarounds. Hopefully this won't break in the next Google protobuf +release. + +I tested the `FieldSyntax()` implementation in this commit across a +number of different Google protobuf releases and found that it worked +(`make && make check`) on all of them: + +- Google protobuf 3.6.1.3 (Ubuntu 20.04) +- Google protobuf 3.12.4 (Ubuntu 22.04) +- Google protobuf 3.21.12 (Debian 12 + Debian unstable) +- Google protobuf 3.25.2 (Debian experimental) +- Google protobuf 26.1-dev +--- + protoc-c/c_helpers.h | 24 ++++++++++++++---------- + 1 file changed, 14 insertions(+), 10 deletions(-) + +diff --git a/protoc-c/c_helpers.h b/protoc-c/c_helpers.h +index 062d330b..be28b601 100644 +--- a/protoc-c/c_helpers.h ++++ b/protoc-c/c_helpers.h +@@ -70,10 +70,6 @@ + #include + #include + +-#if GOOGLE_PROTOBUF_VERSION >= 4023000 +-# include +-#endif +- + namespace google { + namespace protobuf { + namespace compiler { +@@ -173,13 +169,21 @@ struct NameIndex + int compare_name_indices_by_name(const void*, const void*); + + // Return the syntax version of the file containing the field. +-// This wrapper is needed to be able to compile against protobuf2. + inline int FieldSyntax(const FieldDescriptor* field) { +-#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 ++ auto proto = FileDescriptorProto(); ++ field->file()->CopyTo(&proto); ++ ++ if (proto.has_syntax()) { ++ auto syntax = proto.syntax(); ++ assert(syntax == "proto2" || syntax == "proto3"); ++ if (syntax == "proto2") { ++ return 2; ++ } else if (syntax == "proto3") { ++ return 3; ++ } ++ } ++ ++ return 2; + } + + // Work around changes in protobuf >= 22.x without breaking compilation against + +From 2480f4d9d2fa97e5511ed0914ee529a344e969a7 Mon Sep 17 00:00:00 2001 +From: Robert Edmonds +Date: Wed, 20 Mar 2024 22:43:30 -0400 +Subject: [PATCH 03/11] CGenerator: Protect against being invoked against + "edition" syntax .proto files + +The Google protobuf project is currently experimenting with a new syntax +for .proto files called "editions". Since protobuf-c is a proto2/proto3 +compiler, after the previous commit reimplementing `FieldSyntax()`, the +protobuf compiler will abort like this if presented with an "editions" +syntax .proto file due to the safety check in `FieldSyntax()`: + + $ protoc --experimental_editions --c_out=. test.proto + protoc-gen-c: ./protoc-c/c_helpers.h:178: int google::protobuf::compiler::c::FieldSyntax(const google::protobuf::FieldDescriptor*): Assertion `syntax == "proto2" || syntax == "proto3"' failed. + --c_out: protoc-gen-c: Plugin killed by signal 6. + +On protobuf 26, our `CodeGenerator` can implement certain methods to +declare that we "support" editions, and then reject any other edition +except proto2 and proto3, which have apparently been retroactively +declared to be "editions". Of course this needs to be wrapped in a +version guard. + +With this protection in place, the protobuf compiler cleanly exits with +a nice error message like this: + + $ protoc --experimental_editions --c_out=. test.proto + WARNING: All log messages before absl::InitializeLog() is called are written to STDERR + E0000 00:00:1710988958.296200 20022 descriptor.cc:4620] Invalid proto descriptor for file "test.proto": + E0000 00:00:1710988958.296239 20022 descriptor.cc:4623] test.proto: Edition 2023 is later than the maximum supported edition PROTO3 + --c_out: protoc-gen-c: Plugin failed with status code 1. +--- + protoc-c/c_generator.h | 6 ++++++ + 1 file changed, 6 insertions(+) + +diff --git a/protoc-c/c_generator.h b/protoc-c/c_generator.h +index b8b44aaa..4aeb5790 100644 +--- a/protoc-c/c_generator.h ++++ b/protoc-c/c_generator.h +@@ -93,6 +93,12 @@ class PROTOC_C_EXPORT CGenerator : public CodeGenerator { + const std::string& parameter, + OutputDirectory* output_directory, + std::string* error) const; ++ ++#if GOOGLE_PROTOBUF_VERSION >= 5026000 ++ uint64_t GetSupportedFeatures() const { return CodeGenerator::FEATURE_SUPPORTS_EDITIONS; } ++ Edition GetMinimumEdition() const { return Edition::EDITION_PROTO2; } ++ Edition GetMaximumEdition() const { return Edition::EDITION_PROTO3; } ++#endif + }; + + } // namespace c diff --git a/dev-libs/protobuf-c/protobuf-c-1.5.0-r1.ebuild b/dev-libs/protobuf-c/protobuf-c-1.5.0-r1.ebuild new file mode 100644 index 000000000000..842e911beb9e --- /dev/null +++ b/dev-libs/protobuf-c/protobuf-c-1.5.0-r1.ebuild @@ -0,0 +1,51 @@ +# Copyright 1999-2024 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" + +BDEPEND=" + >=dev-libs/protobuf-3:0 + virtual/pkgconfig +" +DEPEND=" + >=dev-libs/protobuf-3:0=[${MULTILIB_USEDEP}]" +RDEPEND="${DEPEND}" + +PATCHES=( + "${FILESDIR}/${PN}-1.5.0-Clean-CMake.patch" +) + +src_prepare() { + default + eautoreconf +} + +multilib_src_configure() { + local myeconfargs=( + $(use_enable static-libs static) + --enable-year2038 + ) + + ECONF_SOURCE="${S}" econf "${myeconfargs[@]}" +} + +multilib_src_install_all() { + find "${ED}" -name '*.la' -type f -delete || die + einstalldocs +}