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
protoc-gen-grpc-java not available on apple m1 #7690
protoc-gen-grpc-java not available on apple m1 #7690
Comments
Yes, we do not produce binaries for arm64 macs. Edit: Summary of the long issue: The easiest thing to do as a consumer is to install Rosetta. With it installed, the Intel binary works fine. If you'd like to contribute, see #7690 (comment) . Easiest plan is to build protobuf and the grpc plugin as universal binaries. |
Since this is the grpc repo, I've called out protoc-gen-grpc-java not being available. Although your actual error is protoc itself, which would be part of the protobuf project. If grpc gets to building it first, then we'd need to add support in protobuf as well. |
Hi @ejona86 |
To manually specify the classifier, for Gradle:
I'm less familiar with the Maven plugin, but I think it may be something like:
You can do the same for protoc-gen-grpc-java. |
Thanks @ejona86 . That worked out. |
Thanks @ejona86 , But How can I keep other platform like linux-x86_64 when the project being compiled on other platform? |
You can also use project properties to only change the behavior when explicitly requested. |
Thanks! Finally, I made it by
|
for me, add this to <settings>
...
<activeProfiles>
<activeProfile>
apple-silicon
</activeProfile>
...
</activeProfiles>
<profiles>
<profile>
<id>apple-silicon</id>
<properties>
<os.detected.classifier>osx-x86_64</os.detected.classifier>
</properties>
</profile>
...
</profiles>
...
</settings> |
Can you share the full setting.xml |
@Uditmittal
in my
I think you can define and use variables in maven to implement this feature. Good luck |
@Uditmittal My settings.xml is awfully long, the key is using your property overwrite |
@guyeu my seetings.xml file |
@Uditmittal This is my <configuration>
<protocArtifact>
com.google.protobuf:protoc:3.1.0:exe:${os.detected.classifier}
</protocArtifact>
<pluginId>grpc-java</pluginId>
<pluginArtifact>io.grpc:protoc-gen-grpc-java:1.0.0:exe:${os.detected.classifier}</pluginArtifact>
</configuration> |
Thanks, it works for me. |
谢谢老哥,搞定了 |
I'm not at all impressed with how hard it was to find the appropriate flags to pass to clang to make a universal binary, but it appears to be |
Just a workaround. Track grpc/grpc-java#7690 and protocolbuffers/protobuf#8557 for permanent fix
@ejona86 Have you had any success building from source for AArch64? I am interested in helping moving this along... |
@jjones-figure, no, as I said, I don't have a Mac, so I can't really help much here. We totally build from source for AArch64 already on Linux. But it is a different toolchain for M1. |
protocolbuffers/protobuf#8557 just went into protobuf based on my suggestion to just copy the current x86 binary to an arm64 name until we have actual M1 support. That doesn't "fix" this, but it does resolve the main user-visible issues and doesn't turn out to be too hacky. I think that is as simple as making a copy of the "exe" and the hashes/signature in our upload_artifacts.sh script. |
Fixes compilation on M1 macOS. Check grpc/grpc-java#7690 for further info Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
Fixes compilation on M1 macOS. Check grpc/grpc-java#7690 for further info Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
It's easy to build the native protoc-gen-grpc-java-$VER-osx-aarch_64.exe with Bazel on a macbook m1/m2, even you can backfill the old versions for your project's backward compatibility, e.g. $VER=1.31.1
(I didn't try building higher versions, please reply if you meet any issues in the above steps) I also tried building grpc_java_plugin with Gradle. No problem of running
Tried configuring |
谢谢您的来信!
|
Use x86_64 protobuf compilers on macOS until protobuf is updated to a newer version (~3.21.0). See grpc/grpc-java#7690 for more background.
Use x86_64 protobuf compilers on macOS until protobuf is updated to a newer version (~3.21.0). See grpc/grpc-java#7690 for more background.
Fixes compilation on M1 macOS. Check grpc/grpc-java#7690 for further info Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
zsh: bad CPU type in executable: ./protoc-gen-grpc-java-osx-aarch_64.exe can not executable on mac m2 chips |
谢谢您的来信!
|
where i can find this .m2/settings.xml |
similar issue i am facing |
|
@JackyAnn, it should work on M2 as well, as long as you have Rosetta installed. |
@hu-chia simple、useful、effective! |
谢谢您的来信!
|
<properties>
<os.detected.classifier>osx-x86_64</os.detected.classifier>
</properties> |
This is going to have to be fixed. Apple has not shipped x86 processors for a year. Going by their past switch, from Power -> x86, it will only be a couple years before they stop shipping Rosetta. Edit: |
This works for me |
Fixes compilation on M1 macOS. Check grpc/grpc-java#7690 for further info Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
thanks that's work |
March 2024. My build started working when I installed Rosetta. I'm using the Gradle protobuf plugin and did not need to change the Gradle build scripts. I echo the comments above, it would be good to have native binaries before the drop-dead date. Another note, it seems this is already done for the protoc compiler itself, only the gRPC plugin is causing problems. I have three modules using protoc, only one of which also uses the gRPC plugin. The others just use base protoc and they built fine without needing to install Rosetta. Can the same approach that was used for the base protoc be replicated here? |
@martin-traverse, protobuf's release build used to be like ours. But they changed it dramatically and it is now based on Bazel. Looks like they are using We are using autotools right now to build protobuf, and then using Gradle to build the plugin. But we've not been able to absorb the absl dependency in newer protobuf versions. I have a change to swap to cmake to build protobuf, but pkg-config is now required and that caused trouble on Windows. More recently pkgconf has taken off, so we might now have a solution there. Since absl was added to protobuf, I have considered moving the plugin compilation out of Gradle. That could be a stepping-stone to using Bazel. But I think that is too much to depend on here. I still believe this just needs a few flags when building (like #7690 (comment), or the |
it didn't work for me |
Body: Environment Steps to Reproduce `protobuf { dependencies { plugins { Expected Behavior Actual Behavior |
any update on this issue? everyone is on M1/M2 chips these days. |
M2 Macbook Air. build.gradle protobuf { if you want to create docker image. FROM jdk as gradle_cache and dockerbuild.sh |
What version of gRPC-Java are you using?
1.34.0
What is your environment?
osx 11.0.1
What did you expect to see?
build success
What did you see instead?
Steps to reproduce the bug
mvn protobuf:compile
The text was updated successfully, but these errors were encountered: