#Yossi #multithreading Python in #WASM with #Emscripten and #Pyodide, using #CORS to enable SharedArrayBuffer. #concurrency #toread #gross
on 02026-04-28#speech synthesis in #MicroPython using DECtalk (?) on a #Raspberry-Pi #RP2040 and a so-called SYN6988, or in #Emscripten. Or categorizing birds with BirdNET-Pi #neural-networks.
on 02023-07-13some hoops to jump through to get #Emscripten #wasm to load in #React #JS
on 02023-06-24oh hey, #Emscripten uses #SDL for I/O!
on 02023-06-24Mozilla's #Emscripten #wasm #tutorial.
on 02023-06-23"WAjic" is a simplified alternative to #Emscripten which, like Emscripten, generates #wasm from C with LLVM 8.0.0 or greater with clang -target wasm32 foo.c -o foo.wasm and a lot of other options. Also apparently #Node 8 and newer support wasm. WAjic is written in Node. The main missing feature seems to be setjmp.
This is where the #Emscripten docs explain how to read #wasm memory from #JS with Module.HEAPU8.set(myTypedArray, ptr) or getValue(ptr, type) or setValue(ptr, value, type).
A different way to enable C compiled with #Emscripten to call #JS is to add JS functions to library.js or LibraryManager.library and pass your JS to emcc with the option --js-library. This seems like a potentially cleaner way to handlle the JS/C split for APIs that have to cross the boundary.
#Emscripten exports Module.ccall and Module.cwrap functions to #JS for calling into #Wasm code.
the main reference for #Emscripten's "Asyncify" setup, which automatically determines the color of each C function (Promise-colored or synchronous), typically adding 50% overhead
on 02023-06-22#Emscripten has an asynchronous emscripten_dlopen function to dynamically load a library from an URL.
#Emscripten has an emscripten_hide_mouse function for hiding the OS mouse cursor, but I guess nothing that can warp the hidden cursor like for mouselook in Minetest.
#Emscripten has an emscripten_set_main_loop function you're supposed to run in order to get #JS to call your C code from requestAnimationFrame or periodically.
#Emscripten has an emscripten_run_script function to eval arbitrary #JS generated by the C it compiled! Unless -sDYNAMIC_EXECUTION=0 is set.
#Emscripten supports writing #JS functions in your C with EM_JS. If the arguments are int32_t, double, or NUL-terminated C strings, it translates them for you automatically, but pointers are treated as integers the JS can index HEAP8, HEAPU8, HEAP32, etc., with. String return values get malloced. There's also EM_ASM for inline JS, which has some trouble with commas that can be worked around with extra parens. EM_ASM_INT, EM_ASM_PTR, etc., also permit return values.
#Emscripten has a thing called "Asyncify" to compile your C into explicit continuation-passing style so you can do things like emscripten_sleep and a blocking emscripten_wget.
there's an #Emscripten #Docker image you can use to compile C to #Wasm with commands like docker run --rm -v "$PWD":/src -u "$(id -u):$(id -g)" emscripten/emsdk emcc hello.c -o hello.js
building #webassembly with the #Emscripten compiler
on 02021-01-13