Try adding one or more of -s linker flags listed in https://github.com/emscripten-core/emscripten/blob/852ca4eb34b316d69f9999b7602e69a249422e63/tests/test_other.py#L9329 . Those can trim down the build output from the default size.
Also while debug builds are large, adding -O3 (or -Oz), and --closure 1 to help trim the size down. Although current default builds target "wasm2js" when building to -s WASM=0, which is somewhat larger than what it would need to be. Installing the "fastcomp" toolchain from emsdk allows targeting asm.js. With those, the smallest hello world will be a few hundred bytes big with no extraneous characters in the output. su 24. toukok. 2020 klo 18.15 Ivan Zvonimir Horvat ([email protected]) kirjoitti: > > EMCC version 1.38.31 > > How to properly compile C to asm.js, with a sample from Wikipedia. > > // input.c > int f(int i) { > return i + 1; > } > > > Expected result: > // output.js > function f(i) { > "use asm"; > i = i | 0; > return (i + 1) | 0; > } > > I have tried to compile it with(see below) and generates huge JavaScript file > with ~5K lines of code > > emcc input.c -o output.js \ > -s INVOKE_RUN=0 \ > -s EXPORTED_FUNCTIONS="['_f']" \ > -s WASM=0 # causes the compiler to target asm.js > > > -- > You received this message because you are subscribed to the Google Groups > "emscripten-discuss" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/emscripten-discuss/ab23c223-21a0-4d3b-abaf-954b547cd8a9%40googlegroups.com. -- You received this message because you are subscribed to the Google Groups "emscripten-discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/emscripten-discuss/CA%2B6sJ-2uUvT6%2BnS1Hn%2BmJqraXdjLNntvm08NodjHjF3Yv--vnA%40mail.gmail.com.
