-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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. |
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 |
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! |
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: