Hi, I think I've found a solution, which turned out to be a lot simpler than I'd thought ...
I made a change to line 71 of shell.js : From: var currentScriptUrl = ENVIRONMENT_IS_WORKER ? undefined : document.currentScript.src; To: var currentScriptUrl = (ENVIRONMENT_IS_WORKER || ENVIRONMENT_IS_NODE) ? undefined : document.currentScript.src; That seems to have done the trick, for me at least. I haven't done extensive testing though. Cheers, David. On Thursday, 28 September 2017 15:41:10 UTC+1, David Claughton wrote: > > 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.