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 · 4 comments
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)?

@tliechti
Copy link

tliechti commented Jan 22, 2025

I run into the same on a Apple M4 with MacOS 15.2 while compiling https://github.com/grpc/grpc-java/examples with

 ➜  examples git:(v1.69.0) ./gradlew installDist
> Task :generateProto FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':generateProto'.
> protoc: stdout: . stderr:  ....... protoc-gen-grpc-java-1.69.0-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_out: protoc-gen-grpc: Plugin failed with status code 1.

File is on indicated location:

-rwxr--r--@ 1 ....  staff  6221952 22 Jan 16:25 protoc-gen-grpc-java-1.69.0-osx-aarch_64.exe`

Running it:

./protoc-gen-grpc-java-1.69.0-osx-aarch_64.exe
zsh: bad CPU type in executable: ......../protoc-gen-grpc-java-1.69.0-osx-aarch_64.exe

@evil0th
Copy link
Author

evil0th commented Jan 23, 2025

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

maven build config:

<build>
  <plugins>
    <plugin>
      <groupId>kr.motd.maven</groupId>
      <artifactId>os-maven-plugin</artifactId>
      <version>1.7.1</version>
      <executions>
        <execution>
          <id>initialize</id>
          <phase>initialize</phase>
          <goals>
            <goal>detect</goal>
          </goals>
        </execution>
      </executions>
    </plugin>
    <plugin>
      <groupId>org.xolstice.maven.plugins</groupId>
      <artifactId>protobuf-maven-plugin</artifactId>
      <version>0.6.1</version>
      <configuration>
        <protocArtifact>com.google.protobuf:protoc:3.25.5:exe:${os.detected.classifier}</protocArtifact>
        <pluginId>grpc-java</pluginId>
        <pluginArtifact>io.grpc:protoc-gen-grpc-java:1.69.1:exe:${os.detected.classifier}</pluginArtifact>
      </configuration>
      <executions>
        <execution>
          <id>compile</id>
          <goals>
            <goal>compile</goal>
            <goal>compile-custom</goal>
          </goals>
          <configuration>
            <pluginParameter>jakarta_omit,@generated=omit</pluginParameter>
          </configuration>
        </execution>
      </executions>
    </plugin>
  </plugins>
</build>

@evil0th
Copy link
Author

evil0th commented Jan 23, 2025

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

Central Repository: io/grpc/protoc-gen-grpc-java/1.69.1 Files of osx-aarch_64 architecture and osx-x86_64 architecture, both md5/sha content and exe size are exactly the same.

Image

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

3 participants