emscripten-core / emscripten

Emscripten: An LLVM-to-WebAssembly Compiler
Other
25.77k stars 3.3k forks source link

Use embind with --embind-emit-tsd returns error: undefined symbol: _embind_register_class_property #19933

Closed DreamOfIce closed 1 year ago

DreamOfIce commented 1 year ago

When I used 3.1.44 to generate a new function of dts for embind, an error occurred. I have tried to delete the local cache.

Version of emscripten/emsdk:

root@server:/work/fastText.wasm# emcc -v
emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.44 (bec42dac7873903d09d713963e34020c22a8bd2d)
clang version 17.0.0 (https://github.com/llvm/llvm-project a8cbd27d1f238e104a5d5ca345d93bc1f4d4ab1f)
Target: wasm32-unknown-emscripten
Thread model: posix
InstalledDir: /root/emsdk/upstream/bin

Failing command line in full:

root@server:/work/fastText.wasm# xmake -v
checking for platform ... wasm
checking for architecture ... wasm32
checking for emsdk directory ... /root/emsdk
checking for emcc ... /root/emsdk/upstream/emscripten/emcc
checking for emcc ... /root/emsdk/upstream/emscripten/emcc
checking for the c++ compiler (cxx) ... emcc
checking for the c++ compiler (cxx) ... emcc
checking for /root/emsdk/upstream/emscripten/emcc ... ok
checking for flags (-fPIC) ... ok
checking for flags (-fvisibility-inlines-hidden) ... ok
checking for flags (-O3) ... ok
checking for flags (-DNDEBUG) ... ok
[  5%]: cache compiling.release core/src/loss.cc
/root/emsdk/upstream/emscripten/emcc -c -fvisibility=hidden -fvisibility-inlines-hidden -O3 -Icore/src -DNDEBUG -o build/.objs/fasttext/wasm/wasm32/release/core/src/loss.cc.o core/src/loss.cc
[  5%]: cache compiling.release core/src/args.cc
/root/emsdk/upstream/emscripten/emcc -c -fvisibility=hidden -fvisibility-inlines-hidden -O3 -Icore/src -DNDEBUG -o build/.objs/fasttext/wasm/wasm32/release/core/src/args.cc.o core/src/args.cc
checking for flags (-MMD -MF) ... ok
checking for flags (-fdiagnostics-color=always) ... ok
[ 11%]: cache compiling.release core/src/dictionary.cc
/root/emsdk/upstream/emscripten/emcc -c -fvisibility=hidden -fvisibility-inlines-hidden -O3 -Icore/src -DNDEBUG -o build/.objs/fasttext/wasm/wasm32/release/core/src/dictionary.cc.o core/src/dictionary.cc
[ 16%]: cache compiling.release core/src/main.cc
/root/emsdk/upstream/emscripten/emcc -c -fvisibility=hidden -fvisibility-inlines-hidden -O3 -Icore/src -DNDEBUG -o build/.objs/fasttext/wasm/wasm32/release/core/src/main.cc.o core/src/main.cc
[ 22%]: cache compiling.release core/src/quantmatrix.cc
/root/emsdk/upstream/emscripten/emcc -c -fvisibility=hidden -fvisibility-inlines-hidden -O3 -Icore/src -DNDEBUG -o build/.objs/fasttext/wasm/wasm32/release/core/src/quantmatrix.cc.o core/src/quantmatrix.cc
[ 27%]: cache compiling.release core/src/autotune.cc
/root/emsdk/upstream/emscripten/emcc -c -fvisibility=hidden -fvisibility-inlines-hidden -O3 -Icore/src -DNDEBUG -o build/.objs/fasttext/wasm/wasm32/release/core/src/autotune.cc.o core/src/autotune.cc
[ 33%]: cache compiling.release core/src/fasttext.cc
/root/emsdk/upstream/emscripten/emcc -c -fvisibility=hidden -fvisibility-inlines-hidden -O3 -Icore/src -DNDEBUG -o build/.objs/fasttext/wasm/wasm32/release/core/src/fasttext.cc.o core/src/fasttext.cc
[ 38%]: cache compiling.release core/src/model.cc
/root/emsdk/upstream/emscripten/emcc -c -fvisibility=hidden -fvisibility-inlines-hidden -O3 -Icore/src -DNDEBUG -o build/.objs/fasttext/wasm/wasm32/release/core/src/model.cc.o core/src/model.cc
[ 44%]: cache compiling.release core/src/productquantizer.cc
/root/emsdk/upstream/emscripten/emcc -c -fvisibility=hidden -fvisibility-inlines-hidden -O3 -Icore/src -DNDEBUG -o build/.objs/fasttext/wasm/wasm32/release/core/src/productquantizer.cc.o core/src/productquantizer.cc
[ 50%]: cache compiling.release core/src/meter.cc
/root/emsdk/upstream/emscripten/emcc -c -fvisibility=hidden -fvisibility-inlines-hidden -O3 -Icore/src -DNDEBUG -o build/.objs/fasttext/wasm/wasm32/release/core/src/meter.cc.o core/src/meter.cc
[ 55%]: cache compiling.release core/src/matrix.cc
/root/emsdk/upstream/emscripten/emcc -c -fvisibility=hidden -fvisibility-inlines-hidden -O3 -Icore/src -DNDEBUG -o build/.objs/fasttext/wasm/wasm32/release/core/src/matrix.cc.o core/src/matrix.cc
[ 61%]: cache compiling.release core/src/vector.cc
/root/emsdk/upstream/emscripten/emcc -c -fvisibility=hidden -fvisibility-inlines-hidden -O3 -Icore/src -DNDEBUG -o build/.objs/fasttext/wasm/wasm32/release/core/src/vector.cc.o core/src/vector.cc
[ 66%]: cache compiling.release core/src/utils.cc
/root/emsdk/upstream/emscripten/emcc -c -fvisibility=hidden -fvisibility-inlines-hidden -O3 -Icore/src -DNDEBUG -o build/.objs/fasttext/wasm/wasm32/release/core/src/utils.cc.o core/src/utils.cc
[ 72%]: cache compiling.release core/src/densematrix.cc
/root/emsdk/upstream/emscripten/emcc -c -fvisibility=hidden -fvisibility-inlines-hidden -O3 -Icore/src -DNDEBUG -o build/.objs/fasttext/wasm/wasm32/release/core/src/densematrix.cc.o core/src/densematrix.cc
[ 77%]: cache compiling.release core/webassembly/fasttext_wasm.cc
/root/emsdk/upstream/emscripten/emcc -c -fvisibility=hidden -fvisibility-inlines-hidden -O3 -Icore/src -DNDEBUG -o build/.objs/fasttext/wasm/wasm32/release/core/webassembly/fasttext_wasm.cc.o core/webassembly/fasttext_wasm.cc
checking for em++ ... /root/emsdk/upstream/emscripten/em++
checking for the linker (ld) ... em++
checking for /root/emsdk/upstream/emscripten/em++ ... ok
checking for flags (-fPIC) ... ok
checking for flags (-O3) ... ok
checking for flags (-sALLOW_MEMORY_GROWTH) ... ok
checking for flags (-sEXPORTED_RUNTIME_METHODS=[addOnPostRun,FS]) ... ok
checking for flags (-sFORCE_FILESYSTEM) ... ok
checking for flags (-sMODULARIZE) ... ok
checking for flags (-sEXPORT_ES6) ... ok
checking for flags (-sEXPORT_NAME=FastTextModule) ... ok
checking for flags (-sWASMFS) ... ok
checking for flags (-sNO_INVOKE_RUN) ... ok
checking for flags (--embind-emit-tsd /work/fastText.wasm/dist/core/fasttext.d.ts) ... ok
checking for flags (--verbose) ... ok
[ 88%]: linking.release fasttext.mjs
/root/emsdk/upstream/emscripten/em++ -o /work/fastText.wasm/dist/core/fasttext.mjs build/.objs/fasttext/wasm/wasm32/release/core/src/loss.cc.o build/.objs/fasttext/wasm/wasm32/release/core/src/args.cc.o build/.objs/fasttext/wasm/wasm32/release/core/src/dictionary.cc.o build/.objs/fasttext/wasm/wasm32/release/core/src/main.cc.o build/.objs/fasttext/wasm/wasm32/release/core/src/quantmatrix.cc.o build/.objs/fasttext/wasm/wasm32/release/core/src/autotune.cc.o build/.objs/fasttext/wasm/wasm32/release/core/src/fasttext.cc.o build/.objs/fasttext/wasm/wasm32/release/core/src/model.cc.o build/.objs/fasttext/wasm/wasm32/release/core/src/productquantizer.cc.o build/.objs/fasttext/wasm/wasm32/release/core/src/meter.cc.o build/.objs/fasttext/wasm/wasm32/release/core/src/matrix.cc.o build/.objs/fasttext/wasm/wasm32/release/core/src/vector.cc.o build/.objs/fasttext/wasm/wasm32/release/core/src/utils.cc.o build/.objs/fasttext/wasm/wasm32/release/core/src/densematrix.cc.o build/.objs/fasttext/wasm/wasm32/release/core/webassembly/fasttext_wasm.cc.o -O3 -lembind -sALLOW_MEMORY_GROWTH -sEXPORTED_RUNTIME_METHODS=[addOnPostRun,FS] -sFORCE_FILESYSTEM -sMODULARIZE -sEXPORT_ES6 -sEXPORT_NAME=FastTextModule -sWASMFS -sNO_INVOKE_RUN --embind-emit-tsd /work/fastText.wasm/dist/core/fasttext.d.ts --verbose
wasm-ld: error: build/.objs/fasttext/wasm/wasm32/release/core/webassembly/fasttext_wasm.cc.o: undefined symbol: _embind_register_class_property
wasm-ld: error: build/.objs/fasttext/wasm/wasm32/release/core/webassembly/fasttext_wasm.cc.o: undefined symbol: _embind_register_class_property
wasm-ld: error: build/.objs/fasttext/wasm/wasm32/release/core/webassembly/fasttext_wasm.cc.o: undefined symbol: _embind_register_class_property
wasm-ld: error: build/.objs/fasttext/wasm/wasm32/release/core/webassembly/fasttext_wasm.cc.o: undefined symbol: _embind_register_class_property
wasm-ld: error: build/.objs/fasttext/wasm/wasm32/release/core/webassembly/fasttext_wasm.cc.o: undefined symbol: _embind_register_class_property
wasm-ld: error: build/.objs/fasttext/wasm/wasm32/release/core/webassembly/fasttext_wasm.cc.o: undefined symbol: _embind_register_class_property
wasm-ld: error: build/.objs/fasttext/wasm/wasm32/release/core/webassembly/fasttext_wasm.cc.o: undefined symbol: _embind_register_class_property
wasm-ld: error: build/.objs/fasttext/wasm/wasm32/release/core/webassembly/fasttext_wasm.cc.o: undefined symbol: _embind_register_class_property
wasm-ld: error: build/.objs/fasttext/wasm/wasm32/release/core/webassembly/fasttext_wasm.cc.o: undefined symbol: _embind_register_class_property
wasm-ld: error: build/.objs/fasttext/wasm/wasm32/release/core/webassembly/fasttext_wasm.cc.o: undefined symbol: _embind_register_class_property
wasm-ld: error: build/.objs/fasttext/wasm/wasm32/release/core/webassembly/fasttext_wasm.cc.o: undefined symbol: _embind_register_class_property
wasm-ld: error: build/.objs/fasttext/wasm/wasm32/release/core/webassembly/fasttext_wasm.cc.o: undefined symbol: _embind_register_class_property
wasm-ld: error: build/.objs/fasttext/wasm/wasm32/release/core/webassembly/fasttext_wasm.cc.o: undefined symbol: _embind_register_class_property
wasm-ld: error: build/.objs/fasttext/wasm/wasm32/release/core/webassembly/fasttext_wasm.cc.o: undefined symbol: _embind_register_class_property
wasm-ld: error: build/.objs/fasttext/wasm/wasm32/release/core/webassembly/fasttext_wasm.cc.o: undefined symbol: _embind_register_class_property
wasm-ld: error: build/.objs/fasttext/wasm/wasm32/release/core/webassembly/fasttext_wasm.cc.o: undefined symbol: _embind_register_class_property
wasm-ld: error: build/.objs/fasttext/wasm/wasm32/release/core/webassembly/fasttext_wasm.cc.o: undefined symbol: _embind_register_class_property
wasm-ld: error: build/.objs/fasttext/wasm/wasm32/release/core/webassembly/fasttext_wasm.cc.o: undefined symbol: _embind_register_class_property
wasm-ld: error: build/.objs/fasttext/wasm/wasm32/release/core/webassembly/fasttext_wasm.cc.o: undefined symbol: _embind_register_class_property
wasm-ld: error: build/.objs/fasttext/wasm/wasm32/release/core/webassembly/fasttext_wasm.cc.o: undefined symbol: _embind_register_class_property
wasm-ld: error: too many errors emitted, stopping now (use -error-limit=0 to see all errors)
em++: error: '/root/emsdk/upstream/bin/wasm-ld -o /work/fastText.wasm/dist/core/fasttext.wasm build/.objs/fasttext/wasm/wasm32/release/core/src/loss.cc.o build/.objs/fasttext/wasm/wasm32/release/core/src/args.cc.o build/.objs/fasttext/wasm/wasm32/release/core/src/dictionary.cc.o build/.objs/fasttext/wasm/wasm32/release/core/src/main.cc.o build/.objs/fasttext/wasm/wasm32/release/core/src/quantmatrix.cc.o build/.objs/fasttext/wasm/wasm32/release/core/src/autotune.cc.o build/.objs/fasttext/wasm/wasm32/release/core/src/fasttext.cc.o build/.objs/fasttext/wasm/wasm32/release/core/src/model.cc.o build/.objs/fasttext/wasm/wasm32/release/core/src/productquantizer.cc.o build/.objs/fasttext/wasm/wasm32/release/core/src/meter.cc.o build/.objs/fasttext/wasm/wasm32/release/core/src/matrix.cc.o build/.objs/fasttext/wasm/wasm32/release/core/src/vector.cc.o build/.objs/fasttext/wasm/wasm32/release/core/src/utils.cc.o build/.objs/fasttext/wasm/wasm32/release/core/src/densematrix.cc.o build/.objs/fasttext/wasm/wasm32/release/core/webassembly/fasttext_wasm.cc.o -L/root/emsdk/upstream/emscripten/cache/sysroot/lib/wasm32-emscripten --whole-archive -lembind-rtti --no-whole-archive -lGL -lal -lhtml5 -lstubs -lnoexit -lc -ldlmalloc -lcompiler_rt -lc++-noexcept -lc++abi-noexcept -lsockets -lwasmfs -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr /tmp/tmpxjmyecurlibemscripten_js_symbols.so --strip-debug --export-if-defined=main --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_argc_argv --export=_wasmfs_read_file --export=_wasmfs_write_file --export=_wasmfs_open --export=_wasmfs_allocate --export=_wasmfs_close --export=_wasmfs_write --export=_wasmfs_pwrite --export=_wasmfs_rename --export=_wasmfs_mkdir --export=_wasmfs_unlink --export=_wasmfs_chdir --export=_wasmfs_mknod --export=_wasmfs_rmdir --export=_wasmfs_read --export=_wasmfs_pread --export=_wasmfs_symlink --export=_wasmfs_truncate --export=_wasmfs_ftruncate --export=_wasmfs_stat --export=_wasmfs_lstat --export=_wasmfs_chmod --export=_wasmfs_fchmod --export=_wasmfs_lchmod --export=_wasmfs_utime --export=_wasmfs_llseek --export=_wasmfs_identify --export=_wasmfs_readlink --export=_wasmfs_readdir_start --export=_wasmfs_readdir_get --export=_wasmfs_readdir_finish --export=_wasmfs_get_cwd --export=stackSave --export=stackRestore --export=stackAlloc --export=__errno_location --export=__get_temp_ret --export=__set_temp_ret --export=malloc --export=free --export=__wasm_call_ctors --export-table -z stack-size=65536 --initial-memory=16777216 --no-entry --max-memory=2147483648 --global-base=1024' failed (returned 1)
error: execv(/root/emsdk/upstream/emscripten/em++ -o /work/fastText.wasm/dist/core/fasttext.mjs build/.objs/fasttext/wasm/wasm32/release/core/src/loss.cc.o build/.objs/fasttext/wasm/wasm32/release/core/src/args.cc.o build/.objs/fasttext/wasm/wasm32/release/core/src/dictionary.cc.o build/.objs/fasttext/wasm/wasm32/release/core/src/main.cc.o build/.objs/fasttext/wasm/wasm32/release/core/src/quantmatrix.cc.o build/.objs/fasttext/wasm/wasm32/release/core/src/autotune.cc.o build/.objs/fasttext/wasm/wasm32/release/core/src/fasttext.cc.o build/.objs/fasttext/wasm/wasm32/release/core/src/model.cc.o build/.objs/fasttext/wasm/wasm32/release/core/src/productquantizer.cc.o build/.objs/fasttext/wasm/wasm32/release/core/src/meter.cc.o build/.objs/fasttext/wasm/wasm32/release/core/src/matrix.cc.o build/.objs/fasttext/wasm/wasm32/release/core/src/vector.cc.o build/.objs/fasttext/wasm/wasm32/release/core/src/utils.cc.o build/.objs/fasttext/wasm/wasm32/release/core/src/densematrix.cc.o build/.objs/fasttext/wasm/wasm32/release/core/webassembly/fasttext_wasm.cc.o -O3 -lembind -sALLOW_MEMORY_GROWTH -sEXPORTED_RUNTIME_METHODS=[addOnPostRun,FS] -sFORCE_FILESYSTEM -sMODULARIZE -sEXPORT_ES6 -sEXPORT_NAME=FastTextModule -sWASMFS -sNO_INVOKE_RUN --embind-emit-tsd /work/fastText.wasm/dist/core/fasttext.d.ts --verbose) failed(1)
DreamOfIce commented 1 year ago

BTW, I didn't find this symbol in the symbol list json

sbc100 commented 1 year ago

Looks like this was fixed in #19875. This change will be available in 3.1.45, or you can using emsdk install tot to try it out today.

sbc100 commented 1 year ago

Hopefully that answers your question and we can close this issue?

DreamOfIce commented 1 year ago

This problem is solved by using the tot version build, but the generated dts are empty.

Let's discuss this problem in another issue later.