Hi all,
I'm looking into generating standalone WASM (#12757), and so far things are looking great, especially when these things are going on inside of a Web Worker.
I've been looking into implementing system calls, making a list of the ones that I'll need to implement in order to get some applications running, but I've noticed that sometimes Emscripten will generate imports to things other than system calls (__syscalNNN) and various WASI functions (i.e. fd_read). I've seen this happen for time-related calls, but I'm sure this will happen in other cases as well.
For reference, the imports to a module looked like this, produced by wasm-objdump:
- func[0] sig=2 <wasi_snapshot_preview1.proc_exit> <- wasi_snapshot_preview1.proc_exit
- func[1] sig=3 <env.__syscall4> <- env.__syscall4
- func[2] sig=3 <wasi_snapshot_preview1.args_get> <- wasi_snapshot_preview1.args_get
- func[3] sig=3 <wasi_snapshot_preview1.args_sizes_get> <- wasi_snapshot_preview1.args_sizes_get
- func[4] sig=0 <env.localtime> <- env.localtime
- func[5] sig=0 <env.time> <- env.time
IIRC, both localtime and time are C library functions, and I'd really like to avoid rewriting sections of libc in JavaScript. For the record, however, it's only these functions that are called as exports: other libc functions like malloc are statically linked in, which is great. I really have no idea which ones are inlined and which ones aren't. The others, like __syscall4 and args_sizes_get are fine, and I expect to implement them myself, in my own compatibility layer. I can also implement time-related system calls, but I'd be better if libc handled localtime and friends itself and called the raw system calls instead.
The command that I used to compile this file is emcc $1.c -O3 -s WASM=1 -s STANDALONE_WASM -o $1.wasm -static -g4. Are there any other flags that I need in order to avoid generating calls to localtime and time, or will I just need to bite the bullet and implement them myself?
Thanks!
Hi all,
I'm looking into generating standalone WASM (#12757), and so far things are looking great, especially when these things are going on inside of a Web Worker.
I've been looking into implementing system calls, making a list of the ones that I'll need to implement in order to get some applications running, but I've noticed that sometimes Emscripten will generate imports to things other than system calls (
__syscalNNN) and various WASI functions (i.e.fd_read). I've seen this happen for time-related calls, but I'm sure this will happen in other cases as well.For reference, the imports to a module looked like this, produced by
wasm-objdump:IIRC, both
localtimeandtimeare C library functions, and I'd really like to avoid rewriting sections of libc in JavaScript. For the record, however, it's only these functions that are called as exports: other libc functions likemallocare statically linked in, which is great. I really have no idea which ones are inlined and which ones aren't. The others, like__syscall4andargs_sizes_getare fine, and I expect to implement them myself, in my own compatibility layer. I can also implement time-related system calls, but I'd be better if libc handledlocaltimeand friends itself and called the raw system calls instead.The command that I used to compile this file is
emcc $1.c -O3 -s WASM=1 -s STANDALONE_WASM -o $1.wasm -static -g4. Are there any other flags that I need in order to avoid generating calls tolocaltimeandtime, or will I just need to bite the bullet and implement them myself?Thanks!