-
Notifications
You must be signed in to change notification settings - Fork 4
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
Support Apple silicon #101
Comments
Hi @ivangreene Thank you for the report. Unfortunately, this is a long-standing issue that we are very much aware of. The original developers wrote the build script used for this project. The file is quite messy and will most likely be rewritten from scratch soon. The way it works is it builds for only one specified OS and architecture at a time. At the same time, when we build for release we do it locally on one of our machines, before publishing to Maven Central. Since we use only one machine with specific specs, we can only reliably compile for the x86_64 architecture. We plan to address this by migrating our build, test and release to GitHub actions, which will allow us to support a wider range of architectures. Currently, the only way to work around the issue is to compile the JAR yourself locally and include it in your project. Since you are running this on MacOS you would need to modify the <plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>3.1.1</version>
<executions>
<!-- OMITTED FOR BREVITY -->
<execution>
<id>build-shared-object-library-macos</id>
<phase>compile</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>python3</executable>
<workingDirectory>${project.basedir}</workingDirectory>
<arguments>
<argument>build.py</argument>
+ <argument>-a</argument>
+ <argument>aarch64</argument>
<argument>-o</argument>
<argument>${project.build.outputDirectory}/libjava-tree-sitter</argument>
</arguments>
</configuration>
</execution>
<!-- OMITTED FOR BREVITY -->
</executions>
</plugin> Since you are compiling locally for just MacOS, you can also skip the Linux compilation entirely: <plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>3.1.1</version>
<!-- OMITTED FOR BREVITY -->
<execution>
<id>build-shared-object-library-linux</id>
<phase>compile</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
+ <skip>true</skip>
<!-- OMITTED FOR BREVITY -->
</configuration>
</execution>
</executions>
</plugin> I'll keep the issue open for the moment, but it might be superseded by a more general one in the future. |
Thanks, looking forward to a build with both architectures in the future. As a note, the build works as-is locally because the build.py determines the host's architecture, so didn't need to add the argument in the pom |
Trying to load the dylib on Apple silicon gives this error:
Important part being
(mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64'))
This is revealed with lipo:
It should be possible to create a universal binary using something like this method: https://developer.apple.com/documentation/apple-silicon/building-a-universal-macos-binary#Update-the-Architecture-List-of-Custom-Makefiles
The text was updated successfully, but these errors were encountered: