With the new static compilation capabilities (thanks Jeff, Keno, and Jameson!) and the new compile=all option, Julia can generate a large LLVM bitcode file using the following (in the devel version of Julia):
cd julia/base mkdir ../tmp ../julia --build /home/tshort/julia/tmp --dump-bitcode=yes --compile=all -J /home/tshort/julia/usr/lib/julia/sys.ji -f sysimg.jl After that, you can compile functions from the julia/tmp/sys.bc bitcode file to JavaScript with something like (find the names of functions in sys.bc with: llvm-nm sys.bc): cd ../tmp emcc -v sys.bc -o out.js -s EXPORTED_FUNCTIONS="['_julia_abs;104547']" I've gotten individual functions like this to compile as well as pisum from julia/test/perf/micro/perf.jl. In doing this, I've come across a couple of items: * The sys.bc needs to be a 32-bit build. I haven't managed that, yet. The devel versions have been a bit goofed lately for 32-bit use. More info: https://code.google.com/p/nativeclient/issues/detail?id=3931 * The current Emscripten has a bug with some Julia-generated bitcode. More info: https://code.google.com/p/nativeclient/issues/detail?id=3932 I've managed to compile about 90% of libjulia using Emscripten. I had to cut out most of the code related to libuv. Unfortunately, I haven't gotten any code to compile that used libjulia. Although, I've gotten 90% of libjulia to compile, the missing 10% is called a lot. Still more work to do there. My attempt involved hacking up the Makefiles. I better attempt would involve making a new target to compile libjulia.bc. The bottom line is that I think this'll work someday, but it will take some work. Tom On Thu, Oct 2, 2014 at 11:08 AM, JobJob <jobbu....@gmail.com> wrote: > Any updates on this? > > On Friday, 13 December 2013 15:16:31 UTC+2, tshort wrote: >> >> I've played a little with this. Using Jameson's static compile branch, I >> was able to dump some functions compiled by Julia to LLVM IR and compile >> these with Emscripten. I did have to mess with some symbol names because >> Emscripten doesn't like Julia's naming. See an Emscripten issue here: >> >> https://github.com/kripken/emscripten/issues/1888 >> >> I also took a quick look at compiling openlibm, and I ran into some >> nonportable header stuff that would need to be worked on. >> >> The nice thing about trying to get compiled stuff to run is that you don't >> necessarily need all of Julia compiled. That means faster downloads, and >> that we don't have to get everything working at the beginning. >> >> It'd be great if we could position Julia to be the leading numerical >> language for the web. With both Firefox and Chrome running asm.js within 2 - >> 4X of native, I think there's lots of opportunity here. >> >> >> >> On Fri, Dec 13, 2013 at 12:22 AM, John Myles White <johnmyl...@gmail.com> >> wrote: >>> >>> I think it would also be great to think a bit about how we might use >>> Julia to generate LLVM IR to generate Javascript for certain simple web >>> tasks. Writing Julia code and then letting a package compile it into an >>> includable Javascript file could be really fun. >>> >>> ā John >>> >>> On Dec 12, 2013, at 9:19 PM, Stefan Karpinski <ste...@karpinski.org> >>> wrote: >>> >>> > Iām not sure how practical it really is to wait until runtime to >>> > compile your code rather than precompiling it >>> > >>> > It's pretty frigging practical, as it turns out. This is great. More >>> > work in this direction and we may actually be able to run a full Julia >>> > instance in a browser. >>> > >>> > >>> > On Fri, Dec 13, 2013 at 12:14 AM, John Myles White >>> > <johnmyl...@gmail.com> wrote: >>> > The Emscripten folks are doing some really cool stuff: >>> > http://badassjs.com/post/39573969361/llvm-js-llvm-itself-compiled-to-javascript-via >>> > >>> > ā John >>> > >>> > >>> >> >