Closed
Description
The code executed by --embind-emit-tsd appears to expect that the target was WASM and therefore fails when the WASM=0 option is set.
Please include the following in your bug report:
Version of emscripten/emsdk:
emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.53 (ce5114b)
Failing command line in full:
emcc -s WASM=0 -lembind main.cpp --embind-emit-tsd interface.d.ts -v
Aborted(TypeError: Module.__wasm2jsInstantiate__ is not a function)
/tmp/emscripten_temp_o4b8c1as/tsgen_a.out.js:136
throw ex;
^
Error: Aborted(TypeError: Module.__wasm2jsInstantiate__ is not a function)
at abort (/tmp/emscripten_temp_o4b8c1as/tsgen_a.out.js:730:11)
at /tmp/emscripten_temp_o4b8c1as/tsgen_a.out.js:860:5
emcc: error: '/media/lia/HDD/Code/emsdk/node/16.20.0_64bit/bin/node /tmp/emscripten_temp_o4b8c1as/tsgen_a.out.js' failed (returned 7)
Full link command and output with -v
appended:
emcc -s WASM=0 -lembind main.cpp --embind-emit-tsd interface.d.ts -v
/media/lia/HDD/Code/emsdk/upstream/bin/clang -target wasm32-unknown-emscripten -fignore-exceptions -fvisibility=default -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr --sysroot=/media/lia/HDD/Code/emsdk/upstream/emscripten/cache/sysroot -DEMSCRIPTEN -Werror=implicit-function-declaration -Xclang -iwithsysroot/include/fakesdl -Xclang -iwithsysroot/include/compat -v main.cpp -c -o /tmp/emscripten_temp_ateluei8/main_0.o
clang version 19.0.0git (https://github.com/llvm/llvm-project febb4c42b192ed7c88c17f91cb903a59acf20baf)
Target: wasm32-unknown-emscripten
Thread model: posix
InstalledDir: /media/lia/HDD/Code/emsdk/upstream/bin
(in-process)
"/media/lia/HDD/Code/emsdk/upstream/bin/clang-19" -cc1 -triple wasm32-unknown-emscripten -emit-obj -mrelax-all -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name main.cpp -mrelocation-model static -mframe-pointer=none -ffp-contract=on -fno-rounding-math -mconstructor-aliases -target-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/home/lia/Code/emsdk/nowasmtsgentest -v -fcoverage-compilation-dir=/home/lia/Code/emsdk/nowasmtsgentest -resource-dir /media/lia/HDD/Code/emsdk/upstream/lib/clang/19 -D EMSCRIPTEN -isysroot /media/lia/HDD/Code/emsdk/upstream/emscripten/cache/sysroot -internal-isystem /media/lia/HDD/Code/emsdk/upstream/emscripten/cache/sysroot/include/wasm32-emscripten/c++/v1 -internal-isystem /media/lia/HDD/Code/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1 -internal-isystem /media/lia/HDD/Code/emsdk/upstream/lib/clang/19/include -internal-isystem /media/lia/HDD/Code/emsdk/upstream/emscripten/cache/sysroot/include/wasm32-emscripten -internal-isystem /media/lia/HDD/Code/emsdk/upstream/emscripten/cache/sysroot/include -Werror=implicit-function-declaration -fdeprecated-macro -ferror-limit 19 -fvisibility=default -fgnuc-version=4.2.1 -fcxx-exceptions -fignore-exceptions -fexceptions -fcolor-diagnostics -iwithsysroot/include/fakesdl -iwithsysroot/include/compat -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr -o /tmp/emscripten_temp_ateluei8/main_0.o -x c++ main.cpp
clang -cc1 version 19.0.0git based upon LLVM 19.0.0git default target x86_64-unknown-linux-gnu
ignoring nonexistent directory "/media/lia/HDD/Code/emsdk/upstream/emscripten/cache/sysroot/include/wasm32-emscripten/c++/v1"
ignoring nonexistent directory "/media/lia/HDD/Code/emsdk/upstream/emscripten/cache/sysroot/include/wasm32-emscripten"
#include "..." search starts here:
#include <...> search starts here:
/media/lia/HDD/Code/emsdk/upstream/emscripten/cache/sysroot/include/fakesdl
/media/lia/HDD/Code/emsdk/upstream/emscripten/cache/sysroot/include/compat
/media/lia/HDD/Code/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1
/media/lia/HDD/Code/emsdk/upstream/lib/clang/19/include
/media/lia/HDD/Code/emsdk/upstream/emscripten/cache/sysroot/include
End of search list.
/media/lia/HDD/Code/emsdk/upstream/bin/clang --version
/media/lia/HDD/Code/emsdk/upstream/bin/wasm-ld -o a.out.wasm /tmp/emscripten_temp_ateluei8/main_0.o -L/media/lia/HDD/Code/emsdk/upstream/emscripten/cache/sysroot/lib/wasm32-emscripten --whole-archive -lembind-rtti --no-whole-archive -lGL-getprocaddr -lal -lhtml5 -lstubs-debug -lnoexit -lc-debug -ldlmalloc -lcompiler_rt -lc++-noexcept -lc++abi-debug-noexcept -lsockets -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr /tmp/tmp7l9v97ublibemscripten_js_symbols.so --import-memory --strip-debug --export=emscripten_stack_get_end --export=emscripten_stack_get_free --export=emscripten_stack_get_base --export=emscripten_stack_get_current --export=emscripten_stack_init --export=stackAlloc --export=stackSave --export=stackRestore --export=__get_temp_ret --export=__set_temp_ret --export=__wasm_call_ctors --export-if-defined=__start_em_asm --export-if-defined=__stop_em_asm --export-if-defined=__start_em_lib_deps --export-if-defined=__stop_em_lib_deps --export-if-defined=__start_em_js --export-if-defined=__stop_em_js --export-if-defined=main --export-if-defined=__main_argc_argv --export-if-defined=fflush --export-table -z stack-size=65536 --initial-memory=16777216 --max-memory=16777216 --no-entry --stack-first --table-base=1
/media/lia/HDD/Code/emsdk/upstream/bin/llvm-objcopy a.out.wasm a.out.wasm --remove-section=.debug* --remove-section=producers
/media/lia/HDD/Code/emsdk/upstream/bin/wasm-emscripten-finalize --dyncalls-i64 --pass-arg=legalize-js-interface-exported-helpers a.out.wasm -o a.out.wasm --detect-features
/media/lia/HDD/Code/emsdk/node/16.20.0_64bit/bin/node /media/lia/HDD/Code/emsdk/upstream/emscripten/src/compiler.mjs /tmp/tmpj72cqlg2.json
/media/lia/HDD/Code/emsdk/node/16.20.0_64bit/bin/node /media/lia/HDD/Code/emsdk/upstream/emscripten/src/compiler.mjs /tmp/tmp6_n7s5a1.json
/media/lia/HDD/Code/emsdk/node/16.20.0_64bit/bin/node /tmp/emscripten_temp_ateluei8/tsgen_a.out.js
failed to asynchronously prepare wasm: TypeError: Module.__wasm2jsInstantiate__ is not a function
Aborted(TypeError: Module.__wasm2jsInstantiate__ is not a function)
/tmp/emscripten_temp_ateluei8/tsgen_a.out.js:136
throw ex;
^
Error: Aborted(TypeError: Module.__wasm2jsInstantiate__ is not a function)
at abort (/tmp/emscripten_temp_ateluei8/tsgen_a.out.js:730:11)
at /tmp/emscripten_temp_ateluei8/tsgen_a.out.js:860:5
emcc: error: '/media/lia/HDD/Code/emsdk/node/16.20.0_64bit/bin/node /tmp/emscripten_temp_ateluei8/tsgen_a.out.js' failed (returned 7)
main.cpp contents:
#include <emscripten/bind.h>
using namespace emscripten;
double add(double a, double b) {
return a + b;
}
EMSCRIPTEN_BINDINGS(my_module) {
function("add", &add);
}