zigwasm / wasmtime-zig Goto Github PK
View Code? Open in Web Editor NEWZig embedding of Wasmtime
License: Apache License 2.0
Zig embedding of Wasmtime
License: Apache License 2.0
Hey,
first of all: thank you for the great work! Really happy to see a few people taking care of Zigs Wasm capabilities!
Unfortunately, this repo aged a bit, I wasn't able to make it work with zig-0.8.0 as wasm-zig is a little more ahead... Therefore I started to update this repo to make it runnable with zig-master and consequently with a recent version of the wasmtime API.
I anticipated a three-step process:
I'm currently in phase 1 and working on a PR. While gyro build
& gyro build test
already work, I'm now about to fix the examples: simple
and gcd
already work on macos, Linux and Windows examples fail to build entirely.
On Linux I get weird linking errors, which is the main reason I'm reaching out here. As macos build basically works, I see no reason why it shouldn't on Linux. However, I have no experience investigating such errors - my gut feeling tells me I either need an additional compile flag, there is an issue in wasm-zig or even an issue in the nightly of the zig version used.
Here an example of the linking errors:
gyro build run -Dexample=simple --search-prefix "$(pwd)/$WASMTIME"
$ gyro build run -Dexample=simple --search-prefix "$(pwd)/$WASMTIME"
LLD Link... ld.lld: error: undefined symbol: _Unwind_Resume
>>> referenced by wasmtime.2gagyan6-cgu.13
>>> wasmtime.wasmtime.2gagyan6-cgu.13.rcgu.o:(_$LT$smallvec..SmallVec$LT$A$GT$$u20$as$u20$core..ops..drop..Drop$GT$::drop::h0c82f3937d4ad6ba) in archive /home/ubuntu/wasmtime-zig/wasmtime-v0.24.0-x86_64-linux-c-api/lib/libwasmtime.a
>>> referenced by wasmtime.2gagyan6-cgu.13
>>> wasmtime.wasmtime.2gagyan6-cgu.13.rcgu.o:(_$LT$smallvec..SmallVec$LT$A$GT$$u20$as$u20$core..ops..drop..Drop$GT$::drop::hefb0aab2e138c30b) in archive /home/ubuntu/wasmtime-zig/wasmtime-v0.24.0-x86_64-linux-c-api/lib/libwasmtime.a
>>> referenced by wasmtime.2gagyan6-cgu.13
>>> wasmtime.wasmtime.2gagyan6-cgu.13.rcgu.o:(smallvec::SmallVec$LT$A$GT$::from_elem::hbdeff6b68cc78aa3) in archive /home/ubuntu/wasmtime-zig/wasmtime-v0.24.0-x86_64-linux-c-api/lib/libwasmtime.a
>>> referenced 2136 more times
ld.lld: error: undefined symbol: _Unwind_Backtrace
>>> referenced by libunwind.rs:90 (/rustc/cb75ad5db02783e8b0222fee363c5f63f7e2cf5b/library/std/src/../../backtrace/src/backtrace/libunwind.rs:90)
>>> std-6f77337c1826707d.std.4qsyoc55-cgu.0.rcgu.o:(_$LT$std..sys_common..backtrace.._print..DisplayBacktrace$u20$as$u20$core..fmt..Display$GT$::fmt::hf092b5883b4b2e50) in archive /home/ubuntu/wasmtime-zig/wasmtime-v0.24.0-x86_64-linux-c-api/lib/libwasmtime.a
>>> referenced by wasmtime_runtime.594lqgj0-cgu.12
>>> wasmtime_runtime-5268fe14b5b9cb0e.wasmtime_runtime.594lqgj0-cgu.12.rcgu.o:(backtrace::backtrace::trace::h6cb5f3002488cf98) in archive /home/ubuntu/wasmtime-zig/wasmtime-v0.24.0-x86_64-linux-c-api/lib/libwasmtime.a
>>> referenced by backtrace.5jl3q0p6-cgu.9
>>> backtrace-b1b27a0e5161b8ca.backtrace.5jl3q0p6-cgu.9.rcgu.o:(backtrace::backtrace::trace::hca0d710b8f9deb48) in archive /home/ubuntu/wasmtime-zig/wasmtime-v0.24.0-x86_64-linux-c-api/lib/libwasmtime.a
ld.lld: error: undefined symbol: _Unwind_GetIP
>>> referenced by libunwind.rs:43 (/rustc/cb75ad5db02783e8b0222fee363c5f63f7e2cf5b/library/std/src/../../backtrace/src/backtrace/libunwind.rs:43)
>>> std-6f77337c1826707d.std.4qsyoc55-cgu.0.rcgu.o:(std::sys_common::backtrace::_print_fmt::_$u7b$$u7b$closure$u7d$$u7d$::_$u7b$$u7b$closure$u7d$$u7d$::h76dfbe2a87a43772) in archive /home/ubuntu/wasmtime-zig/wasmtime-v0.24.0-x86_64-linux-c-api/lib/libwasmtime.a
>>> referenced by libunwind.rs:43 (/rustc/cb75ad5db02783e8b0222fee363c5f63f7e2cf5b/library/std/src/../../backtrace/src/backtrace/libunwind.rs:43)
>>> std-6f77337c1826707d.std.4qsyoc55-cgu.0.rcgu.o:(std::sys_common::backtrace::_print_fmt::_$u7b$$u7b$closure$u7d$$u7d$::hab3cbf6657151fae) in archive /home/ubuntu/wasmtime-zig/wasmtime-v0.24.0-x86_64-linux-c-api/lib/libwasmtime.a
>>> referenced by libunwind.rs:43 (/rustc/cb75ad5db02783e8b0222fee363c5f63f7e2cf5b/library/std/src/../../backtrace/src/backtrace/libunwind.rs:43)
>>> std-6f77337c1826707d.std.4qsyoc55-cgu.0.rcgu.o:(std::backtrace_rs::symbolize::gimli::resolve::hd3226e61f21019de) in archive /home/ubuntu/wasmtime-zig/wasmtime-v0.24.0-x86_64-linux-c-api/lib/libwasmtime.a
>>> referenced 10 more times
ld.lld: error: undefined symbol: _Unwind_GetDataRelBase
>>> referenced by gcc.rs:309 (/rustc/cb75ad5db02783e8b0222fee363c5f63f7e2cf5b/library/panic_unwind/src/gcc.rs:309)
>>> panic_unwind-e238540f8faf9927.panic_unwind.3kbstr8o-cgu.0.rcgu.o:(core::ops::function::FnOnce::call_once$u7b$$u7b$vtable.shim$u7d$$u7d$::h43c444d62f54d802) in archive /home/ubuntu/wasmtime-zig/wasmtime-v0.24.0-x86_64-linux-c-api/lib/libwasmtime.a
>>> referenced by gcc.rs:309 (/rustc/cb75ad5db02783e8b0222fee363c5f63f7e2cf5b/library/panic_unwind/src/gcc.rs:309)
>>> panic_unwind-e238540f8faf9927.panic_unwind.3kbstr8o-cgu.0.rcgu.o:(panic_unwind::real_imp::find_eh_action::_$u7b$$u7b$closure$u7d$$u7d$::h4fbbdfaa9a570c9c) in archive /home/ubuntu/wasmtime-zig/wasmtime-v0.24.0-x86_64-linux-c-api/lib/libwasmtime.a
ld.lld: error: undefined symbol: _Unwind_GetTextRelBase
>>> referenced by gcc.rs:308 (/rustc/cb75ad5db02783e8b0222fee363c5f63f7e2cf5b/library/panic_unwind/src/gcc.rs:308)
>>> panic_unwind-e238540f8faf9927.panic_unwind.3kbstr8o-cgu.0.rcgu.o:(core::ops::function::FnOnce::call_once$u7b$$u7b$vtable.shim$u7d$$u7d$::h46d93eef11d58b07) in archive /home/ubuntu/wasmtime-zig/wasmtime-v0.24.0-x86_64-linux-c-api/lib/libwasmtime.a
>>> referenced by gcc.rs:308 (/rustc/cb75ad5db02783e8b0222fee363c5f63f7e2cf5b/library/panic_unwind/src/gcc.rs:308)
>>> panic_unwind-e238540f8faf9927.panic_unwind.3kbstr8o-cgu.0.rcgu.o:(panic_unwind::real_imp::find_eh_action::_$u7b$$u7b$closure$u7d$$u7d$::h47fb3c2732dca9b2) in archive /home/ubuntu/wasmtime-zig/wasmtime-v0.24.0-x86_64-linux-c-api/lib/libwasmtime.a
ld.lld: error: undefined symbol: _Unwind_DeleteException
>>> referenced by gcc.rs:78 (/rustc/cb75ad5db02783e8b0222fee363c5f63f7e2cf5b/library/panic_unwind/src/gcc.rs:78)
>>> panic_unwind-e238540f8faf9927.panic_unwind.3kbstr8o-cgu.0.rcgu.o:(__rust_panic_cleanup) in archive /home/ubuntu/wasmtime-zig/wasmtime-v0.24.0-x86_64-linux-c-api/lib/libwasmtime.a
ld.lld: error: undefined symbol: _Unwind_RaiseException
>>> referenced by gcc.rs:62 (/rustc/cb75ad5db02783e8b0222fee363c5f63f7e2cf5b/library/panic_unwind/src/gcc.rs:62)
>>> panic_unwind-e238540f8faf9927.panic_unwind.3kbstr8o-cgu.0.rcgu.o:(__rust_start_panic) in archive /home/ubuntu/wasmtime-zig/wasmtime-v0.24.0-x86_64-linux-c-api/lib/libwasmtime.a
ld.lld: error: undefined symbol: _Unwind_GetLanguageSpecificData
>>> referenced by gcc.rs:300 (/rustc/cb75ad5db02783e8b0222fee363c5f63f7e2cf5b/library/panic_unwind/src/gcc.rs:300)
>>> panic_unwind-e238540f8faf9927.panic_unwind.3kbstr8o-cgu.0.rcgu.o:(rust_eh_personality) in archive /home/ubuntu/wasmtime-zig/wasmtime-v0.24.0-x86_64-linux-c-api/lib/libwasmtime.a
ld.lld: error: undefined symbol: _Unwind_GetIPInfo
>>> referenced by gcc.rs:302 (/rustc/cb75ad5db02783e8b0222fee363c5f63f7e2cf5b/library/panic_unwind/src/gcc.rs:302)
>>> panic_unwind-e238540f8faf9927.panic_unwind.3kbstr8o-cgu.0.rcgu.o:(rust_eh_personality) in archive /home/ubuntu/wasmtime-zig/wasmtime-v0.24.0-x86_64-linux-c-api/lib/libwasmtime.a
ld.lld: error: undefined symbol: _Unwind_GetRegionStart
>>> referenced by gcc.rs:307 (/rustc/cb75ad5db02783e8b0222fee363c5f63f7e2cf5b/library/panic_unwind/src/gcc.rs:307)
>>> panic_unwind-e238540f8faf9927.panic_unwind.3kbstr8o-cgu.0.rcgu.o:(rust_eh_personality) in archive /home/ubuntu/wasmtime-zig/wasmtime-v0.24.0-x86_64-linux-c-api/lib/libwasmtime.a
ld.lld: error: undefined symbol: _Unwind_SetGR
>>> referenced by gcc.rs:251 (/rustc/cb75ad5db02783e8b0222fee363c5f63f7e2cf5b/library/panic_unwind/src/gcc.rs:251)
>>> panic_unwind-e238540f8faf9927.panic_unwind.3kbstr8o-cgu.0.rcgu.o:(rust_eh_personality) in archive /home/ubuntu/wasmtime-zig/wasmtime-v0.24.0-x86_64-linux-c-api/lib/libwasmtime.a
ld.lld: error: undefined symbol: _Unwind_SetIP
>>> referenced by gcc.rs:254 (/rustc/cb75ad5db02783e8b0222fee363c5f63f7e2cf5b/library/panic_unwind/src/gcc.rs:254)
>>> panic_unwind-e238540f8faf9927.panic_unwind.3kbstr8o-cgu.0.rcgu.o:(rust_eh_personality) in archive /home/ubuntu/wasmtime-zig/wasmtime-v0.24.0-x86_64-linux-c-api/lib/libwasmtime.a
ld.lld: error: undefined symbol: __deregister_frame
>>> referenced by wasmtime_jit.38whm15l-cgu.11
>>> wasmtime_jit-64b0bceb8bfbac2b.wasmtime_jit.38whm15l-cgu.11.rcgu.o:(_$LT$wasmtime_jit..code_memory..CodeMemoryEntry$u20$as$u20$core..ops..drop..Drop$GT$::drop::hd0cb240d41257406) in archive /home/ubuntu/wasmtime-zig/wasmtime-v0.24.0-x86_64-linux-c-api/lib/libwasmtime.a
ld.lld: error: undefined symbol: __register_frame
>>> referenced by wasmtime_jit.38whm15l-cgu.11
>>> wasmtime_jit-64b0bceb8bfbac2b.wasmtime_jit.38whm15l-cgu.11.rcgu.o:(wasmtime_jit::code_memory::CodeMemory::publish::hafc3e987784edd10) in archive /home/ubuntu/wasmtime-zig/wasmtime-v0.24.0-x86_64-linux-c-api/lib/libwasmtime.a
ld.lld: error: undefined symbol: _Unwind_GetCFA
>>> referenced by backtrace.5jl3q0p6-cgu.9
>>> backtrace-b1b27a0e5161b8ca.backtrace.5jl3q0p6-cgu.9.rcgu.o:(core::ops::function::FnOnce::call_once$u7b$$u7b$vtable.shim$u7d$$u7d$::hca7bc2ec8b552c8a (.llvm.14183395609191761177)) in archive /home/ubuntu/wasmtime-zig/wasmtime-v0.24.0-x86_64-linux-c-api/lib/libwasmtime.a
>>> referenced by backtrace.5jl3q0p6-cgu.9
>>> backtrace-b1b27a0e5161b8ca.backtrace.5jl3q0p6-cgu.9.rcgu.o:(backtrace::backtrace::Frame::sp::hb8cf940b60e44949) in archive /home/ubuntu/wasmtime-zig/wasmtime-v0.24.0-x86_64-linux-c-api/lib/libwasmtime.a
>>> referenced by backtrace.5jl3q0p6-cgu.9
>>> backtrace-b1b27a0e5161b8ca.backtrace.5jl3q0p6-cgu.9.rcgu.o:(backtrace::capture::Backtrace::create::_$u7b$$u7b$closure$u7d$$u7d$::h0062f0a6638f7a48 (.llvm.14183395609191761177)) in archive /home/ubuntu/wasmtime-zig/wasmtime-v0.24.0-x86_64-linux-c-api/lib/libwasmtime.a
ld.lld: error: undefined symbol: _Unwind_FindEnclosingFunction
>>> referenced by backtrace.5jl3q0p6-cgu.9
>>> backtrace-b1b27a0e5161b8ca.backtrace.5jl3q0p6-cgu.9.rcgu.o:(core::ops::function::FnOnce::call_once$u7b$$u7b$vtable.shim$u7d$$u7d$::hca7bc2ec8b552c8a (.llvm.14183395609191761177)) in archive /home/ubuntu/wasmtime-zig/wasmtime-v0.24.0-x86_64-linux-c-api/lib/libwasmtime.a
>>> referenced by backtrace.5jl3q0p6-cgu.9
>>> backtrace-b1b27a0e5161b8ca.backtrace.5jl3q0p6-cgu.9.rcgu.o:(core::ops::function::FnOnce::call_once$u7b$$u7b$vtable.shim$u7d$$u7d$::hca7bc2ec8b552c8a (.llvm.14183395609191761177)) in archive /home/ubuntu/wasmtime-zig/wasmtime-v0.24.0-x86_64-linux-c-api/lib/libwasmtime.a
>>> referenced by backtrace.5jl3q0p6-cgu.9
>>> backtrace-b1b27a0e5161b8ca.backtrace.5jl3q0p6-cgu.9.rcgu.o:(backtrace::capture::Backtrace::create::_$u7b$$u7b$closure$u7d$$u7d$::h0062f0a6638f7a48 (.llvm.14183395609191761177)) in archive /home/ubuntu/wasmtime-zig/wasmtime-v0.24.0-x86_64-linux-c-api/lib/libwasmtime.a
>>> referenced 1 more times
error: LLDReportedFailure
simple...The following command exited with error code 1:
/usr/local/bin/zig build-exe /home/ubuntu/wasmtime-zig/examples/simple.zig -lwasmtime -lc --cache-dir /home/ubuntu/wasmtime-zig/zig-cache --global-cache-dir /root/.cache/zig --name simple --pkg-begin wasmtime /home/ubuntu/wasmtime-zig/src/main.zig --pkg-begin wasm /home/ubuntu/wasmtime-zig/.gyro/wasm-zig-zigwasm-github.com-3a96556d/pkg/src/main.zig --pkg-end --pkg-end -L /home/ubuntu/wasmtime-zig/wasmtime-v0.24.0-x86_64-linux-c-api/lib -isystem /home/ubuntu/wasmtime-zig/wasmtime-v0.24.0-x86_64-linux-c-api/include --enable-cache
The following command exited with error code 1 (expected 0):
cd . && /home/ubuntu/wasmtime-zig/zig-cache/o/c69a7c4ebdb9350db37863b2f992160c/build /usr/local/bin/zig . zig-cache /root/.cache/zig run -Dexample=simple --search-prefix /home/ubuntu/wasmtime-zig/wasmtime-v0.24.0-x86_64-linux-c-api
Windows fails as well, but I didn't spend any time investigating for now.
I'd really appreciate any idea/advice on how I to get Linux (and potentially even Windows ;) ) examples to build!
Wasmtime is getting new API rolled out: bytecodealliance/wasmtime#2897 It might be a good idea to refocus the efforts at migrating to it since it's breaking and the old one will not be supported any longer.
cc @Luukdegram
anyref
is no longer called so, it was changed to externref
some time ago.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.