Stream: general

Topic: Building WMRT on Windows


view this post on Zulip Steve Williams (Apr 28 2020 at 08:01):

Hi guys, grabbed repo, created a CMakefiles.txt.
Get this : https://pastebin.com/t80r554J
Stuck as there appears to be no wasm-micro-runtime\core\shared\platform windows subdir with the file its looking for.

noob to the system. help :)

view this post on Zulip Steve Williams (Apr 28 2020 at 08:03):

unsure where I should set WAMR_RUNTIME_LIB_SOURCE to

view this post on Zulip Steve Williams (Apr 28 2020 at 08:08):

looks like I need to set WAMR_BUILD_PLATFORM to something but to build on windows, what ? as stated, the file its looking for isn't in the tree as far as I can see.

view this post on Zulip Steve Williams (Apr 28 2020 at 08:08):

you build this on windows normally or I'm doing something new ?

view this post on Zulip bjorn3 (Apr 28 2020 at 08:11):

It indeed seems that there is no windows support yet. https://github.com/bytecodealliance/wasm-micro-runtime/blob/master/doc/port_wamr.md describes how to port WAMR though if you want to try it yourself.

WebAssembly Micro Runtime (WAMR). Contribute to bytecodealliance/wasm-micro-runtime development by creating an account on GitHub.

view this post on Zulip Steve Williams (Apr 28 2020 at 08:13):

mmmmkay :) thanks bjorn3. as wasm is in browsers & browsers run on windows that's surprising. suppose firefox & chrome use different runtimes.
can you offer any insight ? I'm wanting a wasm runtime to add to our 3D web browser to replace .net runtime & mono. thought maybe this was a good choice. then again maybe its not. unsure.

view this post on Zulip Till Schneidereit (Apr 28 2020 at 08:41):

@Steve Williams you could look into another one of our projects, Wasmtime, which works on Windows (and macOS, Linux, and some other systems) and is optimized for embedding.

Standalone JIT-style runtime for WebAssembly, using Cranelift - bytecodealliance/wasmtime

view this post on Zulip Steve Williams (Apr 28 2020 at 08:51):

hi till, I spotted wasmtime but wasn't sure what it was. does it also have an embedding API. wanting something close to mono's native interface binding. spotted this for micro-runtime. does wasmtime have similar ? thanks for your assistance.

https://github.com/bytecodealliance/wasm-micro-runtime/blob/master/doc/embed_wamr.md

WebAssembly Micro Runtime (WAMR). Contribute to bytecodealliance/wasm-micro-runtime development by creating an account on GitHub.

view this post on Zulip Till Schneidereit (Apr 28 2020 at 08:53):

It does, yes. See the documentation for a few existing embeddings, and the C embedding API here: https://github.com/bytecodealliance/wasmtime#language-support

Standalone JIT-style runtime for WebAssembly, using Cranelift - bytecodealliance/wasmtime

view this post on Zulip Steve Williams (Apr 28 2020 at 08:54):

think we have a winner - cheers :)

time to experiment. update when I have something.

view this post on Zulip Till Schneidereit (Apr 28 2020 at 08:55):

We also have support for debugging of the Wasm code with gdb/lldb, which often helps a lot with figuring out what's going wrong in embedding scenarios. Sadly no Visual Studio debugger, because that requires a completely different debug info format, but Visual Studio Code works, for example

view this post on Zulip Steve Williams (Apr 28 2020 at 08:56):

yeah, spotted the lldb stuff. looking forwards to having that running in vr :) so you can debug your 3d stuff right alongside it. not sure if gimmick or genuinely useful at this point - guess we'll see :)

view this post on Zulip Steve Williams (Apr 28 2020 at 08:59):

interesting we can use visual studio code for more traditional debugging. visual studio proper has got too big & bulky anyway. for all use cases. asking webdevs to install gigabytes to debug a basic script is one of the reasons for junking our .net assembly approach.

input appreciated & project sounds great. time to dive in :)

view this post on Zulip Till Schneidereit (Apr 28 2020 at 09:01):

Great! I'd love to hear how things are going, whether you run into issues or everything goes smoothly :slight_smile:

view this post on Zulip Steve Williams (Apr 28 2020 at 09:03):

back with questions if I get stuck :)

view this post on Zulip Steve Williams (Apr 28 2020 at 09:51):

k, installed wasmtime windows installer. it installs wasmtime.exe . no library to build against for embedding applications such as ours. having binary library & header files in that install would eliminate a pain point. so installer no use at this point, guess its back to git repo & figure out how to build what I need. ideally that would have come later. experiment first, build from scratch later is my prefered development path.

view this post on Zulip Jakub Konka (Apr 28 2020 at 09:58):

For embedding wasmtime, you might wanna check out these two crates:

Standalone JIT-style runtime for WebAssembly, using Cranelift - bytecodealliance/wasmtime
Standalone JIT-style runtime for WebAssembly, using Cranelift - bytecodealliance/wasmtime

view this post on Zulip Steve Williams (Apr 28 2020 at 10:00):

I don't do crates :) can I not get a zip with .lib & .h in it :) suppose I have to figure out this weird system.

view this post on Zulip Steve Williams (Apr 28 2020 at 10:01):

ewwww rust. this stuff has to go fast. not sold its the way.

view this post on Zulip Steve Williams (Apr 28 2020 at 10:03):

don't much care what you do under the hood. if you can get it fast in rust, fine. but I'm a straight c++ guy. I want a library and header files. the end.

hate rust syntax so not going there myself.

view this post on Zulip Jakub Konka (Apr 28 2020 at 10:03):

Oh, right. So I reckon you should checkout the repo (with the submodule) and specifically look into c-api, wasm-c-api, and wasmtime C-headers here

Standalone JIT-style runtime for WebAssembly, using Cranelift - bytecodealliance/wasmtime
Wasm C API prototype. Contribute to WebAssembly/wasm-c-api development by creating an account on GitHub.
Standalone JIT-style runtime for WebAssembly, using Cranelift - bytecodealliance/wasmtime

view this post on Zulip Jakub Konka (Apr 28 2020 at 10:04):

hahaha, I'm exactly the opposite, used to code a lot in C++ and now can't look at it. Rust is so much more readable for me :D

view this post on Zulip Jakub Konka (Apr 28 2020 at 10:05):

Anyhow, I'll try to help out here but I'm not an expert in embedding Wasmtime in other languages but Rust

view this post on Zulip Steve Williams (Apr 28 2020 at 10:06):

thanks. the bit I don't currently understand is where the library my c/c++ program links against is. a .lib file on windows.

happy to build myself. ideally from a script or cmake in the root so I don't have to learn a new system.

or ideally, the binary library would be in the windows installer, along with a simple embedding example I can build & run to verify all is ok before proceeding with development.

view this post on Zulip Steve Williams (Apr 28 2020 at 10:14):

do I use rust build thingies to get me a library I can link to from C/C++ ?

confused. not seeing an on ramp here.

view this post on Zulip Steve Williams (Apr 28 2020 at 10:24):

thus far I've got build v8 as that defines wasm-c-api, but that's not wasmtime, its the v8 runtime with all its javascript stuff too.
mozilla also have an implementation. am happy to try yours. if there's a piece of the puzzle I need that isn't ready yet, I can shelf this for a while.

view this post on Zulip Jakub Konka (Apr 28 2020 at 10:41):

I think this is what you're looking for then: wasmtime-v0.15.0-x86_64-windows-c-api.zip :-)

view this post on Zulip Jakub Konka (Apr 28 2020 at 10:41):

This archive contains both headers and static/dynamic libs

view this post on Zulip Jakub Konka (Apr 28 2020 at 10:41):

I think it comes with both .lib and .dll but you might want to verify me here :-)

view this post on Zulip Steve Williams (Apr 28 2020 at 10:41):

oh you rock, Jakub :) thanks so much :)

view this post on Zulip Jakub Konka (Apr 28 2020 at 10:41):

anytime!

view this post on Zulip Jakub Konka (Apr 28 2020 at 10:42):

lemme know how you're getting on! I'll do my best to help out the best I can!

view this post on Zulip Steve Williams (Apr 28 2020 at 10:45):

looks to be both static & dynamic linked versions there - perfect. is there also a 32 bit equivalent ? thinking of dropping our 32 bit support but I'd like that to be optional rather than forced.

view this post on Zulip Jakub Konka (Apr 28 2020 at 10:48):

Hmm, I don't think we have 32bit versions. For that, I think you'd need to build it yourself, although I wonder if it'd build just fine.

view this post on Zulip Steve Williams (Apr 28 2020 at 10:49):

looks to be 64 bit only prebuilt for now. guess we're running 64 bit :)

https://github.com/bytecodealliance/wasmtime/releases/tag/v0.15.0

32 bit has its advantages as pointers are half the size so caching better, but whatever. lets get something running.

Standalone JIT-style runtime for WebAssembly, using Cranelift - bytecodealliance/wasmtime

view this post on Zulip Steve Williams (Apr 28 2020 at 10:49):

cheers :)

view this post on Zulip Steve Williams (Apr 28 2020 at 10:50):

will work with what you have pre-built for now. if I like it, I can put the effort into how to build as I need. your 64 bit only distribution is fine for now.

many thanks.

view this post on Zulip Jakub Konka (Apr 28 2020 at 10:52):

No probs! I don't have Windows handy ATM, but if you were able to build wasmtime from sources, I could supply you with build commands to specifically build the embedding libs

