I can create a fairly minimal (203 bytes) wasm file from the following C code by running emcc -O3 -s WASM=1 -s SIDE_MODULE=1 -o sum.wasm sum.c
#include <emscripten/emscripten.h> int EMSCRIPTEN_KEEPALIVE sum(int a, int b) { return a + b; }
Disassembled output:
(module (type $0 (func (param i32 i32) (result i32))) ... trim 9 lines ... (export "_sum" (func $0)) (func $0 (type $0) (param $var$0 i32) (param $var$1 i32) (result i32) (i32.add (get_local $var$1) (get_local $var$0) ) ) ... trim 17 lines ... )
But given the following rust code
pub fn main() {}
I don't seem to be doing anything like that.
rustc -O --target=wasm32-unknown-emscripten sum.rs works, but it gives me an 85 kg wasm file and a 128k js file.
I tried exporting EMMAKEN_CFLAGS='-s WASM=1 -s SIDE_MODULE=1' , but this gives me some warnings like
The input file "/tmp/.../rust.metadata.bin" exists, but is not an LLVM bitcode file suitable for Emscripten. Perhaps accidentally mix your own embedded object files with Emscripten?
and then failed to bind.
My version is Rust 1.22.0-nightly (c6884b12d 2017-09-30) and my version is emcc 1.37.21 .
What am I doing wrong?
source share