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

Why are compiler osx-aarch_64.exe for Apple chips and osx-x86_64.exe for Intel chips the same file? #11844

Open
evil0th opened this issue Jan 22, 2025 · 1 comment
Labels

Comments

@evil0th
Copy link

evil0th commented Jan 22, 2025

Why are protoc-gen-grpc-java compiler osx-aarch_64.exe for Apple chips and osx-x86_64.exe for Intel chips the same file?

  • When I run the protobuf-maven-plugin plugin, I get an error:
[ERROR] PROTOC FAILED: /Users/xxx/Code/demo/spring-boot-grpc/target/protoc-plugins/protoc-gen-grpc-java-1.69.1-osx-aarch_64.exe: program not found or is not executable
Please specify a program using absolute path or make sure the program is available in your PATH system variable
--grpc-java_out: protoc-gen-grpc-java: Plugin failed with status code 1.

[ERROR] /Users/xxx/Code/demo/spring-boot-grpc/src/main/proto/hello.proto [0:0]: /Users/xxx/Code/demo/spring-boot-grpc/target/protoc-plugins/protoc-gen-grpc-java-1.69.1-osx-aarch_64.exe: program not found or is not executable
Please specify a program using absolute path or make sure the program is available in your PATH system variable
--grpc-java_out: protoc-gen-grpc-java: Plugin failed with status code 1.
  • The osx-aarch_64.exe I downloaded from the Maven repository does not run properly and reports an error:
protoc-gen-grpc-java-1.69.1-osx-aarch_64.exe: Bad CPU type in executable
  • The protoc-gen-grpc-java I installed through Homebrew can run normally under Apple chips and generate code correctly.

Please see that the Ruby source code protoc-gen-grpc-java formula installed by brew does not perform special processing on the gradle script.

  def install
    # Workaround for newer Protobuf to link to Abseil libraries
    # Ref: https://github.com/grpc/grpc-java/issues/11475
    ENV.append "CXXFLAGS", "-std=c++17"
    ENV.append "CXXFLAGS", Utils.safe_popen_read("pkgconf", "--cflags", "protobuf").chomp
    ENV.append "LDFLAGS", Utils.safe_popen_read("pkgconf", "--libs", "protobuf").chomp

    inreplace "compiler/build.gradle" do |s|
      # Avoid build errors on ARM macOS from old minimum macOS deployment
      s.gsub! '"-mmacosx-version-min=10.7",', ""
      # Avoid static linkage on Linux
      s.gsub! '"-Wl,-Bstatic"', "\"-L#{Formula["protobuf"].opt_lib}\""
      s.gsub! ', "-static-libgcc"', ""
    end

    # Fails with brew `gradle` due to animalsniffer 1.7.1
    # Ref: https://github.com/xvik/gradle-animalsniffer-plugin/issues/100
    system "./gradlew", "--no-daemon", "--project-dir=compiler", "-PskipAndroid=true", "java_pluginExecutable"
    bin.install "compiler/build/exe/java_plugin/protoc-gen-grpc-java"

    pkgshare.install "examples/src/main/proto/helloworld.proto"
  end

What is the reason why the target files of two different architectures are the same after uploading to the Maven repository?

Can this be solved so that we can run it correctly through the protobuf-maven-plugin plugin to automatically generate code?

@kannanjgithub
Copy link
Contributor

Can you provide the plugin config for protobuf-maven-plugin that you use (example)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants