On Fri, Mar 4, 2022 at 10:50 PM Александр Гурьянов <[email protected]> wrote:
> It compiles with flags -sSHARED_MEMORY=1 -sUSE_PTHREADS=1, but it didn't > start in worker: > > wdosbox.js:6935 Uncaught (in promise) LinkError: > WebAssembly.instantiate(): Import #46 module="env" > function="emscripten_unwind_to_js_event_loop" error: function import > requires a callable > That function is defined in `library/library_eventloop.js` are you using the emcc-generated JS library code? Can you share your entire link command that you are using the build module? > I checked there is no such function on info.env, maybe it's incompatible > with -s ASYNCIFY=1? > > сб, 5 мар. 2022 г. в 13:06, Александр Гурьянов <[email protected]>: > >> I tried set SHARED_MEMORY=1 both for compile and linking, but now I have >> this error from linker: >> wasm-ld: error: --shared-memory is disallowed by lto.tmp because it was >> not compiled with 'atomics' or 'bulk-memory' features >> >> Seems that I need to set PTHREADS anyway. I don't want use PTHREADS >> because I don't know how it affects performance of wasm, can it slowdown >> the overall performance? >> >> >> сб, 5 мар. 2022 г. в 03:27, 'Thomas Lively' via emscripten-discuss < >> [email protected]>: >> >>> Also note that you probably do want to use atomic operations to read and >>> write to the shared memory, even if you're using JS on one thread and Wasm >>> on another. If you don't use atomics, there's no guarantee that the values >>> written on one thread will actually become visible on the other thread when >>> you expect them to. >>> >>> On Fri, Mar 4, 2022 at 11:49 AM 'Sam Clegg' via emscripten-discuss < >>> [email protected]> wrote: >>> >>>> Historically the `-pthead` flag (or `-s USE_PTHREADS`) is the way to >>>> get shared memory. Is there some reason you have not wanted to use that >>>> flag? (is it code size >>>> of the resulting JS.. if so we are working on reducing that). >>>> >>>> As it happens we just today landed a new `-s SHARED_MEMORY` flag I >>>> think gives you exactly what you want without the overhead of the pthread >>>> JS library code: >>>> https://github.com/emscripten-core/emscripten/pull/16419. >>>> >>>> cheers, >>>> sam >>>> >>>> On Fri, Mar 4, 2022 at 10:29 AM Александр Гурьянов <[email protected]> >>>> wrote: >>>> >>>>> https://github.com/WebAssembly/binaryen/pull/4525 >>>>> >>>>> >>>>> пт, 4 мар. 2022 г. в 15:43, Александр Гурьянов <[email protected]>: >>>>> >>>>>> Hi, I want to use shared memory for my WebAssembly module. It's >>>>>> needed for js-dos. Currently emulation works in worker and frame updates >>>>>> are send using postMessage. I want to use SharedArrayBuffer to avoid >>>>>> copying/sending big rgba data. >>>>>> >>>>>> I dont' need to use pthread or threading, I just want to share memory >>>>>> between worker and main process. How I can say emscripten to generate >>>>>> "shared" memory imort. >>>>>> >>>>>> I found similar question here: >>>>>> https://github.com/emscripten-core/emscripten/issues/12098 >>>>>> As suggested I tried wasm2wat and then wat2wasm, but it not working >>>>>> for me. Looks like it affects -s INVOKE_RUN=0, because after wasm2wat my >>>>>> module immediately starts and I can't provide own memory. >>>>>> >>>>>> Without wasm2wat I have this error: >>>>>> >>>>>> LinkError: WebAssembly.instantiate(): mismatch in shared state of >>>>>> memory, declared = *0*, imported = *1* >>>>>> >>>>>> After wasm2wat this: >>>>>> >>>>>> LinkError: WebAssembly.instantiate(): mismatch in shared state of >>>>>> memory, declared = *1*, imported = *0* >>>>>> >>>>>> Can we add some pass to binaryen for turning non-shared memory into >>>>>> shared? >>>>>> >>>>> -- >>>>> 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 [email protected]. >>>>> To view this discussion on the web visit >>>>> https://groups.google.com/d/msgid/emscripten-discuss/CAKOm%3DVE24Q4%2Bewi5QBSdmuuRf7F-FCk_1TM7tZxexwrMOzXdqw%40mail.gmail.com >>>>> <https://groups.google.com/d/msgid/emscripten-discuss/CAKOm%3DVE24Q4%2Bewi5QBSdmuuRf7F-FCk_1TM7tZxexwrMOzXdqw%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 [email protected]. >>>> To view this discussion on the web visit >>>> https://groups.google.com/d/msgid/emscripten-discuss/CAL_va2_UWBhM-2yOG_6aUDPa_%3DX%3DmDJOxaC00Bo8CbQa6cDbYw%40mail.gmail.com >>>> <https://groups.google.com/d/msgid/emscripten-discuss/CAL_va2_UWBhM-2yOG_6aUDPa_%3DX%3DmDJOxaC00Bo8CbQa6cDbYw%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 [email protected]. >>> To view this discussion on the web visit >>> https://groups.google.com/d/msgid/emscripten-discuss/CAJZD_EWNu%3Di0%3DACiKbuPyTOUAckT1SDceosApBvJj6VCo8-WYQ%40mail.gmail.com >>> <https://groups.google.com/d/msgid/emscripten-discuss/CAJZD_EWNu%3Di0%3DACiKbuPyTOUAckT1SDceosApBvJj6VCo8-WYQ%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 [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/emscripten-discuss/CAKOm%3DVH4e3mMQMXowF_-RqVjrCg_hbZY9F9NBH3cTco3%2B%2BpJgw%40mail.gmail.com > <https://groups.google.com/d/msgid/emscripten-discuss/CAKOm%3DVH4e3mMQMXowF_-RqVjrCg_hbZY9F9NBH3cTco3%2B%2BpJgw%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 [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/emscripten-discuss/CAL_va29kVqFU5SNqpzOiB%2Bd9hTtegMM8B9ug5tRJjtw1zti9ig%40mail.gmail.com.
