Thanks, good to know at least 2 people would read a post about this :) I'll try to find time for it.
About Rust, I haven't had time to look into it yet. My general hope is that the same model as for C and Zig could work: 1. Tell Rust to use the emscripten wasm triple. 2. Tell Rust to compile to object files (or a static library, basically), and *not* to link them. 3. The user runs emcc on those object files, linking them. The nice thing in this model is that C/Zig/Rust does not need to be aware of emcc at all here (aside from telling LLVM to use the emscripten triple). And it's easy to do this, at least in C and Zig (although there are some subtle ABI questions). This is actually the main thing I wanted to do before writing the post - ideally I'd have a Rust demo alongside C and Zig - so if someone figures that out, let me know! - Alon On Thu, Jan 13, 2022 at 2:06 AM Александр Гурьянов <caiiiy...@gmail.com> wrote: > +1 for blog post. Not clear how I can use it with rust, e.g. can I compile > static lib with target --wasm32-unknown-unknown and then link using > emscripten? The main problem with RUST is that it even can't compile with > --wasm32-unknown-emscipten (because of lib dependencies that not support > emscripten) > > чт, 13 янв. 2022 г. в 16:46, Floh <flo...@gmail.com>: > >> That's a very useful gist, Alon! I think that blog post would be much >> appreciated by a lot of people who like to tinker with other languages :) >> >> On Wednesday, 12 January 2022 at 19:32:04 UTC+1 alon...@gmail.com wrote: >> >>> On Sat, Dec 25, 2021 at 6:02 AM Floh <flo...@gmail.com> wrote: >>> >>>> Ah, language and toolchain interoperability, one of my favourite topics >>>> ;) >>>> >>>> Zig has nearly the same problems as Rust: it allows to compile to WASM, >>>> it has both a WASI and Emscripten target, with the WASI target working out >>>> of the box, but I gave up on the Emscripten target because I just couldn't >>>> get it to work. >>>> >>> >>> I wrote up a demo of Zig + Emscripten here: >>> >>> https://gist.github.com/kripken/58c0e640227fe5bac9e7b30100a2a1d3 >>> >>> That uses GLES3 and Asyncify from Emscripten, so it's a small program >>> but it uses interesting features. >>> >>> The gist also shows using C in the same way, where Emscripten is just >>> the linker, not the frontend. >>> >>> I've been meaning to do the same with Rust and write a blogpost about >>> all 3 but haven't found the time... >>> >>> - Alon >>> >>> >>> >>>> >>>> IMHO it would be great if the Javascript shims and interop could be >>>> somehow split out of the Emscripten SDK into a separate, smaller >>>> "webapi-wasm-tools" SDK which could be better integrated with other >>>> language toolchains. The goal should be that other programming languages >>>> can benefit from the work that went into the Emscripten SDK to access web >>>> APIs like WebGL, WebGPU, WebAudio etc... up to "EM_JS()" functionality, >>>> instead of having to duplicate this work, or requiring a separate >>>> installation of the whole Emscripten SDK. >>>> >>>> There's a very promising project https://github.com/schellingb/wajic >>>> by Bernhard Schelling which has the same goals and which was used to port >>>> Mattias Gustavsson's DOS-like library to the web: >>>> https://mattiasgustavsson.com/wasm/ >>>> >>>> Anyway... just my 2 cents :) >>>> -Floh. >>>> On Friday, 24 December 2021 at 15:16:23 UTC+1 caiiiycuk wrote: >>>> >>>>> Hi! Just want to share my experiment with using Rust and WebAssembly. >>>>> I tried to port Vange-rs project (rust + wgpu) to browser. I used >>>>> emscripten and unknown platforms. Both finally works, but have lot of >>>>> obstacles. I am very sad about support level of emscripten in Rust, hope >>>>> it >>>>> will change at some day. >>>>> >>>>> https://caiiiycuk.medium.com/vange-rs-webassembly-in-rust-498e2f960a04 >>>>> >>>> -- >>>> >>> You received this message because you are subscribed to the Google >>>> Groups "emscripten-discuss" group. >>>> To unsubscribe from this group and stop receiving emails from it, send >>>> an email to emscripten-disc...@googlegroups.com. >>>> >>> To view this discussion on the web visit >>>> https://groups.google.com/d/msgid/emscripten-discuss/99cc45ea-2307-4551-94b8-ecff9ad965a0n%40googlegroups.com >>>> <https://groups.google.com/d/msgid/emscripten-discuss/99cc45ea-2307-4551-94b8-ecff9ad965a0n%40googlegroups.com?utm_medium=email&utm_source=footer> >>>> . >>>> >>> -- >> You received this message because you are subscribed to the Google Groups >> "emscripten-discuss" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to emscripten-discuss+unsubscr...@googlegroups.com. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/emscripten-discuss/9e88b4b5-f110-4d90-a630-1c282a1febffn%40googlegroups.com >> <https://groups.google.com/d/msgid/emscripten-discuss/9e88b4b5-f110-4d90-a630-1c282a1febffn%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> > -- > You received this message because you are subscribed to the Google Groups > "emscripten-discuss" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to emscripten-discuss+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/emscripten-discuss/CAKOm%3DVFgNcSPR-KFe35yg%2BU9NXFpG7U_Y5G0APbkZRf5UM2%2B8w%40mail.gmail.com > <https://groups.google.com/d/msgid/emscripten-discuss/CAKOm%3DVFgNcSPR-KFe35yg%2BU9NXFpG7U_Y5G0APbkZRf5UM2%2B8w%40mail.gmail.com?utm_medium=email&utm_source=footer> > . > -- You received this message because you are subscribed to the Google Groups "emscripten-discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-discuss+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/emscripten-discuss/CAEX4NpRH1%2BxWEaTbjTvnk5kE5W4XwUjHefP8g1psk-pUvxVAtg%40mail.gmail.com.