-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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. |
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 |
thx a lot. only one way it worked! |
Oh, it seems I hit this again, trying to download osx-aarch64 file only to find out it's actually a Mach-0 x86_64 binary: grpc/grpc.io#1296 |
protobuf {
protoc {
if (osdetector.os == "osx") {
artifact = 'com.google.protobuf:protoc:3.14.0:osx-x86_64'
} else {
artifact = 'com.google.protobuf:protoc:3.14.0'
}
}
} I have pasted this code, and I have received another error.
|
@Ivan-Kurochenko There is no such file on that location, is it? See https://repo.maven.apache.org/maven2/io/grpc/protoc-gen-grpc-java/1.28.1/ If you upgrade to e.g. https://repo.maven.apache.org/maven2/io/grpc/protoc-gen-grpc-java/1.64.0/ you can see there is an osx-aarch_64 file now. The problem is though that it is in fact x86_64 binary and your aarch64 system won't run it:
So you'd need to have Rosetta installed so as your Mac OS can translate amd64 machine code do aarch64 machine code... |
@Karm I installed Rosetta.
|
@Karm Do you have another idea, of how I can get rid of the protoc.3.13 for arm? |
@Ivan-Kurochenko I am sorry, I don't understand the question. |
i dont use Rosetta and this one work for me
after |
For M1 chip, I had to install rosetta to make it work.
|
i read https://github.com/grpc/grpc-java/releases/tag/v1.62.2
What is the change ? |
Is there any solution without hack for this? It works adding specific value as mentioned above, |
@gharia, you don't need to do any os.detected.classifier hacks. Just make sure Rosetta is installed on OS X arm machines and use releases from 2022 or newer. |
I have Rosetta installed and protoc version is 27.1
|
@ejona86 , could you help with this? Let me know if I am missing anything here |
I notice the protobuf 4.x have been supported . It is great! |
Thanks @shalk those changes worked for. However I am using Protobuf version 3.25.3. I am on M2 chip |
@gharia, you don't say what problem you are experiencing. What error do you get? Our examples work on Rosetta-available OS X ARM64 systems. Try the Quick Start. It uses configuration essentially the same as shalk posted, but with protobuf 3.25.3. It's also essentially the same configuration as our main README.md. @shalk, protobuf 4 still has an issue: protocolbuffers/protobuf#17247 |
@ejona86 , I was using older version of Protobuf release (before 2022 as you mentioned) in pom.xml Below is my working pom.xml
|
Execute this command in terminal to install Rosetta 2: Specify pom as osx-x86_64 type, reference: <plugin>
<groupId>org.xolstice.maven.plugins</groupId>
<artifactId>protobuf-maven-plugin</artifactId>
<version>0.6.1</version>
<configuration>
<protocArtifact>
com.google.protobuf:protoc:3.5.1:exe:osx-x86_64
</protocArtifact>
<pluginId>grpc-java</pluginId>
<pluginArtifact>
io.grpc:protoc-gen-grpc-java:1.13.1:exe:osx-x86_64
</pluginArtifact>
<protoSourceRoot>src/main/proto</protoSourceRoot>
</configuration>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>compile-custom</goal>
</goals>
</execution>
</executions>
</plugin> Hope this helps! |
FWIW - I was able to get this working on an M3 w/ arm64 architecture. The only change I made was explicitly setting JAVA_HOME to a JDK version of 11 or higher. Setting to JDK 8, it does indeed require the x86_64 |
FYI, homebrew added protoc-gen-grpc-java formula recently and it works for the arm build for apache-pulsar 4.0.0 apple arm build, Homebrew/homebrew-core#199494 |
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: