- Update from version 25.2 to 28.1 - Update of rootfile - Changelog is too large to include here. Details can be found at https://github.com/protocolbuffers/protobuf/releases
Signed-off-by: Adolf Belka adolf.belka@ipfire.org --- config/rootfiles/common/protobuf | 240 ++++++++++++++++++++++++++----- lfs/protobuf | 4 +- 2 files changed, 204 insertions(+), 40 deletions(-)
diff --git a/config/rootfiles/common/protobuf b/config/rootfiles/common/protobuf index d3aa47718..3f7236b5b 100644 --- a/config/rootfiles/common/protobuf +++ b/config/rootfiles/common/protobuf @@ -1,5 +1,11 @@ #usr/bin/protoc -#usr/bin/protoc-25.2.0 +#usr/bin/protoc-28.1.0 +#usr/bin/protoc-gen-upb +#usr/bin/protoc-gen-upb-28.1.0 +#usr/bin/protoc-gen-upb_minitable +#usr/bin/protoc-gen-upb_minitable-28.1.0 +#usr/bin/protoc-gen-upbdefs +#usr/bin/protoc-gen-upbdefs-28.1.0 #usr/include/google #usr/include/google/protobuf #usr/include/google/protobuf/any.h @@ -14,9 +20,6 @@ #usr/include/google/protobuf/arenastring.h #usr/include/google/protobuf/arenaz_sampler.h #usr/include/google/protobuf/compiler -#usr/include/google/protobuf/compiler/allowlists -#usr/include/google/protobuf/compiler/allowlists/allowlist.h -#usr/include/google/protobuf/compiler/allowlists/allowlists.h #usr/include/google/protobuf/compiler/code_generator.h #usr/include/google/protobuf/compiler/command_line_interface.h #usr/include/google/protobuf/compiler/cpp @@ -28,9 +31,11 @@ #usr/include/google/protobuf/compiler/cpp/file.h #usr/include/google/protobuf/compiler/cpp/generator.h #usr/include/google/protobuf/compiler/cpp/helpers.h +#usr/include/google/protobuf/compiler/cpp/ifndef_guard.h #usr/include/google/protobuf/compiler/cpp/message.h #usr/include/google/protobuf/compiler/cpp/message_layout_helper.h #usr/include/google/protobuf/compiler/cpp/names.h +#usr/include/google/protobuf/compiler/cpp/namespace_printer.h #usr/include/google/protobuf/compiler/cpp/options.h #usr/include/google/protobuf/compiler/cpp/padding_optimizer.h #usr/include/google/protobuf/compiler/cpp/parse_function_generator.h @@ -59,37 +64,47 @@ #usr/include/google/protobuf/compiler/java #usr/include/google/protobuf/compiler/java/context.h #usr/include/google/protobuf/compiler/java/doc_comment.h -#usr/include/google/protobuf/compiler/java/enum.h -#usr/include/google/protobuf/compiler/java/enum_field.h -#usr/include/google/protobuf/compiler/java/enum_field_lite.h -#usr/include/google/protobuf/compiler/java/enum_lite.h -#usr/include/google/protobuf/compiler/java/extension.h -#usr/include/google/protobuf/compiler/java/extension_lite.h -#usr/include/google/protobuf/compiler/java/field.h +#usr/include/google/protobuf/compiler/java/field_common.h #usr/include/google/protobuf/compiler/java/file.h +#usr/include/google/protobuf/compiler/java/full +#usr/include/google/protobuf/compiler/java/full/enum.h +#usr/include/google/protobuf/compiler/java/full/enum_field.h +#usr/include/google/protobuf/compiler/java/full/extension.h +#usr/include/google/protobuf/compiler/java/full/field_generator.h +#usr/include/google/protobuf/compiler/java/full/generator_factory.h +#usr/include/google/protobuf/compiler/java/full/make_field_gens.h +#usr/include/google/protobuf/compiler/java/full/map_field.h +#usr/include/google/protobuf/compiler/java/full/message.h +#usr/include/google/protobuf/compiler/java/full/message_builder.h +#usr/include/google/protobuf/compiler/java/full/message_field.h +#usr/include/google/protobuf/compiler/java/full/primitive_field.h +#usr/include/google/protobuf/compiler/java/full/service.h +#usr/include/google/protobuf/compiler/java/full/string_field.h #usr/include/google/protobuf/compiler/java/generator.h +#usr/include/google/protobuf/compiler/java/generator_common.h #usr/include/google/protobuf/compiler/java/generator_factory.h #usr/include/google/protobuf/compiler/java/helpers.h +#usr/include/google/protobuf/compiler/java/internal_helpers.h #usr/include/google/protobuf/compiler/java/java_features.pb.h #usr/include/google/protobuf/compiler/java/kotlin_generator.h -#usr/include/google/protobuf/compiler/java/map_field.h -#usr/include/google/protobuf/compiler/java/map_field_lite.h -#usr/include/google/protobuf/compiler/java/message.h -#usr/include/google/protobuf/compiler/java/message_builder.h -#usr/include/google/protobuf/compiler/java/message_builder_lite.h -#usr/include/google/protobuf/compiler/java/message_field.h -#usr/include/google/protobuf/compiler/java/message_field_lite.h -#usr/include/google/protobuf/compiler/java/message_lite.h +#usr/include/google/protobuf/compiler/java/lite +#usr/include/google/protobuf/compiler/java/lite/enum.h +#usr/include/google/protobuf/compiler/java/lite/enum_field.h +#usr/include/google/protobuf/compiler/java/lite/extension.h +#usr/include/google/protobuf/compiler/java/lite/field_generator.h +#usr/include/google/protobuf/compiler/java/lite/generator_factory.h +#usr/include/google/protobuf/compiler/java/lite/make_field_gens.h +#usr/include/google/protobuf/compiler/java/lite/map_field.h +#usr/include/google/protobuf/compiler/java/lite/message.h +#usr/include/google/protobuf/compiler/java/lite/message_builder.h +#usr/include/google/protobuf/compiler/java/lite/message_field.h +#usr/include/google/protobuf/compiler/java/lite/primitive_field.h +#usr/include/google/protobuf/compiler/java/lite/string_field.h #usr/include/google/protobuf/compiler/java/message_serialization.h #usr/include/google/protobuf/compiler/java/name_resolver.h #usr/include/google/protobuf/compiler/java/names.h #usr/include/google/protobuf/compiler/java/options.h -#usr/include/google/protobuf/compiler/java/primitive_field.h -#usr/include/google/protobuf/compiler/java/primitive_field_lite.h -#usr/include/google/protobuf/compiler/java/service.h #usr/include/google/protobuf/compiler/java/shared_code_generator.h -#usr/include/google/protobuf/compiler/java/string_field.h -#usr/include/google/protobuf/compiler/java/string_field_lite.h #usr/include/google/protobuf/compiler/objectivec #usr/include/google/protobuf/compiler/objectivec/enum.h #usr/include/google/protobuf/compiler/objectivec/enum_field.h @@ -108,7 +123,7 @@ #usr/include/google/protobuf/compiler/objectivec/oneof.h #usr/include/google/protobuf/compiler/objectivec/options.h #usr/include/google/protobuf/compiler/objectivec/primitive_field.h -#usr/include/google/protobuf/compiler/objectivec/text_format_decode_data.h +#usr/include/google/protobuf/compiler/objectivec/tf_decode_data.h #usr/include/google/protobuf/compiler/parser.h #usr/include/google/protobuf/compiler/php #usr/include/google/protobuf/compiler/php/names.h @@ -125,18 +140,23 @@ #usr/include/google/protobuf/compiler/ruby/ruby_generator.h #usr/include/google/protobuf/compiler/rust #usr/include/google/protobuf/compiler/rust/accessors -#usr/include/google/protobuf/compiler/rust/accessors/accessor_generator.h +#usr/include/google/protobuf/compiler/rust/accessors/accessor_case.h #usr/include/google/protobuf/compiler/rust/accessors/accessors.h +#usr/include/google/protobuf/compiler/rust/accessors/default_value.h +#usr/include/google/protobuf/compiler/rust/accessors/generator.h #usr/include/google/protobuf/compiler/rust/context.h +#usr/include/google/protobuf/compiler/rust/crate_mapping.h +#usr/include/google/protobuf/compiler/rust/enum.h #usr/include/google/protobuf/compiler/rust/generator.h #usr/include/google/protobuf/compiler/rust/message.h #usr/include/google/protobuf/compiler/rust/naming.h #usr/include/google/protobuf/compiler/rust/oneof.h #usr/include/google/protobuf/compiler/rust/relative_path.h +#usr/include/google/protobuf/compiler/rust/rust_field_type.h +#usr/include/google/protobuf/compiler/rust/rust_keywords.h #usr/include/google/protobuf/compiler/scc.h #usr/include/google/protobuf/compiler/subprocess.h #usr/include/google/protobuf/compiler/versions.h -#usr/include/google/protobuf/compiler/versions_suffix.h #usr/include/google/protobuf/compiler/zip_writer.h #usr/include/google/protobuf/cpp_edition_defaults.h #usr/include/google/protobuf/cpp_features.pb.h @@ -144,8 +164,11 @@ #usr/include/google/protobuf/descriptor.h #usr/include/google/protobuf/descriptor.pb.h #usr/include/google/protobuf/descriptor.proto +#usr/include/google/protobuf/descriptor.upb.h +#usr/include/google/protobuf/descriptor.upb_minitable.h #usr/include/google/protobuf/descriptor_database.h #usr/include/google/protobuf/descriptor_legacy.h +#usr/include/google/protobuf/descriptor_lite.h #usr/include/google/protobuf/descriptor_visitor.h #usr/include/google/protobuf/duration.pb.h #usr/include/google/protobuf/duration.proto @@ -171,7 +194,6 @@ #usr/include/google/protobuf/has_bits.h #usr/include/google/protobuf/implicit_weak_message.h #usr/include/google/protobuf/inlined_string_field.h -#usr/include/google/protobuf/internal_message_util.h #usr/include/google/protobuf/internal_visibility.h #usr/include/google/protobuf/io #usr/include/google/protobuf/io/coded_stream.h @@ -216,8 +238,11 @@ #usr/include/google/protobuf/reflection_internal.h #usr/include/google/protobuf/reflection_mode.h #usr/include/google/protobuf/reflection_ops.h +#usr/include/google/protobuf/reflection_visit_field_info.h +#usr/include/google/protobuf/reflection_visit_fields.h #usr/include/google/protobuf/repeated_field.h #usr/include/google/protobuf/repeated_ptr_field.h +#usr/include/google/protobuf/runtime_version.h #usr/include/google/protobuf/serial_arena.h #usr/include/google/protobuf/service.h #usr/include/google/protobuf/source_context.pb.h @@ -231,6 +256,8 @@ #usr/include/google/protobuf/stubs/platform_macros.h #usr/include/google/protobuf/stubs/port.h #usr/include/google/protobuf/stubs/status_macros.h +#usr/include/google/protobuf/testing +#usr/include/google/protobuf/testing/file.h #usr/include/google/protobuf/text_format.h #usr/include/google/protobuf/thread_safe_arena.h #usr/include/google/protobuf/timestamp.pb.h @@ -256,11 +283,147 @@ #usr/include/java/core #usr/include/java/core/src #usr/include/java/core/src/main -#usr/include/java/core/src/main/java -#usr/include/java/core/src/main/java/com -#usr/include/java/core/src/main/java/com/google -#usr/include/java/core/src/main/java/com/google/protobuf -#usr/include/java/core/src/main/java/com/google/protobuf/java_features.proto +#usr/include/java/core/src/main/resources +#usr/include/java/core/src/main/resources/google +#usr/include/java/core/src/main/resources/google/protobuf +#usr/include/java/core/src/main/resources/google/protobuf/java_features.proto +#usr/include/upb +#usr/include/upb/base +#usr/include/upb/base/descriptor_constants.h +#usr/include/upb/base/internal +#usr/include/upb/base/internal/endian.h +#usr/include/upb/base/internal/log2.h +#usr/include/upb/base/status.h +#usr/include/upb/base/status.hpp +#usr/include/upb/base/string_view.h +#usr/include/upb/base/upcast.h +#usr/include/upb/generated_code_support.h +#usr/include/upb/hash +#usr/include/upb/hash/common.h +#usr/include/upb/hash/int_table.h +#usr/include/upb/hash/str_table.h +#usr/include/upb/json +#usr/include/upb/json/decode.h +#usr/include/upb/json/encode.h +#usr/include/upb/lex +#usr/include/upb/lex/atoi.h +#usr/include/upb/lex/round_trip.h +#usr/include/upb/lex/strtod.h +#usr/include/upb/lex/unicode.h +#usr/include/upb/mem +#usr/include/upb/mem/alloc.h +#usr/include/upb/mem/arena.h +#usr/include/upb/mem/arena.hpp +#usr/include/upb/mem/internal +#usr/include/upb/mem/internal/arena.h +#usr/include/upb/message +#usr/include/upb/message/accessors.h +#usr/include/upb/message/array.h +#usr/include/upb/message/compare.h +#usr/include/upb/message/compat.h +#usr/include/upb/message/copy.h +#usr/include/upb/message/internal +#usr/include/upb/message/internal/accessors.h +#usr/include/upb/message/internal/array.h +#usr/include/upb/message/internal/compare_unknown.h +#usr/include/upb/message/internal/extension.h +#usr/include/upb/message/internal/iterator.h +#usr/include/upb/message/internal/map.h +#usr/include/upb/message/internal/map_entry.h +#usr/include/upb/message/internal/map_sorter.h +#usr/include/upb/message/internal/message.h +#usr/include/upb/message/internal/tagged_ptr.h +#usr/include/upb/message/internal/types.h +#usr/include/upb/message/map.h +#usr/include/upb/message/map_gencode_util.h +#usr/include/upb/message/merge.h +#usr/include/upb/message/message.h +#usr/include/upb/message/tagged_ptr.h +#usr/include/upb/message/value.h +#usr/include/upb/mini_descriptor +#usr/include/upb/mini_descriptor/build_enum.h +#usr/include/upb/mini_descriptor/decode.h +#usr/include/upb/mini_descriptor/internal +#usr/include/upb/mini_descriptor/internal/base92.h +#usr/include/upb/mini_descriptor/internal/decoder.h +#usr/include/upb/mini_descriptor/internal/encode.h +#usr/include/upb/mini_descriptor/internal/encode.hpp +#usr/include/upb/mini_descriptor/internal/modifiers.h +#usr/include/upb/mini_descriptor/internal/wire_constants.h +#usr/include/upb/mini_descriptor/link.h +#usr/include/upb/mini_table +#usr/include/upb/mini_table/enum.h +#usr/include/upb/mini_table/extension.h +#usr/include/upb/mini_table/extension_registry.h +#usr/include/upb/mini_table/field.h +#usr/include/upb/mini_table/file.h +#usr/include/upb/mini_table/internal +#usr/include/upb/mini_table/internal/enum.h +#usr/include/upb/mini_table/internal/extension.h +#usr/include/upb/mini_table/internal/field.h +#usr/include/upb/mini_table/internal/file.h +#usr/include/upb/mini_table/internal/message.h +#usr/include/upb/mini_table/internal/size_log2.h +#usr/include/upb/mini_table/internal/sub.h +#usr/include/upb/mini_table/message.h +#usr/include/upb/mini_table/sub.h +#usr/include/upb/port +#usr/include/upb/port/atomic.h +#usr/include/upb/port/def.inc +#usr/include/upb/port/undef.inc +#usr/include/upb/port/vsnprintf_compat.h +#usr/include/upb/reflection +#usr/include/upb/reflection/common.h +#usr/include/upb/reflection/def.h +#usr/include/upb/reflection/def.hpp +#usr/include/upb/reflection/def_pool.h +#usr/include/upb/reflection/def_type.h +#usr/include/upb/reflection/enum_def.h +#usr/include/upb/reflection/enum_reserved_range.h +#usr/include/upb/reflection/enum_value_def.h +#usr/include/upb/reflection/extension_range.h +#usr/include/upb/reflection/field_def.h +#usr/include/upb/reflection/file_def.h +#usr/include/upb/reflection/internal +#usr/include/upb/reflection/internal/def_pool.h +#usr/include/upb/reflection/internal/desc_state.h +#usr/include/upb/reflection/internal/enum_def.h +#usr/include/upb/reflection/internal/enum_reserved_range.h +#usr/include/upb/reflection/internal/enum_value_def.h +#usr/include/upb/reflection/internal/extension_range.h +#usr/include/upb/reflection/internal/field_def.h +#usr/include/upb/reflection/internal/file_def.h +#usr/include/upb/reflection/internal/message_def.h +#usr/include/upb/reflection/internal/message_reserved_range.h +#usr/include/upb/reflection/internal/method_def.h +#usr/include/upb/reflection/internal/oneof_def.h +#usr/include/upb/reflection/internal/service_def.h +#usr/include/upb/reflection/internal/upb_edition_defaults.h +#usr/include/upb/reflection/message.h +#usr/include/upb/reflection/message.hpp +#usr/include/upb/reflection/message_def.h +#usr/include/upb/reflection/message_reserved_range.h +#usr/include/upb/reflection/method_def.h +#usr/include/upb/reflection/oneof_def.h +#usr/include/upb/reflection/service_def.h +#usr/include/upb/text +#usr/include/upb/text/encode.h +#usr/include/upb/text/internal +#usr/include/upb/text/internal/encode.h +#usr/include/upb/text/options.h +#usr/include/upb/util +#usr/include/upb/util/def_to_proto.h +#usr/include/upb/util/required_fields.h +#usr/include/upb/wire +#usr/include/upb/wire/decode.h +#usr/include/upb/wire/encode.h +#usr/include/upb/wire/eps_copy_input_stream.h +#usr/include/upb/wire/internal +#usr/include/upb/wire/internal/decode_fast.h +#usr/include/upb/wire/reader.h +#usr/include/upb/wire/types.h +#usr/include/upb_generator +#usr/include/upb_generator/mangle.h #usr/include/utf8_range.h #usr/include/utf8_validity.h #usr/lib/cmake/protobuf @@ -276,13 +439,14 @@ #usr/lib/cmake/utf8_range/utf8_range-targets-noconfig.cmake #usr/lib/cmake/utf8_range/utf8_range-targets.cmake #usr/lib/libprotobuf-lite.so -#usr/lib/libprotobuf-lite.so.25.2.0 +#usr/lib/libprotobuf-lite.so.28.1.0 #usr/lib/libprotobuf.so -#usr/lib/libprotobuf.so.25.2.0 +#usr/lib/libprotobuf.so.28.1.0 #usr/lib/libprotoc.so -#usr/lib/libprotoc.so.25.2.0 -#usr/lib/libutf8_range.a -#usr/lib/libutf8_validity.a +#usr/lib/libprotoc.so.28.1.0 +#usr/lib/libupb.a +#usr/lib/libutf8_range.so +#usr/lib/libutf8_validity.so #usr/lib/pkgconfig/protobuf-lite.pc #usr/lib/pkgconfig/protobuf.pc #usr/lib/pkgconfig/utf8_range.pc diff --git a/lfs/protobuf b/lfs/protobuf index 5258fc192..368e58123 100644 --- a/lfs/protobuf +++ b/lfs/protobuf @@ -24,7 +24,7 @@
include Config
-VER = 25.2 +VER = 28.1
THISAPP = protobuf-$(VER) DL_FILE = $(THISAPP).tar.gz @@ -40,7 +40,7 @@ objects = $(DL_FILE)
$(DL_FILE) = $(DL_FROM)/$(DL_FILE)
-$(DL_FILE)_BLAKE2 = 1ee7a48d3a481f523ff240c79e8cacb39b6a7e2c671279812cbffd5ce9be595034461fba41f03bed363133118c1b92bd14bcfd8c4e46ac6368e6407a23fb02ea +$(DL_FILE)_BLAKE2 = 908dd074cc4ef632efdf123fdc76e6d78fd0db13d580584f00fd6afd3b5e1b6d3b6b52e49c528d4095905c802dcf0f391b01d2edf872738ed11a70c1123258a9
install : $(TARGET)
- 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 adolf.belka@ipfire.org --- 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 edmonds@users.noreply.github.com +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 edmonds@users.noreply.github.com +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 <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 { +@@ -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 +