From patchwork Fri Sep 13 16:26:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adolf Belka X-Patchwork-Id: 8113 Return-Path: Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) client-signature RSA-PSS (4096 bits)) (Client CN "mail01.haj.ipfire.org", Issuer "R10" (verified OK)) by web04.haj.ipfire.org (Postfix) with ESMTPS id 4X506z6cM3z3wxp for ; Fri, 13 Sep 2024 16:26:19 +0000 (UTC) Received: from mail02.haj.ipfire.org (mail02.haj.ipfire.org [172.28.1.201]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) client-signature ECDSA (secp384r1)) (Client CN "mail02.haj.ipfire.org", Issuer "E6" (verified OK)) by mail01.ipfire.org (Postfix) with ESMTPS id 4X506z3sgwz2sr; Fri, 13 Sep 2024 16:26:19 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4X506z2S36z342Z; Fri, 13 Sep 2024 16:26:19 +0000 (UTC) Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) client-signature RSA-PSS (4096 bits)) (Client CN "mail01.haj.ipfire.org", Issuer "R10" (verified OK)) by mail02.haj.ipfire.org (Postfix) with ESMTPS id 4X506x0F4Gz2ybk for ; Fri, 13 Sep 2024 16:26:17 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) (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 mail01.ipfire.org (Postfix) with ESMTPSA id 4X506w5k4Wz1Fd; Fri, 13 Sep 2024 16:26:16 +0000 (UTC) DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003ed25519; t=1726244776; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3A26bP4GDT2hZCiyYDZKtGpbQl8EIoOU7dI4Tp5fUfU=; b=B5EaGIfd3D5U6HcUYTRX4uiZLwTTmsQSPqHCXaP2mA8IW8iuE08aUHzcxwmWniMt3AVVvH cfd27IQWjWThO1Ag== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003rsa; t=1726244776; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3A26bP4GDT2hZCiyYDZKtGpbQl8EIoOU7dI4Tp5fUfU=; b=vjpvpE7s1LbB8AZdFr/Tp9OZnbCyXB5y6kXTsiVIB20Jrqf+vQ4KNAAo1QkuGBe2rj3AUR kERxTMh/m56D7I6sER0+DDxlB2Ry8eZVhEBxv77hPqwqG1pCRu6apnCH4VXyn68sxTZnZQ gWUw8w7K/Qj5SZ4l/k5r+2sV9OmNWM5L2a2zlMyLUQL1ihufLEKa6TW4jY9PHMQ1BwqrU9 wbr58VqfcWtFRgnIL3t6G+FPu/+ZvWW4H6EQA92bbsEzY/pCvDfKexuNtkhUX5ORC44AQZ Cz+OsejRxskJ0QLjDWQ/bFrx9HHLnx45AUpb7l0kN9KHptTEyFHTY7Q4UaqL0g== From: Adolf Belka To: development@lists.ipfire.org Subject: [PATCH 2/2] protobuf-c: Update of protobuf removed SYNTAX_PROTO3 used by protobuf-c-1.5.0 Date: Fri, 13 Sep 2024 18:26:11 +0200 Message-ID: <20240913162611.2352531-2-adolf.belka@ipfire.org> In-Reply-To: <20240913162611.2352531-1-adolf.belka@ipfire.org> References: <20240913162611.2352531-1-adolf.belka@ipfire.org> MIME-Version: 1.0 Message-ID-Hash: SP7VKMZWIGOVFD5LMI6DXDDZ2BIUCM3Y X-Message-ID-Hash: SP7VKMZWIGOVFD5LMI6DXDDZ2BIUCM3Y X-MailFrom: adolf.belka@ipfire.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: IPFire development talk Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: - Addition of patch to enable protobuf-c to be built with protobuf version > 26 - When protobuf-c is upgraded to version 1.5.1 it will include this patch Signed-off-by: Adolf Belka --- lfs/protobuf-c | 3 +- .../protobuf-c_1.5.0_protobuf-26.patch | 118 ++++++++++++++++++ 2 files changed, 120 insertions(+), 1 deletion(-) create mode 100644 src/patches/protobuf-c_1.5.0_protobuf-26.patch diff --git a/lfs/protobuf-c b/lfs/protobuf-c index 2c3128f35..679977872 100644 --- a/lfs/protobuf-c +++ b/lfs/protobuf-c @@ -70,8 +70,9 @@ $(subst %,%_BLAKE2,$(objects)) : $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects)) @$(PREBUILD) @rm -rf $(DIR_APP) && cd $(DIR_SRC) && tar axf $(DIR_DL)/$(DL_FILE) + cd $(DIR_APP) && patch -Np1 -i $(DIR_SRC)/src/patches/protobuf-c_1.5.0_protobuf-26.patch cd $(DIR_APP) && ./configure \ - --prefix=/usr + --prefix=/usr cd $(DIR_APP) && make $(MAKETUNING) cd $(DIR_APP) && make install @rm -rf $(DIR_APP) diff --git a/src/patches/protobuf-c_1.5.0_protobuf-26.patch b/src/patches/protobuf-c_1.5.0_protobuf-26.patch new file mode 100644 index 000000000..40c9e64d0 --- /dev/null +++ b/src/patches/protobuf-c_1.5.0_protobuf-26.patch @@ -0,0 +1,118 @@ +From a6cf1aa386067e26d582cc1d1e327787595c9f13 Mon Sep 17 00:00:00 2001 +From: Robert Edmonds +Date: Wed, 20 Mar 2024 21:48:10 -0400 +Subject: [PATCH 1/3] 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 2/3] 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 +