From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 287C3D13592 for ; Mon, 28 Oct 2024 02:54:37 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 962CA81355; Mon, 28 Oct 2024 02:54:36 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id PW8T72lw3159; Mon, 28 Oct 2024 02:54:35 +0000 (UTC) X-Comment: SPF check N/A for local connections - client-ip=140.211.166.142; helo=lists1.osuosl.org; envelope-from=buildroot-bounces@buildroot.org; receiver= DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 486318136E Received: from lists1.osuosl.org (lists1.osuosl.org [140.211.166.142]) by smtp1.osuosl.org (Postfix) with ESMTP id 486318136E; Mon, 28 Oct 2024 02:54:35 +0000 (UTC) Received: from smtp3.osuosl.org (smtp3.osuosl.org [IPv6:2605:bc80:3010::136]) by lists1.osuosl.org (Postfix) with ESMTP id 18B414EC0 for ; Mon, 28 Oct 2024 02:54:26 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 07DB5607A7 for ; Mon, 28 Oct 2024 02:54:26 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id sswpMMBSjX0S for ; Mon, 28 Oct 2024 02:54:25 +0000 (UTC) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=2607:f8b0:4864:20::d36; helo=mail-io1-xd36.google.com; envelope-from=james.hilliard1@gmail.com; receiver= DMARC-Filter: OpenDMARC Filter v1.4.2 smtp3.osuosl.org C838D60721 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org C838D60721 Received: from mail-io1-xd36.google.com (mail-io1-xd36.google.com [IPv6:2607:f8b0:4864:20::d36]) by smtp3.osuosl.org (Postfix) with ESMTPS id C838D60721 for ; Mon, 28 Oct 2024 02:54:24 +0000 (UTC) Received: by mail-io1-xd36.google.com with SMTP id ca18e2360f4ac-83ac817aac3so154290539f.0 for ; Sun, 27 Oct 2024 19:54:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730084063; x=1730688863; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=GI36vGPMmz9uTdU8J+53ysOZo6lh2N8gF1hKX8m5fUc=; b=ecHUhx2WzjCm5sAvJOsZZgC5VXzXpx6c4wh4L8y1dvppXTL2ukMmGrYhSJGJXcWW4f QE5k2KcunJRsh6gG11SDt2hPKPFiTcSxHzrSpY42kDPJSOny8S3jMw2fH5/90S9YDgzh 9jhVXZTN4dzK1MOlHj+wsFfD1xiz1kiR9AREf81u7GApCD5hZUcdVqkpBw85dXuyq2vF 17lgeXxOnmxcVdYx/LAhHWkkMqrDVUt00p5EV/aN1CSEfwik1N2CXQAqOmSagmFSTlTf rfJ+bPc7JrHVfXpQx69cAtGZhxS4pZ2Pf11pyK1Tcytmz/nzsu8q07+fR3KBcqnpuGky oaaw== X-Gm-Message-State: AOJu0YynS4/DbmcsOUMOZdDUWxLhfMm9ygZnYENG9Xsn37QGm+M1wAnL Y8DvzMHy+HOJPe6LVmRK1B6qKrWQ+UgYmy3tSL8e9luprCkyLJ68MmJj2voV X-Google-Smtp-Source: AGHT+IH6DYTvxi055TjVDuRe8MnPRPX7pPPJnejqexpTuNIRofJ1MR3cqWsc5S32V73RZUV8nQF/Ug== X-Received: by 2002:a05:6602:6b0b:b0:83a:b74c:800e with SMTP id ca18e2360f4ac-83b1c4ae5c3mr553862739f.12.1730084063471; Sun, 27 Oct 2024 19:54:23 -0700 (PDT) Received: from james-x399.localdomain (97-118-131-57.hlrn.qwest.net. [97.118.131.57]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4dc727ae9cdsm1399218173.158.2024.10.27.19.54.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Oct 2024 19:54:23 -0700 (PDT) From: James Hilliard To: buildroot@buildroot.org Date: Sun, 27 Oct 2024 20:54:10 -0600 Message-Id: <20241028025410.62158-4-james.hilliard1@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241028025410.62158-1-james.hilliard1@gmail.com> References: <20241028025410.62158-1-james.hilliard1@gmail.com> MIME-Version: 1.0 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1730084063; x=1730688863; darn=buildroot.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=GI36vGPMmz9uTdU8J+53ysOZo6lh2N8gF1hKX8m5fUc=; b=Tr5XkThMxu3t/oXihZNP4+LhLuN/mUvq3tWfmLQzilhq0hApwgngLO/7f6GT0jQqQd l0JXeB4l2wEpte414E/ifkSv8xMpIYsy3Uu7WsXxaD8bUz014YAHIci7fasQ4BhP0pyz BQD98tkFlHvrgVYrjIIS5oBncohcK21BPCefE5bG+nTOOKlbT0UYUk9A8MxaehAT3UFN 19lVs/kvvRLZ9ipxx4rO1LpLIMtbwE8mc74uipcNyzgQfz229/h855AGPZeFYeBUKL2y 3ew+JCO/A+J/D3iXDMVikBnsgn60Xrgcv12IZaqjefpzY/LUKuRLmb7nqL4izhA5r1XC YRAw== X-Mailman-Original-Authentication-Results: smtp3.osuosl.org; dmarc=pass (p=none dis=none) header.from=gmail.com X-Mailman-Original-Authentication-Results: smtp3.osuosl.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=Tr5XkThM Subject: [Buildroot] [PATCH v3 4/4] package/protobuf-c: fix protobuf >= 26.0 compatibility X-BeenThere: buildroot@buildroot.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Marcus Folkesson , Kamel Bouhara , Marcin Niestroj , Julien Olivain , Asaf Kahlon , James Hilliard , Woodrow Douglass , Christian Stewart , Robert Rose , Fabrice Fontaine Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: buildroot-bounces@buildroot.org Sender: "buildroot" Add some patches fixing protobuf >= 26.0 compatibility. Signed-off-by: James Hilliard --- ...ct-against-being-invoked-against-edi.patch | 57 +++++++++++++ ...dSyntax-to-maximize-compatibility-ac.patch | 84 +++++++++++++++++++ ...nerateHeader-Set-min_header_version-.patch | 44 ++++++++++ 3 files changed, 185 insertions(+) create mode 100644 package/protobuf-c/0001-CGenerator-Protect-against-being-invoked-against-edi.patch create mode 100644 package/protobuf-c/0002-Reimplement-FieldSyntax-to-maximize-compatibility-ac.patch create mode 100644 package/protobuf-c/0003-FileGenerator-GenerateHeader-Set-min_header_version-.patch diff --git a/package/protobuf-c/0001-CGenerator-Protect-against-being-invoked-against-edi.patch b/package/protobuf-c/0001-CGenerator-Protect-against-being-invoked-against-edi.patch new file mode 100644 index 0000000000..c674ca2ee1 --- /dev/null +++ b/package/protobuf-c/0001-CGenerator-Protect-against-being-invoked-against-edi.patch @@ -0,0 +1,57 @@ +From 2480f4d9d2fa97e5511ed0914ee529a344e969a7 Mon Sep 17 00:00:00 2001 +From: Robert Edmonds +Date: Wed, 20 Mar 2024 22:43:30 -0400 +Subject: [PATCH] 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. + +Signed-off-by: James Hilliard +Upstream: https://github.com/protobuf-c/protobuf-c/pull/711 +--- + 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 b8b44aa..4aeb579 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 +-- +2.34.1 + diff --git a/package/protobuf-c/0002-Reimplement-FieldSyntax-to-maximize-compatibility-ac.patch b/package/protobuf-c/0002-Reimplement-FieldSyntax-to-maximize-compatibility-ac.patch new file mode 100644 index 0000000000..e14a9fbc75 --- /dev/null +++ b/package/protobuf-c/0002-Reimplement-FieldSyntax-to-maximize-compatibility-ac.patch @@ -0,0 +1,84 @@ +From ee3d9e5423c93ee6b828fdda8e7fef13a77634eb Mon Sep 17 00:00:00 2001 +From: Robert Edmonds +Date: Wed, 20 Mar 2024 22:25:54 -0400 +Subject: [PATCH] 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 + +Signed-off-by: James Hilliard +Upstream: https://github.com/protobuf-c/protobuf-c/pull/711 +--- + 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 062d330..be28b60 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 +-- +2.34.1 + diff --git a/package/protobuf-c/0003-FileGenerator-GenerateHeader-Set-min_header_version-.patch b/package/protobuf-c/0003-FileGenerator-GenerateHeader-Set-min_header_version-.patch new file mode 100644 index 0000000000..d7d9cdf845 --- /dev/null +++ b/package/protobuf-c/0003-FileGenerator-GenerateHeader-Set-min_header_version-.patch @@ -0,0 +1,44 @@ +From a6cf1aa386067e26d582cc1d1e327787595c9f13 Mon Sep 17 00:00:00 2001 +From: Robert Edmonds +Date: Wed, 20 Mar 2024 21:48:10 -0400 +Subject: [PATCH] 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. + +Signed-off-by: James Hilliard +Upstream: https://github.com/protobuf-c/protobuf-c/pull/711 +--- + 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 ca0ad34..c6d8a24 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( +-- +2.34.1 + -- 2.34.1 _______________________________________________ buildroot mailing list buildroot@buildroot.org https://lists.buildroot.org/mailman/listinfo/buildroot