Skip to content

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

Closed
@evil0th

Description

@evil0th

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions