Stream: git-wasmtime

Topic: wasmtime / issue #3596 Is there any way to reduce wasi's ...


view this post on Zulip Wasmtime GitHub notifications bot (Dec 12 2021 at 10:52):

fengqi2019 opened issue #3596:

hello, i just learn wasi. i compile the helloworld's code to wasi in release, and the wasi's size is 1.78M(i think it is too big.), is there any way to reduce wasi's size?
the helloworld code:

fn main() {
    println!("Hello, world!");
}

view this post on Zulip Wasmtime GitHub notifications bot (Dec 12 2021 at 11:13):

bjorn3 commented on issue #3596:

Did you enable LTO? That helps a lot with removing dead code.

view this post on Zulip Wasmtime GitHub notifications bot (Dec 12 2021 at 11:23):

fengqi2019 commented on issue #3596:

it is useful, now it's size is 250k. thanks a lot!

view this post on Zulip Wasmtime GitHub notifications bot (Dec 12 2021 at 11:23):

fengqi2019 closed issue #3596:

hello, i just learn wasi. i compile the helloworld's code to wasi in release, and the wasi's size is 1.78M(i think it is too big.), is there any way to reduce wasi's size?
the helloworld code:

fn main() {
    println!("Hello, world!");
}

view this post on Zulip Wasmtime GitHub notifications bot (Dec 12 2021 at 14:18):

tschneidereit commented on issue #3596:

Most of that is probably still debug symbols, and running wasm-strip on the result will further reduce the size substantially. Running it through wasm-opt with -O3 or -Os makes it even smaller.

The smallest I can get this is 61kb, with these commands:

rustc --target wasm32-wasi main.rs -o main.wasm
wasm-opt -Os --strip -o main.wasm main.wasm


Last updated: Oct 23 2024 at 20:03 UTC