emscripten-core / emscripten

Emscripten: An LLVM-to-WebAssembly Compiler
Other
25.63k stars 3.29k forks source link

Missing header file when compiling spider monkey #203

Closed hanm closed 12 years ago

hanm commented 12 years ago

I've got an error when building spider monkey using lastest emscripten on Ubuntu 11.10.

cd js-1.8.5/js/src (enter spider monkey source directory) autoconf2.13 (generate configuration file for spider monkey) emconfigure ./configure (an error here complaining link.h can't be located)

The missing header file link.h is obviously not included in the libc bundle comes with emscripten. It seems to me that the file is required because autoconf uses the system include headers (glibc on Unbuntu in this case), which makes sense. Then I simply ignores this error and go ahead with make, and I got another error:

./perf/pm_linux.cpp:47:10: fatal error: 'linux/perf_event.h" file not found

include <linux/perf_event.h>

pm_linux.cpp is a source file from spider monkey : js-1.8.5/js/src/perf/pm_linux.cpp

Any ideas on how to work around these issues?

kripken commented 12 years ago

cc @jterrace who is the expert on compiling spidermonkey, which he does in https://github.com/jterrace/js.js

My first guess is, perhaps wrap autoconf in emconfigure as well? Not sure how autoconf works, but if it runs compiler commands like configure, then emconfigure could fix it.

If not, we might need to add some headers?

jterrace commented 12 years ago

Getting spidermonkey to compile has been difficult - you need to patch some complicated things they do that are not portable to emscripten.

The configure line we use looks like this:

./configure --disable-methodjit --disable-monoic --disable-polyic --disable-tracejit --disable-methodjit-spew --disable-tests --disable-debug --disable-optimize

but that's only the beginning. See the full list of patches and hacks we did at:

https://github.com/jterrace/js.js/blob/master/builder/build.py

hanm commented 12 years ago

@jterrace , awesome, I'll try that. Thanks

@kripken , here is another missing header problem I just had when trying to compile node.js. I just ran emconfigure on the vanilla configure file comes with node.js, and then do a make. The error is:

include/uv-private/uv-unix.h:33:10: fatal error: 'netinet/tcp.h' file not found

include <netinet/tcp.h>

Would emscripten includes these headers in the bundled libc/c++ headers in future ?

Also a minor suggestion - it might be a good idea to have one or two C++ cross compile demo on the wiki page, which only has C to Javascript demos, to demonstrate the C++ support for emscripten.

kripken commented 12 years ago

@hanm We definitely want to add headers that are useful. The main problem is finding BSD licensed ones (we don't want to use LGPL ones here, to avoid people worrying about licensing issues). I have had to write headers from scratch for lots of stuff missing from newlib (which is the BSD licensed source of most of our headers).

If you're missing a particular header, write a testcase that shows its use and I'll find or write the stuff the testcase needs to work.

Regarding demos, the Poppler demo actually uses some C++ stuff. Not in any significant amount though. What kind of demo did you have in mind?

hanm commented 12 years ago

@kripken, totally make sense.

I don't have any particular ideas on the C++ demo at the moment - it might be a good idea to just link https://github.com/jterrace/js.js somewhere on the wiki so people like me evaluating the emscripten's C++ support would have a general idea on the status of C++ support.. some other crazy idea including trying to host Clang using emscripten so the LLVM online demo http://llvm.org/demo/ could be done completely at client side =}

Another possible demo at some point in future is something we built at Autodesk (https://documents.cloud.autodesk.com/), which embeds a webgl based 3D model viewer. For now it is hand coded in Javascript and we are evaluating mandreel - I would expect at some point if the openGL to webGL pipeline works it might be possible to switch to use emscripten.

kripken commented 12 years ago

Are there any headers we still need to add? Closing for now, please comment if there are.