Skip to content

Build still fails when both -sJSPI and --emit-tsd are active #23418

Closed
@mroohian

Description

@mroohian

Version of emscripten/emsdk:

emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.74 (1092ec30a3fb1d46b1782ff1b4db5094d3d06ae5)
clang version 20.0.0git (https:/github.com/llvm/llvm-project 322eb1a92e6d4266184060346616fa0dbe39e731)
Target: wasm32-unknown-emscripten
Thread model: posix

Issue:
This is a follow-up to #23272 because it was closed.

When enabling the JSPI flag and attempting to emit Typescript definitions (via --emit-tsd), the build fails. Since we disable Asyncify the library_async is not included and the linker complains about missing emscripten_sleep() function.

Demo to reproduce: https://github.com/mroohian/emscripten-jspi-demo

Failing command line in full:

# This command is executed by CMake
em++ -gsource-map \
     -lembind \
     --emit-tsd test1.d.ts \   # It works without this line
     -s EXPORT_NAME=Test1Module \
     -s JSPI \
     -s STRICT \
     -s USE_ES6_IMPORT_META \
     -s MODULARIZE \
     -s EXPORT_ES6=1 \
     --no-entry \
     test1.cpp.o \
     -o test1.js

Full link command and output with -v appended:

> [email protected] cmake:build
> cd build.em && make

-- Configuring done (1.2s)
-- Generating done (0.0s)
-- Build files have been written to: /root/workspace/emscripten-jspi-demo/build.em
[ 33%] Building CXX object CMakeFiles/test1.dir/src/wasm/calc.cpp.o
[ 66%] Building CXX object CMakeFiles/test1.dir/src/wasm/test1.cpp.o
[100%] Linking CXX executable test1.js
em++: warning: -sASYNCIFY=2 (JSPI) is still experimental [-Wexperimental]
error: undefined symbol: emscripten_sleep (referenced by root reference (e.g. compiled C/C++ code))
warning: To disable errors for undefined symbols use `-sERROR_ON_UNDEFINED_SYMBOLS=0`
warning: _emscripten_sleep may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
Error: Aborting compilation due to previous errors
em++: error: '/root/workspace/emsdk/node/20.18.0_64bit/bin/node /root/workspace/emsdk/upstream/emscripten/src/compiler.mjs /tmp/tmpyi_gjmeb.json' failed (returned 1)
make[2]: *** [CMakeFiles/test1.dir/build.make:114: test1.js] Error 1
make[1]: *** [CMakeFiles/Makefile2:83: CMakeFiles/test1.dir/all] Error 2
make: *** [Makefile:91: all] Error 2

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions