kawamuray / wasmtime-java

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

Build shared library for Apple Silicon #51

Closed rob-odwyer closed 1 year ago

rob-odwyer commented 1 year ago

This adds support for an aarch64 build of the shared library, and updates the NativeLibraryLoader to load it on macOS when the os.arch system property is aarch64.

Although it's pretty straightforward to build for this architecture, running the tests is a lot more complex so I've disabled them when cross-compiling for now. It looks like bytecodealliance/wasmtime uses qemu to solve this problem for some architectures, but it's not as simple as just setting a target.

rob-odwyer commented 1 year ago

Updated the build.gradle and the loading logic to use the following paths (grabbed these from a tagged build on the fork to confirm):

$ file jni-libs/*
jni-libs/libwasmtime_jni_0.17.0_linux_x86_64.so:     ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=fe48cb0c3ace952c7619e0e498399475cf0ddd98, with debug_info, not stripped
jni-libs/libwasmtime_jni_0.17.0_macos_aarch64.dylib: Mach-O 64-bit dynamically linked shared library arm64
jni-libs/libwasmtime_jni_0.17.0_macos_x86_64.dylib:  Mach-O 64-bit dynamically linked shared library x86_64
jni-libs/wasmtime_jni_0.17.0_windows_x86_64.dll:     PE32+ executable (DLL) (GUI) x86-64, for MS Windows

On #36 - I think my timing was just lucky! I didn't run into any cross-compilation issues, so it must have been fixed upstream.