view this post on Zulip Steve Williams (Apr 28 2020 at 10:57):

happy to work from pre-built for now. that lets me figure out how cool you are :)

view this post on Zulip bjorn3 (Apr 28 2020 at 11:17):

32bit support in Cranelift is a bit lacking. @whitequark did open a few PRs to improve this though.

view this post on Zulip Steve Williams (Apr 28 2020 at 12:40):

this seems out of date.

https://bytecodealliance.github.io/wasmtime/examples-c-hello-world.html

wasmtime_error_t * seems to have changed to bool

view this post on Zulip Steve Williams (Apr 28 2020 at 12:41):

fixing up as I go. comments here in case I anticipate incorrectly. feel free to bash me with the stupid stick :)

view this post on Zulip Steve Williams (Apr 28 2020 at 12:43):

not just minor, that sample's out of date. will see if I can figure it out but should be fixed up as this is for us noobs who are confused enough as it is :)

view this post on Zulip Steve Williams (Apr 28 2020 at 12:45):

or wasmtime-v0.15.0-x86_64-windows-c-api is out of date & we need a package update. don't know which as new to the code :)

view this post on Zulip Steve Williams (Apr 28 2020 at 12:46):

bjorn3: 32 bit support not critical right now. for now looking to compile embedding example. 64 bit is fine.

view this post on Zulip Steve Williams (Apr 28 2020 at 12:55):

changed too much to use right now. I need windows h/libs as provided and sample code at the same revision of the api that compiles & runs as expected to continue.

view this post on Zulip Steve Williams (Apr 28 2020 at 12:56):

thanks - being clear. almost there :)

view this post on Zulip Steve Williams (Apr 28 2020 at 13:03):

going with this instead as apparently the embed API is vendor neutral.

https://github.com/WebAssembly/wasm-c-api/blob/master/example/hello.c

compiles.

Wasm C API prototype. Contribute to WebAssembly/wasm-c-api development by creating an account on GitHub.

view this post on Zulip Steve Williams (Apr 28 2020 at 13:05):

link against your lib has following unresolved.

https://pastebin.com/JjXLCNA8

view this post on Zulip Steve Williams (Apr 28 2020 at 13:05):

My source file is .cpp. Put an extern "C" around wasm headers.

view this post on Zulip Steve Williams (Apr 28 2020 at 13:12):

ahhhh - linked to the dll rather than the static lib, contact :)

view this post on Zulip Steve Williams (Apr 28 2020 at 13:14):

don't care. dll will do. so lets see if I can do something. wasm api direct rather than your extensions is better anyhow as want to try various engines in due course & that being the point :)

the unresolved above linking to your static lib, no idea, don't care :) but fyi.

view this post on Zulip bjorn3 (Apr 28 2020 at 13:15):

Are you sure that wasmtime supports wasm-c-api? The official C api for wasmtime is at https://github.com/bytecodealliance/wasmtime/blob/master/crates/c-api/include/wasmtime.h

Standalone JIT-style runtime for WebAssembly, using Cranelift - bytecodealliance/wasmtime

view this post on Zulip Steve Williams (Apr 28 2020 at 13:19):

I'm not sure of anything. I hit this code about half an hour ago :)

view this post on Zulip Steve Williams (Apr 28 2020 at 13:19):

but it compiles & links, so lets see.

view this post on Zulip Steve Williams (Apr 28 2020 at 13:24):

bjorn3 : wasmtime_error_t is used in the wasmtime.h you just referenced (assuming that's trunk) but its not defined in wasmtime-v0.15.0-x86_64-windows-c-api.zip headers, which is why I pivoted to wasm-c-api

view this post on Zulip Benjamin Brittain (Apr 28 2020 at 13:25):

wasmtime supports the wasm-c api, not a custom one

view this post on Zulip Steve Williams (Apr 28 2020 at 13:25):

wasm_engine_new gets me an instance so I assume its working. have no clue what I'm going yet, but we continue. guessing that sample wants to load a wasm binary that I don't currently have. so need to find that :)

view this post on Zulip bjorn3 (Apr 28 2020 at 13:26):

Steve Williams said:

bjorn3 : wasmtime_error_t is used in the wasmtime.h you just referenced (assuming that's trunk) but its not defined in wasmtime-v0.15.0-x86_64-windows-c-api.zip headers, which is why I pivoted to wasm-c-api

It should be defined at https://github.com/bytecodealliance/wasmtime/blob/4d2670afa3d28e17b185b7292ddbfd5e9e4f02ba/crates/c-api/include/wasmtime.h#L15-L20 using a macro

Standalone JIT-style runtime for WebAssembly, using Cranelift - bytecodealliance/wasmtime

Last updated: Dec 23 2024 at 12:05 UTC