[rust-dev] enscripten demo?

Brian Anderson banderson at mozilla.com
Sun Apr 8 13:37:35 PDT 2012


On 04/04/2012 02:55 AM, Mohd. Bilal Husain wrote:
> Passed a dumb sample rust bitcode to emscripten, got js functions#. 
> Realized I need to run on core modules too for printing simple hello 
> world. Took io from libcore, decimated code to avoid few build errors, 
> emcc throws error
>
>     Unclear type in struct
>
> Anyways, need to figure out how to build native modules and core lib, 
> std lib; and how to map these modules to imports in a sample hello-world.

I would start with test cases that do not use core or std at all, like:

     #[no_core];
     fn main() { log(0, "hello, world"); }

Build that with --emit-llvm -S and build it with emscripten. After 
enough fiddling it should complain about not being able to find 
`rust_start` (the entry point to the rust runtime). Then you write a 
`rust_start` function and keep repeating until you've rewritten the 
runtime in javascript.

FWIW, last time I tried to run our bitcode through emscripten I had to 
use 32-bit code because emscripten had some bugs related to 64-bit code.

-Brian


More information about the Rust-dev mailing list