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

Use native aarch64 graphANNIS service on Apple Silicon instead of reying on emulation #884

Merged
merged 1 commit into from
Feb 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Fixed

- Use native aarch64 graphANNIS service on Apple Silicon instead of relying on emulation.
- Updated to graphANNIS 3.6.0
- Updated Java dependencies to fix security issues

Expand Down
19 changes: 17 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
<swagger-core-version>1.5.24</swagger-core-version>
<gson-fire-version>1.8.4</gson-fire-version>
<kotlin.version>1.6.0</kotlin.version>
<commons-lang3.version>3.13.0</commons-lang3.version>
<commons-lang3.version>3.17.0</commons-lang3.version>
</properties>

<repositories>
Expand Down Expand Up @@ -281,7 +281,22 @@
</configuration>
</execution>
<execution>
<id>download-mac-binaries</id>
<id>download-apple-silicon-macos-binaries</id>
<phase>generate-resources</phase>
<goals>
<goal>wget</goal>
</goals>
<configuration>
<url>
https://github.com/korpling/graphANNIS/releases/download/v${graphannis.version}/graphannis-webservice-aarch64-apple-darwin.tar.xz</url>
<outputDirectory>
${project.build.directory}/native/</outputDirectory>
<sha256>658ae2ab56d69a800625d463161a0578e04023abc4640981acc198d85b14f3c7</sha256>
<unpack>true</unpack>
</configuration>
</execution>
<execution>
<id>download-intel-macos-binaries</id>
<phase>generate-resources</phase>
<goals>
<goal>wget</goal>
Expand Down
35 changes: 19 additions & 16 deletions src/main/java/org/corpus_tools/annis/gui/ServiceStarter.java
Original file line number Diff line number Diff line change
Expand Up @@ -120,20 +120,10 @@ private void startService() {
// Start the process and read output/error stream in background threads
log.info("Starting the bundled graphANNIS service with configuration file {}",
serviceConfigFile.getAbsolutePath());
ProcessBuilder backgroundProcessBuilder;

if (SystemUtils.IS_OS_MAC_OSX) {
// On MacOS has several processor architectors, but allows to emulate x86_64 processors
// with the Rosetta tool. We use the `arch` helper program to trigger emulation if
// necessary. This is necessary when Java support the native processor architecture and
// thus is not emulated yet.
backgroundProcessBuilder = new ProcessBuilder("arch", "-x86_64",
tmpExec.getAbsolutePath(), "--config", serviceConfigFile.getAbsolutePath());

} else {
backgroundProcessBuilder = new ProcessBuilder(tmpExec.getAbsolutePath(), "--config",
serviceConfigFile.getAbsolutePath());
}
ProcessBuilder backgroundProcessBuilder = new ProcessBuilder(tmpExec.getAbsolutePath(),
"--config",
serviceConfigFile.getAbsolutePath());

backgroundProcess = backgroundProcessBuilder.start();

// Create threads that read from the output and error streams and add the messages to
Expand Down Expand Up @@ -164,8 +154,21 @@ private void startService() {
private Optional<String> executablePathForSystem() {
Optional<String> execPath = Optional.empty();
if (SystemUtils.IS_OS_MAC_OSX) {
execPath = Optional.of("graphannis-webservice-x86_64-apple-darwin/graphannis-webservice");
} else if ("amd64".equals(SystemUtils.OS_ARCH) || "x86_64".equals(SystemUtils.OS_ARCH)) {
// MacOS 64 bit architecture includes the newer Apple Silicon chips and the old Intel ones,
// but not AMD
if ("aarch64".equals(SystemUtils.OS_ARCH)) {
execPath = Optional.of("graphannis-webservice-aarch64-apple-darwin/graphannis-webservice");
} else if ("x86_64".equals(SystemUtils.OS_ARCH)) {
execPath = Optional.of("graphannis-webservice-x86_64-apple-darwin/graphannis-webservice");
} else {
log.error(
"GraphANNIS can only be run on 64 bit operating systems (\"x86_64\" or \"aarch64\") "
+ "and with a 64 bit version of Java, "
+ "but this is reported as architecture {}!",
SystemUtils.OS_ARCH);
}
} else if ("x86_64".equals(SystemUtils.OS_ARCH) || "amd64".equals(SystemUtils.OS_ARCH)) {
// ARM is not supported on Linux/Windows yet, but the other 64 bit architectures are
if (SystemUtils.IS_OS_LINUX) {
execPath =
Optional.of("graphannis-webservice-x86_64-unknown-linux-gnu/graphannis-webservice");
Expand Down
Loading