
On Wed, Jul 3, 2013 at 11:06 AM, B B
Emscripten is meant to translate ANY LLVM IR code to javascript and it should work (as I belive).
It cannot compile ANY LLVM code: It's heavily geared towards porting C and C++ code to JavaScript, and still there are some limitatons, see: https://github.com/kripken/emscripten/wiki/CodeGuidelinesAndLimitations Also the FAQ mentions how event loops should be converted to something that emscripten can deal with: https://github.com/kripken/emscripten/wiki/FAQ Since the GHC runtime never returns, you'd probably have to do something similar. I've tried to compile 'hello wrold' Haskell program to JS using Emscripten
but I faced a problem, that in generated LLVM IR code there is no C-like main function (https://github.com/kripken/emscripten/issues/500) so there has to be a runtime library that has to be linked and will run the code - is this "RTS" or something else? If its RTS I understeand I should compile it to javascript and then provide it as a library to emscripten? Do you have a working RTS js version?
I don't have a working version. The files you need are probably mostly in the rts directory of the GHC repository: https://github.com/ghc/ghc/tree/master/rts , but you might need a bit more, like libffi and gmp (unless you use integer-simple).
I want to simply try emscripten and see how it performs on such GHC generater LLVM IRs.
I don't think it's that easy... I'd expect a few weeks of work minimum to get very simple examples like "Hello, world" working. And a few months for something big like GHC. Also keep in mind that the code will probably be pretty big, GHC (and GHCi, which is the same file) is ~65MB on my linux system, so getting well over 100MB of JavaScript wouldn't be terribly surprising. luite