Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test build of #711 with #714 #715

Closed

Conversation

edmonds
Copy link
Member

@edmonds edmonds commented Apr 22, 2024

Testing #714 on top of #711, do not merge.

edmonds and others added 9 commits March 20, 2024 23:33
…ally

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.
…ersions

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
…roto 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.
The CMake module is used by default but isn't compatible with
recent protobuf version.

Try to first look for a protobuf config then fallback to legacy
cmake module.

Signed-off-by: Clément Péron <peron.clem@gmail.com>
APT cache could be out of date leading to a:
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?

Fix this by always calling apt-get update before an apt-get install.

Signed-off-by: Clément Péron <peron.clem@gmail.com>
Keep the DART compatibility enabled until test are moved
to CTest.

Signed-off-by: Clément Péron <peron.clem@gmail.com>
PROTOBUF_PROTOC_EXECUTABLE is not set in the Protobuf CMake config file.
Set it properly in case we use CMake protobuf config file.

Signed-off-by: Clément Péron <peron.clem@gmail.com>
@coveralls
Copy link

coveralls commented Apr 22, 2024

Coverage Status

coverage: 90.313%. remained the same
when pulling 86a89d1 on edmonds/test/google-protobuf-26-fixes_plus_pull-714
into 5c13d7d on next.

@edmonds edmonds mentioned this pull request Apr 22, 2024
@edmonds edmonds force-pushed the edmonds/test/google-protobuf-26-fixes_plus_pull-714 branch from 27c10cf to fdd163f Compare April 22, 2024 03:12
This job builds abseil-cpp and protobuf from source using Cmake and
tries to build protobuf-c against those dependencies using Cmake.

The "latest" build dependencies are being targeted, currently Ubuntu
22.04, abseil-cpp from the lts_2024_01_16 branch, protobuf from the 27.x
branch. Update as newer versions become available.

This uses Cmake's Ninja generator which should be equivalent to the
legacy makefiles that it generates. The Cmake Ninja generator is useful
primarily because it automatically compiles using the maximum amount
of concurrency and it actually shows you the command that failed by
default.
@edmonds edmonds force-pushed the edmonds/test/google-protobuf-26-fixes_plus_pull-714 branch from fdd163f to 9bdd24f Compare April 22, 2024 03:36
@edmonds edmonds closed this Apr 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants