Coder Social home page Coder Social logo

wasmedge-go-examples's Introduction

WasmEdge-Go Examples

The WasmEdge is a high performance WebAssembly runtime optimized for server side applications. The WasmEdge-Go provides a golang package for accessing to WasmEdge.

Getting Started

Before trying the examples, the WasmEdge installation is required. The WasmEdge extensions are built for Linux platforms. For the Windows and MacOS users, there is only the WasmEdge without extensions can be installed.

This repository contains examples of WasmEdge-Go.

wasmedge-go-examples's People

Contributors

juntao avatar q82419 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

wasmedge-go-examples's Issues

go_BindgenFuncs doesn't work

Try the example from
https://github.com/second-state/WasmEdge-go-examples/tree/master/go_BindgenFuncs

Env

my env: Ubuntu 20.04 LTS
go version go1.19.4 linux/amd64
rustc 1.66.0 (69f9c33d7 2022-12-12)
wasmedge version 0.11.2

Problem 1

if I build the bindgen_funcs and run with the wasm provided by the repo itself. I get this error

./bindgen_funcs rust_bindgen_funcs_lib_bg.wasm
[2022-12-21 02:38:32.641] [error] loading failed: invalid path, Code: 0x20
[2022-12-21 02:38:32.641] [error]     File name: "/home/clin4/github/WasmEdge-go-examples/wasmedge-bindgen/go_BindgenFuncs/rust_bindgen_funcs_lib_bg.wasm"
[2022-12-21 02:38:32.641] [error] wasmedge runtime failed: wrong VM workflow, Code: 0x04
[2022-12-21 02:38:32.642] [error] wasmedge runtime failed: wrong VM workflow, Code: 0x04
[2022-12-21 02:38:32.642] [error] execution failed: wrong instance address, Code: 0x80
[2022-12-21 02:38:32.642] [error]     When executing function name: "allocate"
Run bindgen -- create_line FAILED wrong instance address
[2022-12-21 02:38:32.642] [error] execution failed: wrong instance address, Code: 0x80
[2022-12-21 02:38:32.642] [error]     When executing function name: "allocate"
Run bindgen -- say FAILED
[2022-12-21 02:38:32.642] [error] execution failed: wrong instance address, Code: 0x80
[2022-12-21 02:38:32.642] [error]     When executing function name: "allocate"
Run bindgen -- obfusticate FAILED
[2022-12-21 02:38:32.642] [error] execution failed: wrong instance address, Code: 0x80
[2022-12-21 02:38:32.642] [error]     When executing function name: "allocate"
Run bindgen -- lowest_common_multiple FAILED
[2022-12-21 02:38:32.642] [error] execution failed: wrong instance address, Code: 0x80
[2022-12-21 02:38:32.642] [error]     When executing function name: "allocate"
Run bindgen -- sha3_digest FAILED
[2022-12-21 02:38:32.642] [error] execution failed: wrong instance address, Code: 0x80
[2022-12-21 02:38:32.642] [error]     When executing function name: "allocate"
Run bindgen -- keccak_digest FAILED

problem 2

If i build the rust wasm myself, I will get a different error

cargo build --target wasm32-wasi --release
./bindgen_funcs  2.wasm
[2022-12-21 02:47:46.618] [error] instantiation failed: unknown import, Code: 0x62
[2022-12-21 02:47:46.619] [error]     When linking module: "wasmedge-bindgen" , function name: "return_error"
[2022-12-21 02:47:46.619] [error]     At AST node: import description
[2022-12-21 02:47:46.619] [error]     At AST node: import section
[2022-12-21 02:47:46.619] [error]     At AST node: module
[2022-12-21 02:47:46.619] [error] execution failed: wrong instance address, Code: 0x80
[2022-12-21 02:47:46.619] [error]     When executing function name: "allocate"
Run bindgen -- create_line FAILED wrong instance address
[2022-12-21 02:47:46.619] [error] execution failed: wrong instance address, Code: 0x80
[2022-12-21 02:47:46.619] [error]     When executing function name: "allocate"
Run bindgen -- say FAILED
[2022-12-21 02:47:46.619] [error] execution failed: wrong instance address, Code: 0x80
[2022-12-21 02:47:46.619] [error]     When executing function name: "allocate"
Run bindgen -- obfusticate FAILED
[2022-12-21 02:47:46.619] [error] execution failed: wrong instance address, Code: 0x80
[2022-12-21 02:47:46.619] [error]     When executing function name: "allocate"
Run bindgen -- lowest_common_multiple FAILED
[2022-12-21 02:47:46.619] [error] execution failed: wrong instance address, Code: 0x80
[2022-12-21 02:47:46.619] [error]     When executing function name: "allocate"
Run bindgen -- sha3_digest FAILED
[2022-12-21 02:47:46.619] [error] execution failed: wrong instance address, Code: 0x80
[2022-12-21 02:47:46.619] [error]     When executing function name: "allocate"
Run bindgen -- keccak_digest FAILED

Any help will be highly appreciate!

unknown import, Code: 0x62

I'm using the bindgen example to run my rust code. I have followed all steps to setup my environment.

❯ ./bindgen_funcs rust_bindgen_funcs/pkg/rust_bindgen_funcs_lib_bg.wasm
[2022-06-01 18:17:59.023] [error] instantiation failed: unknown import, Code: 0x62
[2022-06-01 18:17:59.023] [error]     When linking module: "env" , function name: "return_error"
[2022-06-01 18:17:59.023] [error]     At AST node: import description
[2022-06-01 18:17:59.023] [error]     At AST node: import section
[2022-06-01 18:17:59.023] [error]     At AST node: module
[2022-06-01 18:17:59.023] [error] execution failed: wrong instance address, Code: 0x80
[2022-06-01 18:17:59.023] [error]     When executing function name: "__wbindgen_malloc"
panic: toWasmEdgeValueSlideBindgen(): malloc failed

goroutine 1 [running]:
github.com/second-state/WasmEdge-go/wasmedge.toWasmEdgeValueSlideBindgen(0x4ae7e6?, 0x4ae7e6?, 0x0, {0xc00005cf40, 0x3, 0x7fc023bc0a68?})
        /home/ME/go/pkg/mod/github.com/second-state/[email protected]/wasmedge/value.go:321 +0xa85
github.com/second-state/WasmEdge-go/wasmedge.(*VM).ExecuteBindgen(0xc00019e060?, {0x4ae7e6, 0xa}, 0xc0000506b0?, {0xc00005cf40, 0x3, 0x3})
        /home/ME/go/pkg/mod/github.com/second-state/[email protected]/wasmedge/vm.go:275 +0xf8
main.main()
        /home/ME/MY-PROJECT/bindgen/bindgen_funcs.go:40 +0x30

unfortunately I cannot make sense on any of those errors.

EDIT:

I now followed the instructions in joey to install everthing and now face

./bindgen_funcs: symbol lookup error: ./bindgen_funcs: undefined symbol: WasmEdge_ModuleInstanceListMemory

Run example get fatal error: 'wasmedge.h' file not found

After run

$ cd go_ExternRef
$ go get -u github.com/second-state/WasmEdge-go
$ go build

I got follwing error:

# github.com/second-state/WasmEdge-go/wasmedge
/Users/zc/go/pkg/mod/github.com/second-state/[email protected]/wasmedge/ast.go:3:11: fatal error: 'wasmedge.h' file not found
 #include <wasmedge.h>
          ^~~~~~~~~~~~
1 error generated.

I am using go version go1.17.2 darwin/amd64.

fatal error: wasmedge/wasmedge.h: No such file or directory

Hello,

I am trying to run this example https://wasmedge.org/book/en/sdk/go/memory.html#pass-strings-to-tinygo-functions
with go1.19.3 linux/amd64

I wrapped the code in unit test, got error when trying to run it:

vitvlkv@emc2:~/tp/backend/indicators/tpi_worker/junk$ go test ./run_wasmedge/
# github.com/second-state/WasmEdge-go/wasmedge
/home/vitvlkv/go/pkg/mod/github.com/second-state/[email protected]/wasmedge/ast.go:3:11: fatal error: wasmedge/wasmedge.h: No such file or directory
    3 | // #include <wasmedge/wasmedge.h>
      |           ^~~~~~~~~~~~~~~~~~~~~
compilation terminated.
FAIL    gitlab.takeprofit.team/backend/indicators/tpi_worker/junk/run_wasmedge [build failed]
FAIL

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.