kawamuray / wasmtime-java

Java or JVM-language binding for Wasmtime
Apache License 2.0
127 stars 29 forks source link

Include aarch64-apple-darwin builds of libwasmtime_jni #36

Open dakota-doordash opened 2 years ago

dakota-doordash commented 2 years ago

Currently, only x86_64 darwin builds of libwasmtime_jni are included in the package. This causes issues on M1 Macs in which the library needs to be manually built for aarch64 darwin. Could aarch64 darwin builds also be included?

kawamuray commented 2 years ago

It's not easy for now as github actions doesn't provide M1 mac as an execution environment. We might be able to cross-build a shared library for aarch64 without any tests executed, but as far as I tried the build now fails due to the compilation errors from the stage building C library for zstd-sys which is transitively dependent by wasmtime crate. (cargo build --target aarch64-apple-darwin)

So for now, there's no easy way to build a shared library for aarch64-apple-darwin on github actions.

syedfaizanalef commented 2 years ago

@kawamuray is there any workaround?

kawamuray commented 2 years ago

@syedfaizanalef The situation remain the same. Github actions still does not support aarch64 mac, and compiling for the aarch64-apple-drawin on an intel mac fails by zstd-sys, even with latest dependency versions.

The workaround is to build this project (precisely, wasmtime-jni subproject. Just run cargo build --release) on an apple silicon mac by yourself, and use a built shared object (by -Djava.library.path) instead of those shipped with the official jar.

krisbitney commented 1 year ago

Is it possible to use something like this to build on more architectures? https://github.com/marketplace/actions/run-on-architecture

Also, this Mozilla Gradle plugin makes it easier to build for Android: https://github.com/mozilla/rust-android-gradle

kawamuray commented 1 year ago

Is it possible to use something like this to build on more architectures? https://github.com/marketplace/actions/run-on-architecture

Looks like an option, but it seems that we need to write entire build process as shell script, requiring some effort as in currently the ci.yml is written with leveraging a lot of actions.

krisbitney commented 1 year ago

When i get time, i will look at it and see if i can update the build script to build to work seamlessly with arm architectures

krisbitney commented 1 year ago

I haven't tried it yet, but this sounds promising:

https://actually.fyi/posts/zig-makes-rust-cross-compilation-just-work/

cch0 commented 1 year ago

I am also interested in this subject since I am using M1 for development but need to use this library for other OS and platforms.

What I have tried and found out is that we can still use ubuntu-22.04 and macos-12 to build for targets such as aarch64-unknown-linux-gnu and aarch64-apple-darwin, respectively.

The other tool I also looked at is cross.