second-state / WasmEdge-go

The GO language SDK and API for WasmEdge
https://www.secondstate.io/articles/extend-golang-app-with-webassembly-rust/
Apache License 2.0
107 stars 16 forks source link

arm64 support #41

Closed brennanjl closed 1 year ago

brennanjl commented 1 year ago

When running this, I am getting the following warning:

ld: warning: ignoring file ~/.wasmedge/lib/libwasmedge.dylib, building for macOS-arm64 but attempting to link with file built for macOS-x86_64

I then get a long stack trace, and the errors:

ld: symbol(s) not found for architecture arm64 clang: error: linker command failed with exit code 1 (use -v to see invocation)

AFAIK this means that I have to rebuild this library for my architecture. I can't seem to find where to do this in the docs, is this supported?

brennanjl commented 1 year ago

Update: it seems this was a known issue a while ago, as found here: https://github.com/second-state/WasmEdge-go/issues/18

The issue still occurs for me.

hydai commented 1 year ago

Hi @brennanjl Thanks for raising this issue. How did you install the wasmedge library? We provide both aarch64 and x86_64 libraries for macOS. But the error message shows that ld is trying to link with different arch versions.

brennanjl commented 1 year ago

I installed by running curl -sSf https://raw.githubusercontent.com/WasmEdge/WasmEdge/master/utils/install.sh | bash -s -- -e all, as found here: https://wasmedge.org/book/en/quick_start/install.html.

I am able to use the tool just fine; if I have a wasm file called main.wasm, I can run wasmedge main.wasm and it works as expected. The issue seems to be when using this SDK.

It could be a local configuration issue for CGo, I am unsure.

brennanjl commented 1 year ago

I've taken a look through all of the files in ~/.wasmedge/lib directory and they all seem to be built for x86_64

Edit: It also seems that my wasmedge executable is for x86_84. I am not sure how it is running on my machine (I guess using Rosetta 2?), but this could be why it is not working in cgo.

brennanjl commented 1 year ago

Got it working. Here's a recap for anyone else who might run into this:

hydai commented 1 year ago

Hi @brennanjl Could you try to run the installer with -D? Because I cannot reproduce the result on my M2 MacBook.

Here is the command I used:

$ curl -sSf https://raw.githubusercontent.com/WasmEdge/WasmEdge/master/utils/install.sh | bash -s -- -D

...omitted...
DEBUG   - CONST_release_pkg: darwin_arm64.tar.gz
DEBUG   - CONST_ipkg: WasmEdge-0.12.1-Darwin
DEBUG   - CONST_lib_ext: .dylib
DEBUG   - CONST_urls: {'WasmEdge': 'https://github.com/WasmEdge/WasmEdge/releases/download/0.12.1/WasmEdge-0.12.1-darwin_arm64.tar.gz', 'WasmEdge_Uninstaller': 'https://raw.githubusercontent.com/WasmEdge/WasmEdge/0.12.1/utils/uninstall.sh', 'image': 'https://github.com/second-state/WasmEdge-image/releases/download/0.12.1/WasmEdge-image-0.12.1-darwin_arm64.tar.gz', 'tensorflow_deps': 'https://github.com/second-state/WasmEdge-tensorflow-deps/releases/download/0.12.1/WasmEdge-tensorflow-deps-TF-0.12.1-darwin_arm64.tar.gz', 'tensorflow_lite_deps': 'https://github.com/second-state/WasmEdge-tensorflow-deps/releases/download/0.12.1/WasmEdge-tensorflow-deps-TFLite-0.12.1-darwin_arm64.tar.gz', 'tensorflow': 'https://github.com/second-state/WasmEdge-tensorflow/releases/download/0.12.1/WasmEdge-tensorflow-0.12.1-darwin_arm64.tar.gz', 'tensorflow_lite': 'https://github.com/second-state/WasmEdge-tensorflow/releases/download/0.12.1/WasmEdge-tensorflowlite-0.12.1-darwin_arm64.tar.gz', 'tensorflow_tools': 'https://github.com/second-state/WasmEdge-tensorflow-tools/releases/download/0.12.1/WasmEdge-tensorflow-tools-0.12.1-darwin_arm64.tar.gz'}
...omitted...

$ find ~/.wasmedge/* -name '*.dylib' | xargs -I X file X

/Users/hydai/.wasmedge/lib/libwasmedge.0.dylib: Mach-O 64-bit dynamically linked shared library arm64
/Users/hydai/.wasmedge/lib/libwasmedge.dylib: Mach-O 64-bit dynamically linked shared library arm64
/Users/hydai/.wasmedge/lib/libwasmedge.0.0.2.dylib: Mach-O 64-bit dynamically linked shared library arm64