Is it intended behavior that -shared -s SIDE_MODULE=1
changes function signature?
#17559
-
#include <unistd.h>
int f() {
return (int)lseek(0,0,0);
} $ emcc --version
emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.16 (6f1214164cb4b854755689060e91fd8167bc97a4)
Copyright (C) 2014 the Emscripten authors (see AUTHORS.txt)
This is free and open source software under the MIT license.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ emcc -c a.c
$ wasm2wat a.o
(module
(type (;0;) (func (result i32)))
(type (;1;) (func (param i32 i64 i32) (result i64)))
(import "env" "__linear_memory" (memory (;0;) 0))
(import "env" "lseek" (func (;0;) (type 1)))
... But $ emcc -s SIDE_MODULE=1 -shared -o a.so a.c
$ wasm2wat a.so
(module
(type (;0;) (func))
(type (;1;) (func (result i32)))
(type (;2;) (func (param i32 i64 i32) (result i64)))
(type (;3;) (func (param i32 i32 i32 i32) (result i32)))
(import "env" "getTempRet0" (func (;0;) (type 1)))
(import "env" "lseek" (func (;1;) (type 3)))
... The signature of |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
I think what's going on here is that building with Making a side module does emit an executable, so we do end up legalizing - it's an external interface, we're calling a function from another module, and we need to be fully general there. Note that you can control this, by setting |
Beta Was this translation helpful? Give feedback.
I think what's going on here is that building with
-c
does not link the file. So it is still a wasm object file. After that object file is linked and we produce an executable it will be legalized (if it needs to be). In this case, we won't legalize anyhow since it is just called from inside wasm - it's not an external interface..Making a side module does emit an executable, so we do end up legalizing - it's an external interface, we're calling a function from another module, and we need to be fully general there.
Note that you can control this, by setting
-sNO_LEGALIZE_JS_FFI
to disable the legalization (though I'm not sure if that is supported with side modules or not).