PSA: Passing linker flags on the command line

2020-03-25 Thread 'Sam Clegg' via emscripten-discuss
After going back and forth on this issue I'm hoping to once again allow
arbitrary flags to be passed to the linker (wasm-ld) via the command line
(-Wl,xxx):  https://github.com/emscripten-core/emscripten/pull/10747.

This means that some people will see linker errors because they (or thier
build systems) pass flags via `-Wl,xxx` that wasm-ld doesn't handle.  If
you encounter such errors you have we have two possible solutions for you:

1. Remove the offending flag from the linker command.
2. Add it to the list of flags that emscripten will ignore not not pass
onto the linker (`UNSUPPORTED_LLD_FLAGS`).

Hopefully with a combination of these two solutions the fallout of this
change should be minimal.

cheers,
sam

-- 
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/CAL_va28XuFiBzovensmJTX06PApp%3DvzttiunCc5xG4WzO8%3D6BA%40mail.gmail.com.


Re: async JavaScript code not running in USE_PTHREADS build

2020-03-25 Thread Kevin McGrath
  Ah!  Thanks for the details!  I looked into Asyncify and ruled it out 
because of this from the emscripten documentation:

It is not safe to start an async operation while another is already 
> running. The first must complete before the second begins.


  That would mean one HTTP request at a time, one after another, and any 
time we want to use Asyncify for any other async JavaScript tasks we may 
run into trouble that would be a nightmare to debug.  Plus there's more 
issues described in that doc, such as if we get an event (like a keypress) 
while the async JavaScript is running it doesn't sound too stable when it 
calls into compiled code.  Lastly, they mention that you should always run 
optimized builds if you're using Asyncify, which will not be fun to debug.  
Taking all of that into consideration, it didn't sound like a good option 
to me, especially since I wasn't sure it would work in the first place with 
USE_PTHREADS=1.

  I'm not sure I understand how emscripten_set_main_loop() will help my 
JavaScript execute the async code... are you saying that the compiled code 
in each thread is blocking the JavaScript code?

  Sorry for so many questions, I'm very new to JavaScript and know very 
little about its internal workings.  Also seems impossible to Google for 
this kind of stuff.

  Thank you!

-- 
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/1445b398-abcb-483e-8384-6c5bebfc3e29%40googlegroups.com.


Re: async JavaScript code not running in USE_PTHREADS build

2020-03-25 Thread Kevin McGrath
  Ah!  Thanks for the details!  I looked into Asyncify and ruled it out 
because of this from the emscripten documentation:

It is not safe to start an async operation while another is already 
> running. The first must complete before the second begins.


  That would mean one HTTP request at a time, one after another, and any 
time we want to use Asyncify for any other async JavaScript tasks we may 
run into trouble that would be a nightmare to debug.  Plus there's more 
issues described in that doc, such as if we get an event (like a keypress) 
while the async JavaScript is running it doesn't sound too stable when it 
calls into compiled code.  Lastly, they mention that you should always run 
optimized builds if you're using Asyncify, which will not be fun to debug.  
Taking all of that into consideration, it didn't sound like a good option 
to me, especially since I wasn't sure it would work in the first place with 
USE_PTHREADS=1.

  I'm not sure I understand how emscripten_set_main_loop() will help my 
JavaScript execute the async code... are you saying that the compiled code 
in each thread is blocking the JavaScript code?

  Sorry for so many questions, I'm very new to JavaScript and know very 
little about its internal workings.  Also seems impossible to Google for 
this kind of stuff.

  Thank you!


