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

Bump Protobuf to 3.19.1 which is is Mac M1 osx-aarch_64 compatible. #8724

Closed
toffentoffen opened this issue Nov 24, 2021 · 4 comments
Closed
Assignees

Comments

@toffentoffen
Copy link

toffentoffen commented Nov 24, 2021

What version of gRPC-Java are you using?

gRPC-java version 1.42.1

What is your environment?

Mac M1 aarch_64

% java -version
openjdk version "1.8.0_312"
OpenJDK Runtime Environment (Zulu 8.58.0.13-CA-macos-aarch64) (build 1.8.0_312-b07)
OpenJDK 64-Bit Server VM (Zulu 8.58.0.13-CA-macos-aarch64) (build 25.312-b07, mixed mode)

What did you expect to see?

Release 1.42.1 generates osx-aarch_64 compatible artifacts.
However the protobuf version used is 3.17.2 which does not have a compatible osx-aarch_64.
From the release 1.42.1 notes:

compiler: Protoc plugin for macOS x86 is duplicated to be used on the aarch architecture, to ease use on arm64 macs. The plugin is not actually ARM64, just named as such. Future work will need to compile it appropriately #8680

I seems that this release will work correctly with arm64 macs. Probably I understood it wrongly.

What I expect is that using the latest grpc-java arm64 mac compatible and using the latest protoc 3.19.1 which is "compatible" with arm64 mac, I can generate valid code.

What did you see instead?

As I was using a newer compiler, for arm64 compatibility reasons, It was generating code that depends on methods that are not available in the current grpc-java used protobuf 3.17.2 version.

error: cannot find symbol
    if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(appId_)) {
                                               ^
  symbol:   method isStringEmpty(Object)
  location: class GeneratedMessageV3

Steps to reproduce the bug

If you try to compile the well know helloworld.proto bundled in protoc, you will get the error mentioned previously.

I am using the current suggested protobuf-maven-pluginto generate code. However I need to dump up the protocArtifact to 3.19.1 to use a aarm64 mac compatible artifact.

<protocArtifact>com.google.protobuf:protoc:3.19.1:exe:${os.detected.classifier}</protocArtifact>

Workaround

Use protoc 3.17.3 which does include osx-aarch_64 based maven artifacts

@ejona86
Copy link
Member

ejona86 commented Dec 2, 2021

However the protobuf version used is 3.17.2 which does not have a compatible osx-aarch_64.

You are free to depend on the newer version of protobuf yourself, and then you can use the newer protoc. You should be able to upgrade dependencies to newer versions (with same major version) without issue (the main exception where I wouldn't be surprised if there are issues is bumping the patch version of Netty/tcnative).

@toffentoffen
Copy link
Author

toffentoffen commented Dec 3, 2021

Right if I understood it correctly I can depend on newer versions. The tricky part is to find the right combination of protoc version, protobuf-java, and grpc-java. For the latest grpc-java version, to make it work with the latest protoc & protobuf-java combination, it will be needed to "override" (using maven's dependencyManagement) grpc-java dependencie to protobuf-java, to use the same version (that protoc protobuf-java needs) instead of the one that it depends on. Mainly because the generated code from protoc is not compatible with the protobuf-java version grpc-java depends on (3.17.2).

@ejona86
Copy link
Member

ejona86 commented Dec 3, 2021

The tricky part is to find the right combination of protoc version, protobuf-java, and grpc-java

The easiest thing is to just use the same version of protobuf for protoc and protobuf-java, and use at least the version used by grpc-java.

it will be needed to "override" (using maven's dependencyManagement)

No need to use dependencyManagement. Just add a direct dependency on protobuf-java and Maven will prefer that version over the transitive dependencies defined by grpc. I do suggest always using mavenEnforcer's requireUpperBoundDeps, however, as Maven happily downgrades transitive dependencies which just asks for trouble.

@ejona86
Copy link
Member

ejona86 commented Dec 9, 2021

Seems like this is resolved. If not, comment, and it can be reopened.

@ejona86 ejona86 closed this as completed Dec 9, 2021
@ejona86 ejona86 removed this from the Next milestone Dec 9, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 10, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants