Skip to content

--emit-tsd doesn't account for -s WASM_ASYNC_COMPILATION=0 with -s MODULARIZE=1 #21760

@merceyz

Description

@merceyz

When compiling using -s WASM_ASYNC_COMPILATION=0 -s MODULARIZE=1 the MainModuleFactory function is synchronous, however --emit-tsd claims that it's asynchronous / returns a Promise.

Version of emscripten/emsdk:

emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.57 (1df9c1977b49926c1efca672c31414da45c0c7bb)
clang version 19.0.0git (https:/github.com/llvm/llvm-project ccdebbae4d77d3efc236af92c22941de5d437e01)
Target: wasm32-unknown-emscripten
Thread model: posix
InstalledDir: /emsdk/upstream/bin

Full link command and output with -v appended:

touch test.c && docker run --rm -v "$(pwd):/src" emscripten/emsdk:3.1.57 bash -c "cd /emsdk/upstream/emscripten && npm ci && cd /src && emcc -o ./build.js --emit-tsd ./build.d.ts -s WASM_ASYNC_COMPILATION=0 -s MODULARIZE=1 -v ./test.c"
added 446 packages, and audited 447 packages in 13s

45 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities
npm notice
npm notice New major version of npm available! 8.19.4 -> 10.5.2
npm notice Changelog: <https://github.com/npm/cli/releases/tag/v10.5.2>
npm notice Run `npm install -g [email protected]` to update!
npm notice
 /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=/emsdk/upstream/emscripten/cache/sysroot -DEMSCRIPTEN -Werror=implicit-function-declaration -Xclang -iwithsysroot/include/fakesdl -Xclang -iwithsysroot/include/compat -v ./test.c -c -o /tmp/emscripten_temp_f925o90u/test_0.o
clang version 19.0.0git (https:/github.com/llvm/llvm-project ccdebbae4d77d3efc236af92c22941de5d437e01)
Target: wasm32-unknown-emscripten
Thread model: posix
InstalledDir: /emsdk/upstream/bin
 (in-process)
 "/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 test.c -mrelocation-model static -mframe-pointer=none -ffp-contract=on -fno-rounding-math -mconstructor-aliases -target-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/src -v -fcoverage-compilation-dir=/src -resource-dir /emsdk/upstream/lib/clang/19 -D EMSCRIPTEN -isysroot /emsdk/upstream/emscripten/cache/sysroot -internal-isystem /emsdk/upstream/lib/clang/19/include -internal-isystem /emsdk/upstream/emscripten/cache/sysroot/include/wasm32-emscripten -internal-isystem /emsdk/upstream/emscripten/cache/sysroot/include -Werror=implicit-function-declaration -ferror-limit 19 -fvisibility=default -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -fignore-exceptions -iwithsysroot/include/fakesdl -iwithsysroot/include/compat -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr -o /tmp/emscripten_temp_f925o90u/test_0.o -x c ./test.c
clang -cc1 version 19.0.0git based upon LLVM 19.0.0git default target x86_64-unknown-linux-gnu
ignoring nonexistent directory "/emsdk/upstream/emscripten/cache/sysroot/include/wasm32-emscripten"
#include "..." search starts here:
#include <...> search starts here:
 /emsdk/upstream/emscripten/cache/sysroot/include/fakesdl
 /emsdk/upstream/emscripten/cache/sysroot/include/compat
 /emsdk/upstream/lib/clang/19/include
 /emsdk/upstream/emscripten/cache/sysroot/include
End of search list.
 /emsdk/upstream/bin/clang --version
cache:INFO: generating system asset: symbol_lists/bd9734d316c5831ee108cb0dfeea4b33f35a6034.json... (this will be cached in "/emsdk/upstream/emscripten/cache/symbol_lists/bd9734d316c5831ee108cb0dfeea4b33f35a6034.json" for subsequent builds)
 /emsdk/node/16.20.0_64bit/bin/node /emsdk/upstream/emscripten/src/compiler.mjs /tmp/tmpdrfp8hlb.json --symbols-only
cache:INFO:  - ok
 /emsdk/upstream/bin/wasm-ld -o ./build.wasm -L/emsdk/upstream/emscripten/cache/sysroot/lib/wasm32-emscripten /tmp/emscripten_temp_f925o90u/test_0.o -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/tmph863_a7xlibemscripten_js_symbols.so --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=_emscripten_stack_alloc --export=__get_temp_ret --export=__set_temp_ret --export=__wasm_call_ctors --export=_emscripten_stack_restore --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 --no-growable-memory --initial-heap=16777216 --no-entry --stack-first --table-base=1
 /emsdk/upstream/bin/llvm-objcopy ./build.wasm ./build.wasm --remove-section=.debug* --remove-section=producers
 /emsdk/upstream/bin/wasm-emscripten-finalize --dyncalls-i64 --pass-arg=legalize-js-interface-exported-helpers ./build.wasm -o ./build.wasm --detect-features
 /emsdk/node/16.20.0_64bit/bin/node /emsdk/upstream/emscripten/src/compiler.mjs /tmp/tmpoioe9rhr.json
 /emsdk/node/16.20.0_64bit/bin/node /emsdk/upstream/emscripten/node_modules/.bin/tsc --outFile /tmp/emscripten_temp_f925o90u/jsdoc.d.ts --declaration --emitDeclarationOnly --allowJs /tmp/emscripten_temp_f925o90u/jsdoc.js

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions