Hi,

I'm having a bit of trouble working out how to compile a project with 
pthreads support where the project is based on autoconf.

The docs say I need to pass -s USE_PTHREADS=1 to the compile stage as well 
as when linking.  The simplest way to do that with a configure script is to 
pass it in CFLAGS...

    e.g. emconfigure ./configure CFLAGS="-s USE_PTHREADS=1"

(That's from memory, I'm not at my home PC at the moment)

The problem with doing that is the flag is used when compiling the feature 
tests in the configure script and because those are run by Node, they all 
fail.  Node doesn't have Web Workers so there's no way to make that work 
AFAIK (although strictly speaking the actual failure is because the 
pthreads code references the 'document' object).

As far as solutions go I can think of a few possibilities:

1. Modify emcc to filter out the USE_PTHREADS flag when compiling a 
conftest snippet.  The downside to that is if the feature test is actually 
testing for pthreads support it will probably fail.

2. Switch to compiling the conftest snippets using native compilation.  
This used to be the default last time I played with emscripten a few years 
ago, but has the disadvantage that the features tests may find features 
available on Linux/Windows that are unimplemented on emscripten and/or 
javascript.  I assume this is why the default was switched to running them 
in Node.

3. Somehow make pthreads code work on Node, at least to some extent.  There 
are npm modules that claim to implement Web Workers although I don't know 
how well these work.  Alternatively maybe emscripten's pthread library can 
be modified to run under node with most things doing a no-op, such that 
code compiled with USE_PTHREADS but which is actually single-threaded will 
run.  That might be enough to make conftests work, but I don't know how 
much work that would be.

Thoughts?  I'm prepared to accept I'm missing something obvious here ... :-)

Cheers,

David.

-- 
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.
For more options, visit https://groups.google.com/d/optout.

Reply via email to