Open juj opened 2 months ago
One way to figure out why a given function is included would be to use -Wl,--trace-symbol
. For example -Wl,--trace-symbol=raise
might help understand any raise is being included. That does seem like a symbol that should only be included if its used directly.
I've got a Flappy Bird game that I compiled last time in circa 2020, when I last optimized it for minimal code size.
It's been a while since I touched the codebase, though tonight I looked to update the code to take it through the latest Emscripten compiler version.
There are some code size creeps that have appeared in the build. Here are some examples:
and in Wasm:
The project itself does not use WASI, libc filesystem, or most other parts of libc much at all (e.g. no
printf()
and noenviron()
or related code), and it is compiled with-sEXIT_RUNTIME=0
in MINIMAL_RUNTIME build mode.When I look at why these code functions are present, I get odd circular trails:
__setitimer_js
from JS is imported to Wasm. In Wasm, it is called by_emscripten_timeout
._emscripten_timeout
is exported out to JS. In JS,_emscripten_timeout
is only used by__setitimer_js
._environ_get
from JS is imported to Wasm. In Wasm, it is called by__wasm_call_ctors
, and nothing else._proc_exit
from JS is imported to Wasm. In Wasm, it is called byaction_terminate
, which is not called directly, but exists only as part of(table $0 37 37 funcref)
. Searching Emscripten codebase, I findsystem\lib\libc\raise.c
references these via a signal table, but the codebase does not useraise
or signaling.It seems that the code size tests aren't catching real-world use case regressions as much as I would have hoped. I wonder if there are past changes in these areas that would come to mind?