On Wednesday, March 25, 2020 at 4:39:29 PM UTC-7, Alon Zakai wrote:
>
> emscripten_thread_sleep() will check the pthread event queue, which means 
> it can receive C messages from other threads - those are synchronized using 
> shared memory. However, it can't help with JS events, as to get those to 
> happen you need to actually return to the main JS event loop. The browser 
> won't run those events otherwise.
>
> To do that, you can use Asyncify (
> https://emscripten.org/docs/porting/asyncify.html) and 
> emscripten_sleep(). Or, you can manually return to the main event loop 
> yourself, replacing an infinite event loop with an 
> emscripten_set_main_loop() etc.
>
> On Wed, Mar 25, 2020 at 1:56 PM Kevin McGrath  > wrote:
>
>> Hello!
>>
>> I'm hoping someone has already run into this before and can tell me what 
>> I'm doing wrong...
>>
>> I have a JavaScript function I'm calling from a C++ multi-threaded game 
>> that is designed to perform an async HTTP fetch.
>>
>> I'm building the game using USE_PTHREADS=1 and PROXY_TO_PTHREAD=1 and 
>> I've tried both having the JavaScript function embedded in a EM_JS() and in 
>> a --js-library.  The C++ code sparks off a pthread and calls into the 
>> JavaScript function, and that JavaScript code executes and then returns 
>> back to the C++ code.  What doesn't work is any of the Promise / await 
>> code, nothing is executing in those code blocks.
>>
>> I've tried calling emscripten_thread_sleep() from the C++ code, which is 
>> still executing in the thread waiting on the JavaScript asynchronous code 
>> to call it back, it just never happens.  The network request is just marked 
>> as "(pending)" in Chrome and never changes.
>>
>> So my question is, what's the right way to run Promise/async/await code 
>> in a WebAssembly pthread/Web Worker?
>>
>> Thank you!!
>>
>> -- 
>> 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/aecd43c5-6662-4d7d-bb8c-15461e75522e%40googlegroups.com
>>  
>> 
>> .
>>
>

-- 
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/fe4d60af-6a74-40e6-b37f-31a04eb34afd%40googlegroups.com.


Re: async JavaScript code not running in USE_PTHREADS build

2020-03-25 Thread Alon Zakai
emscripten_thread_sleep() will check the pthread event queue, which means
it can receive C messages from other threads - those are synchronized using
shared memory. However, it can't help with JS events, as to get those to
happen you need to actually return to the main JS event loop. The browser
won't run those events otherwise.

To do that, you can use Asyncify (
https://emscripten.org/docs/porting/asyncify.html) and emscripten_sleep().
Or, you can manually return to the main event loop yourself, replacing an
infinite event loop with an emscripten_set_main_loop() etc.

On Wed, Mar 25, 2020 at 1:56 PM Kevin McGrath 
wrote:

> Hello!
>
> I'm hoping someone has already run into this before and can tell me what
> I'm doing wrong...
>
> I have a JavaScript function I'm calling from a C++ multi-threaded game
> that is designed to perform an async HTTP fetch.
>
> I'm building the game using USE_PTHREADS=1 and PROXY_TO_PTHREAD=1 and I've
> tried both having the JavaScript function embedded in a EM_JS() and in a
> --js-library.  The C++ code sparks off a pthread and calls into the
> JavaScript function, and that JavaScript code executes and then returns
> back to the C++ code.  What doesn't work is any of the Promise / await
> code, nothing is executing in those code blocks.
>
> I've tried calling emscripten_thread_sleep() from the C++ code, which is
> still executing in the thread waiting on the JavaScript asynchronous code
> to call it back, it just never happens.  The network request is just marked
> as "(pending)" in Chrome and never changes.
>
> So my question is, what's the right way to run Promise/async/await code in
> a WebAssembly pthread/Web Worker?
>
> Thank you!!
>
> --
> 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/aecd43c5-6662-4d7d-bb8c-15461e75522e%40googlegroups.com
> 
> .
>

-- 
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/CAEX4NpSDeUKi05LaBrH8BPynV61xxgpk%2B7n5GiFEbhKRMDMLvA%40mail.gmail.com.


async JavaScript code not running in USE_PTHREADS build

2020-03-25 Thread Kevin McGrath
Hello!

I'm hoping someone has already run into this before and can tell me what 
I'm doing wrong...

I have a JavaScript function I'm calling from a C++ multi-threaded game 
that is designed to perform an async HTTP fetch.

I'm building the game using USE_PTHREADS=1 and PROXY_TO_PTHREAD=1 and I've 
tried both having the JavaScript function embedded in a EM_JS() and in a 
--js-library.  The C++ code sparks off a pthread and calls into the 
JavaScript function, and that JavaScript code executes and then returns 
back to the C++ code.  What doesn't work is any of the Promise / await 
code, nothing is executing in those code blocks.

I've tried calling emscripten_thread_sleep() from the C++ code, which is 
still executing in the thread waiting on the JavaScript asynchronous code 
to call it back, it just never happens.  The network request is just marked 
as "(pending)" in Chrome and never changes.

So my question is, what's the right way to run Promise/async/await code in 
a WebAssembly pthread/Web Worker?

Thank you!!

-- 
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/aecd43c5-6662-4d7d-bb8c-15461e75522e%40googlegroups.com.