emscripten-core / emscripten

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

Undefined/duplicate libc++ symbols when linking 2 libraries together #19742

Open susoferreira opened 1 year ago

susoferreira commented 1 year ago

What im doing

Im trying to compile 2 libraries libsokol and libemu to wasm using entry.c (just a wrapper in c to call the real main, inside libemu), i get undefined symbol error for libc++ symbols, but libc++ is being linked if i understand the debug output correctly? i also tried adding -lc++ and EMCC_FORCE_STDLIBS=1 to the command, giving the same results,however when i add both of those options to the command at the same time i get duplicate symbol errors for those same symbols

Maybe this has something to do with the libraries being compiled from zig? They compiled without errors though

Version of emscripten/emsdk:

emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.42 (6ede0b8fc1c979bb206148804bfb48b472ccc3da)
clang version 17.0.0 (https://github.com/llvm/llvm-project f3b64887de61020c09404bfee97b2fadd30df10a)
Target: wasm32-unknown-emscripten
Thread model: posix
InstalledDir: /run/media/suso/SHARE/Programacion/Zig/maquina-sencilla/emsdk/upstream/bin

Failing command line in full:

EMCC_DEBUG=1 emcc src/entry.c -O0 -ozig-out/web/emu.html -Lzig-out/lib -lemu -lsokol -sNO_FILESYSTEM=1
tools.filelock:DEBUG: Attempting to acquire lock 140051960695184 on /tmp/emscripten_temp/emscripten.lock
tools.filelock:DEBUG: Lock 140051960695184 acquired on /tmp/emscripten_temp/emscripten.lock
emcc:WARNING: invocation: /run/media/suso/SHARE/Programacion/Zig/maquina-sencilla/emsdk/upstream/emscripten/emcc.py src/entry.c -O0 -ozig-out/web/emu.html -Lzig-out/lib -lemu -lsokol -sNO_FILESYSTEM=1 (in /run/media/suso/SHARE/Programacion/Zig/maquina-sencilla)
profiler:DEBUG: block "parse arguments" took 0.000 seconds
shared:DEBUG: successfully executed /run/media/suso/SHARE/Programacion/Zig/maquina-sencilla/emsdk/upstream/bin/clang --version
shared:DEBUG: sanity file up-to-date: /run/media/suso/SHARE/Programacion/Zig/maquina-sencilla/emsdk/upstream/emscripten/cache/sanity.txt
shared:DEBUG: successfully executed /run/media/suso/SHARE/Programacion/Zig/maquina-sencilla/emsdk/node/16.20.0_64bit/bin/node --version
shared:DEBUG: successfully executed /run/media/suso/SHARE/Programacion/Zig/maquina-sencilla/emsdk/upstream/bin/clang -print-targets
shared:INFO: (Emscripten: Running sanity checks)
shared:DEBUG: successfully executed /run/media/suso/SHARE/Programacion/Zig/maquina-sencilla/emsdk/node/16.20.0_64bit/bin/node -e console.log("hello")
profiler:DEBUG: block "check_node" took 0.046 seconds
profiler:DEBUG: block "sanity LLVM" took 0.000 seconds
profiler:DEBUG: block "check_sanity" took 0.075 seconds
profiler:DEBUG: block "setup" took 0.000 seconds
profiler:DEBUG: block "ensure_sysroot" took 0.000 seconds
emcc:DEBUG: compiling source file: src/entry.c
shared:DEBUG: successfully executed /run/media/suso/SHARE/Programacion/Zig/maquina-sencilla/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 -DEMSCRIPTEN -Werror=implicit-function-declaration --sysroot=/run/media/suso/SHARE/Programacion/Zig/maquina-sencilla/emsdk/upstream/emscripten/cache/sysroot -Xclang -iwithsysroot/include/fakesdl -Xclang -iwithsysroot/include/compat -O0 src/entry.c -c -o /tmp/emscripten_temp/entry_0.o
profiler:DEBUG: block "compile inputs" took 0.020 seconds
feature_matrix:DEBUG: cannot use PROMISE_ANY because MIN_CHROME_VERSION is too old: 75
feature_matrix:DEBUG: cannot use BULK_MEMORY because MIN_FIREFOX_VERSION is too old: 68
profiler:DEBUG: block "linker_setup" took 0.001 seconds
emcc:DEBUG: looking for library "emu"
emcc:DEBUG: found library "libemu.a" at zig-out/lib/libemu.a
emcc:DEBUG: looking for library "sokol"
emcc:DEBUG: found library "libsokol.a" at zig-out/lib/libsokol.a
profiler:DEBUG: block "calculate linker inputs" took 0.003 seconds
shared:DEBUG: successfully executed /run/media/suso/SHARE/Programacion/Zig/maquina-sencilla/emsdk/node/16.20.0_64bit/bin/node /run/media/suso/SHARE/Programacion/Zig/maquina-sencilla/emsdk/upstream/emscripten/src/compiler.js /tmp/emscripten_temp/tmpn4e9l66k.json --symbols-only
profiler:DEBUG: block "JS symbol generation" took 0.244 seconds
system_libs:DEBUG: including libGL (libGL.a)
system_libs:DEBUG: including libal (libal.a)
system_libs:DEBUG: including libhtml5 (libhtml5.a)
system_libs:DEBUG: including libstubs (libstubs-debug.a)
system_libs:DEBUG: including libnoexit (libnoexit.a)
system_libs:DEBUG: including libc (libc-debug.a)
system_libs:DEBUG: including libmalloc (libdlmalloc.a)
system_libs:DEBUG: including libcompiler_rt (libcompiler_rt.a)
system_libs:DEBUG: including libc++ (libc++-noexcept.a)
system_libs:DEBUG: including libc++abi (libc++abi-debug-noexcept.a)
system_libs:DEBUG: including libsockets (libsockets.a)
profiler:DEBUG: block "calculate system libraries" took 0.004 seconds
emcc:DEBUG: linking: ['/tmp/emscripten_temp/entry_0.o', '-Lzig-out/lib', 'zig-out/lib/libemu.a', 'zig-out/lib/libsokol.a', '-L/run/media/suso/SHARE/Programacion/Zig/maquina-sencilla/emsdk/upstream/emscripten/cache/sysroot/lib/wasm32-emscripten', '-lGL', '-lal', '-lhtml5', '-lstubs-debug', '-lnoexit', '-lc-debug', '-ldlmalloc', '-lcompiler_rt', '-lc++-noexcept', '-lc++abi-debug-noexcept', '-lsockets']
wasm-ld: warning: function signature mismatch: drawAssemblyEditor
>>> defined as (i32) -> void in zig-out/lib/libemu.a(/run/media/suso/SHARE/Programacion/Zig/maquina-sencilla/zig-cache/o/0ed28ba9d1ef977fb7f4043874a6a18c/libemu.a.o)
>>> defined as () -> void in zig-out/lib/libemu.a(/run/media/suso/SHARE/Programacion/Zig/maquina-sencilla/zig-cache/o/cc6a7f9d6e74310385f34d10612d85a9/TextEditorWrappers.o)

wasm-ld: warning: function signature mismatch: getAssemblyEditorText
>>> defined as (i32) -> i32 in zig-out/lib/libemu.a(/run/media/suso/SHARE/Programacion/Zig/maquina-sencilla/zig-cache/o/0ed28ba9d1ef977fb7f4043874a6a18c/libemu.a.o)
>>> defined as () -> i32 in zig-out/lib/libemu.a(/run/media/suso/SHARE/Programacion/Zig/maquina-sencilla/zig-cache/o/cc6a7f9d6e74310385f34d10612d85a9/TextEditorWrappers.o)

wasm-ld: error: zig-out/lib/libemu.a(/run/media/suso/SHARE/Programacion/Zig/maquina-sencilla/zig-cache/o/d923a3e86ae0761c674437575ebe27b1/TextEditor.o): undefined symbol: std::__1::chrono::system_clock::now()
wasm-ld: error: zig-out/lib/libemu.a(/run/media/suso/SHARE/Programacion/Zig/maquina-sencilla/zig-cache/o/d923a3e86ae0761c674437575ebe27b1/TextEditor.o): undefined symbol: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>::~basic_string()
wasm-ld: error: zig-out/lib/libemu.a(/run/media/suso/SHARE/Programacion/Zig/maquina-sencilla/zig-cache/o/d923a3e86ae0761c674437575ebe27b1/TextEditor.o): undefined symbol: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>::~basic_string()
wasm-ld: error: zig-out/lib/libemu.a(/run/media/suso/SHARE/Programacion/Zig/maquina-sencilla/zig-cache/o/d923a3e86ae0761c674437575ebe27b1/TextEditor.o): undefined symbol: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>::~basic_string()
wasm-ld: error: zig-out/lib/libemu.a(/run/media/suso/SHARE/Programacion/Zig/maquina-sencilla/zig-cache/o/d923a3e86ae0761c674437575ebe27b1/TextEditor.o): undefined symbol: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>::~basic_string()
wasm-ld: error: zig-out/lib/libemu.a(/run/media/suso/SHARE/Programacion/Zig/maquina-sencilla/zig-cache/o/d923a3e86ae0761c674437575ebe27b1/TextEditor.o): undefined symbol: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>::~basic_string()
wasm-ld: error: zig-out/lib/libemu.a(/run/media/suso/SHARE/Programacion/Zig/maquina-sencilla/zig-cache/o/d923a3e86ae0761c674437575ebe27b1/TextEditor.o): undefined symbol: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>::~basic_string()
wasm-ld: error: zig-out/lib/libemu.a(/run/media/suso/SHARE/Programacion/Zig/maquina-sencilla/zig-cache/o/d923a3e86ae0761c674437575ebe27b1/TextEditor.o): undefined symbol: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>::~basic_string()
wasm-ld: error: zig-out/lib/libemu.a(/run/media/suso/SHARE/Programacion/Zig/maquina-sencilla/zig-cache/o/d923a3e86ae0761c674437575ebe27b1/TextEditor.o): undefined symbol: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>::~basic_string()
wasm-ld: error: zig-out/lib/libemu.a(/run/media/suso/SHARE/Programacion/Zig/maquina-sencilla/zig-cache/o/d923a3e86ae0761c674437575ebe27b1/TextEditor.o): undefined symbol: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>::~basic_string()
wasm-ld: error: zig-out/lib/libemu.a(/run/media/suso/SHARE/Programacion/Zig/maquina-sencilla/zig-cache/o/d923a3e86ae0761c674437575ebe27b1/TextEditor.o): undefined symbol: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>::~basic_string()
wasm-ld: error: zig-out/lib/libemu.a(/run/media/suso/SHARE/Programacion/Zig/maquina-sencilla/zig-cache/o/d923a3e86ae0761c674437575ebe27b1/TextEditor.o): undefined symbol: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>::~basic_string()
wasm-ld: error: zig-out/lib/libemu.a(/run/media/suso/SHARE/Programacion/Zig/maquina-sencilla/zig-cache/o/d923a3e86ae0761c674437575ebe27b1/TextEditor.o): undefined symbol: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>::operator=(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&)
wasm-ld: error: zig-out/lib/libemu.a(/run/media/suso/SHARE/Programacion/Zig/maquina-sencilla/zig-cache/o/d923a3e86ae0761c674437575ebe27b1/TextEditor.o): undefined symbol: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>::operator=(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&)
wasm-ld: error: zig-out/lib/libemu.a(/run/media/suso/SHARE/Programacion/Zig/maquina-sencilla/zig-cache/o/d923a3e86ae0761c674437575ebe27b1/TextEditor.o): undefined symbol: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>::operator=(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&)
wasm-ld: error: zig-out/lib/libemu.a(/run/media/suso/SHARE/Programacion/Zig/maquina-sencilla/zig-cache/o/d923a3e86ae0761c674437575ebe27b1/TextEditor.o): undefined symbol: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>::operator=(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&)
wasm-ld: error: zig-out/lib/libemu.a(/run/media/suso/SHARE/Programacion/Zig/maquina-sencilla/zig-cache/o/d923a3e86ae0761c674437575ebe27b1/TextEditor.o): undefined symbol: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>::assign(char const*)
wasm-ld: error: zig-out/lib/libemu.a(/run/media/suso/SHARE/Programacion/Zig/maquina-sencilla/zig-cache/o/d923a3e86ae0761c674437575ebe27b1/TextEditor.o): undefined symbol: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>::~basic_string()
wasm-ld: error: zig-out/lib/libemu.a(/run/media/suso/SHARE/Programacion/Zig/maquina-sencilla/zig-cache/o/d923a3e86ae0761c674437575ebe27b1/TextEditor.o): undefined symbol: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>::~basic_string()
wasm-ld: error: zig-out/lib/libemu.a(/run/media/suso/SHARE/Programacion/Zig/maquina-sencilla/zig-cache/o/d923a3e86ae0761c674437575ebe27b1/TextEditor.o): undefined symbol: std::__1::locale::locale()
wasm-ld: error: too many errors emitted, stopping now (use -error-limit=0 to see all errors)
emcc: error: '/run/media/suso/SHARE/Programacion/Zig/maquina-sencilla/emsdk/upstream/bin/wasm-ld -o zig-out/web/emu.wasm /tmp/emscripten_temp/entry_0.o -Lzig-out/lib zig-out/lib/libemu.a zig-out/lib/libsokol.a -L/run/media/suso/SHARE/Programacion/Zig/maquina-sencilla/emsdk/upstream/emscripten/cache/sysroot/lib/wasm32-emscripten -lGL -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/emscripten_temp/tmpuwljfpxdlibemscripten_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-if-defined=fflush --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=stackSave --export=stackRestore --export=stackAlloc --export=__errno_location --export=__get_temp_ret --export=__set_temp_ret --export=__wasm_call_ctors --export-table -z stack-size=65536 --initial-memory=16777216 --no-entry --max-memory=16777216 --stack-first' failed (returned 1)
profiler:DEBUG: block "link" raised an exception after 0.066 seconds
profiler:DEBUG: block "main" raised an exception after 0.414 seconds
not cleaning up temp files since in debug-save mode, see them in /tmp/emscripten_temp
tools.filelock:DEBUG: Attempting to release lock 140051960695184 on /tmp/emscripten_temp/emscripten.lock
tools.filelock:DEBUG: Lock 140051960695184 released on /tmp/emscripten_temp/emscripten.lock

Full link command and output with -v appended:

EMCC_DEBUG=1 emcc src/entry.c -O0 -ozig-out/web/emu.html -Lzig-out/lib -lemu -lsokol -sNO_FILESYSTEM=1 -v
tools.filelock:DEBUG: Attempting to acquire lock 140235424173648 on /tmp/emscripten_temp/emscripten.lock
tools.filelock:DEBUG: Lock 140235424173648 acquired on /tmp/emscripten_temp/emscripten.lock
emcc:WARNING: invocation: /run/media/suso/SHARE/Programacion/Zig/maquina-sencilla/emsdk/upstream/emscripten/emcc.py src/entry.c -O0 -ozig-out/web/emu.html -Lzig-out/lib -lemu -lsokol -sNO_FILESYSTEM=1 -v (in /run/media/suso/SHARE/Programacion/Zig/maquina-sencilla)
profiler:DEBUG: block "parse arguments" took 0.000 seconds
 "/run/media/suso/SHARE/Programacion/Zig/maquina-sencilla/emsdk/upstream/bin/clang" --version
shared:DEBUG: successfully executed /run/media/suso/SHARE/Programacion/Zig/maquina-sencilla/emsdk/upstream/bin/clang --version
shared:DEBUG: sanity file up-to-date: /run/media/suso/SHARE/Programacion/Zig/maquina-sencilla/emsdk/upstream/emscripten/cache/sanity.txt
shared:DEBUG: successfully executed /run/media/suso/SHARE/Programacion/Zig/maquina-sencilla/emsdk/node/16.20.0_64bit/bin/node --version
shared:DEBUG: successfully executed /run/media/suso/SHARE/Programacion/Zig/maquina-sencilla/emsdk/upstream/bin/clang -print-targets
shared:INFO: (Emscripten: Running sanity checks)
shared:DEBUG: successfully executed /run/media/suso/SHARE/Programacion/Zig/maquina-sencilla/emsdk/node/16.20.0_64bit/bin/node -e console.log("hello")
profiler:DEBUG: block "check_node" took 0.043 seconds
profiler:DEBUG: block "sanity LLVM" took 0.000 seconds
profiler:DEBUG: block "check_sanity" took 0.071 seconds
profiler:DEBUG: block "setup" took 0.000 seconds
profiler:DEBUG: block "ensure_sysroot" took 0.000 seconds
emcc:DEBUG: compiling source file: src/entry.c
 "/run/media/suso/SHARE/Programacion/Zig/maquina-sencilla/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 -DEMSCRIPTEN -Werror=implicit-function-declaration --sysroot=/run/media/suso/SHARE/Programacion/Zig/maquina-sencilla/emsdk/upstream/emscripten/cache/sysroot -Xclang -iwithsysroot/include/fakesdl -Xclang -iwithsysroot/include/compat -O0 -v src/entry.c -c -o /tmp/emscripten_temp/entry_0.o
clang version 17.0.0 (https://github.com/llvm/llvm-project f3b64887de61020c09404bfee97b2fadd30df10a)
Target: wasm32-unknown-emscripten
Thread model: posix
InstalledDir: /run/media/suso/SHARE/Programacion/Zig/maquina-sencilla/emsdk/upstream/bin
 (in-process)
 "/run/media/suso/SHARE/Programacion/Zig/maquina-sencilla/emsdk/upstream/bin/clang-17" -cc1 -triple wasm32-unknown-emscripten -emit-obj -mrelax-all -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name entry.c -mrelocation-model static -mframe-pointer=none -ffp-contract=on -fno-rounding-math -mconstructor-aliases -target-cpu generic -debugger-tuning=gdb -v -fcoverage-compilation-dir=/run/media/suso/SHARE/Programacion/Zig/maquina-sencilla -resource-dir /run/media/suso/SHARE/Programacion/Zig/maquina-sencilla/emsdk/upstream/lib/clang/17 -D EMSCRIPTEN -isysroot /run/media/suso/SHARE/Programacion/Zig/maquina-sencilla/emsdk/upstream/emscripten/cache/sysroot -internal-isystem /run/media/suso/SHARE/Programacion/Zig/maquina-sencilla/emsdk/upstream/lib/clang/17/include -internal-isystem /run/media/suso/SHARE/Programacion/Zig/maquina-sencilla/emsdk/upstream/emscripten/cache/sysroot/include/wasm32-emscripten -internal-isystem /run/media/suso/SHARE/Programacion/Zig/maquina-sencilla/emsdk/upstream/emscripten/cache/sysroot/include -O0 -Werror=implicit-function-declaration -fdebug-compilation-dir=/run/media/suso/SHARE/Programacion/Zig/maquina-sencilla -ferror-limit 19 -fvisibility=default -fgnuc-version=4.2.1 -fignore-exceptions -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/entry_0.o -x c src/entry.c
clang -cc1 version 17.0.0 based upon LLVM 17.0.0git default target x86_64-unknown-linux-gnu
ignoring nonexistent directory "/run/media/suso/SHARE/Programacion/Zig/maquina-sencilla/emsdk/upstream/emscripten/cache/sysroot/include/wasm32-emscripten"
#include "..." search starts here:
#include <...> search starts here:
 /run/media/suso/SHARE/Programacion/Zig/maquina-sencilla/emsdk/upstream/emscripten/cache/sysroot/include/fakesdl
 /run/media/suso/SHARE/Programacion/Zig/maquina-sencilla/emsdk/upstream/emscripten/cache/sysroot/include/compat
 /run/media/suso/SHARE/Programacion/Zig/maquina-sencilla/emsdk/upstream/lib/clang/17/include
 /run/media/suso/SHARE/Programacion/Zig/maquina-sencilla/emsdk/upstream/emscripten/cache/sysroot/include
End of search list.
shared:DEBUG: successfully executed /run/media/suso/SHARE/Programacion/Zig/maquina-sencilla/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 -DEMSCRIPTEN -Werror=implicit-function-declaration --sysroot=/run/media/suso/SHARE/Programacion/Zig/maquina-sencilla/emsdk/upstream/emscripten/cache/sysroot -Xclang -iwithsysroot/include/fakesdl -Xclang -iwithsysroot/include/compat -O0 -v src/entry.c -c -o /tmp/emscripten_temp/entry_0.o
profiler:DEBUG: block "compile inputs" took 0.021 seconds
feature_matrix:DEBUG: cannot use PROMISE_ANY because MIN_CHROME_VERSION is too old: 75
feature_matrix:DEBUG: cannot use BULK_MEMORY because MIN_FIREFOX_VERSION is too old: 68
profiler:DEBUG: block "linker_setup" took 0.001 seconds
emcc:DEBUG: looking for library "emu"
emcc:DEBUG: found library "libemu.a" at zig-out/lib/libemu.a
emcc:DEBUG: looking for library "sokol"
emcc:DEBUG: found library "libsokol.a" at zig-out/lib/libsokol.a
profiler:DEBUG: block "calculate linker inputs" took 0.003 seconds
 "/run/media/suso/SHARE/Programacion/Zig/maquina-sencilla/emsdk/node/16.20.0_64bit/bin/node" /run/media/suso/SHARE/Programacion/Zig/maquina-sencilla/emsdk/upstream/emscripten/src/compiler.js /tmp/emscripten_temp/tmppbkh106l.json --symbols-only
shared:DEBUG: successfully executed /run/media/suso/SHARE/Programacion/Zig/maquina-sencilla/emsdk/node/16.20.0_64bit/bin/node /run/media/suso/SHARE/Programacion/Zig/maquina-sencilla/emsdk/upstream/emscripten/src/compiler.js /tmp/emscripten_temp/tmppbkh106l.json --symbols-only
profiler:DEBUG: block "JS symbol generation" took 0.271 seconds
system_libs:DEBUG: including libGL (libGL.a)
system_libs:DEBUG: including libal (libal.a)
system_libs:DEBUG: including libhtml5 (libhtml5.a)
system_libs:DEBUG: including libstubs (libstubs-debug.a)
system_libs:DEBUG: including libnoexit (libnoexit.a)
system_libs:DEBUG: including libc (libc-debug.a)
system_libs:DEBUG: including libmalloc (libdlmalloc.a)
system_libs:DEBUG: including libcompiler_rt (libcompiler_rt.a)
system_libs:DEBUG: including libc++ (libc++-noexcept.a)
system_libs:DEBUG: including libc++abi (libc++abi-debug-noexcept.a)
system_libs:DEBUG: including libsockets (libsockets.a)
profiler:DEBUG: block "calculate system libraries" took 0.004 seconds
emcc:DEBUG: linking: ['/tmp/emscripten_temp/entry_0.o', '-Lzig-out/lib', 'zig-out/lib/libemu.a', 'zig-out/lib/libsokol.a', '-L/run/media/suso/SHARE/Programacion/Zig/maquina-sencilla/emsdk/upstream/emscripten/cache/sysroot/lib/wasm32-emscripten', '-lGL', '-lal', '-lhtml5', '-lstubs-debug', '-lnoexit', '-lc-debug', '-ldlmalloc', '-lcompiler_rt', '-lc++-noexcept', '-lc++abi-debug-noexcept', '-lsockets']
 "/run/media/suso/SHARE/Programacion/Zig/maquina-sencilla/emsdk/upstream/bin/wasm-ld" -o zig-out/web/emu.wasm /tmp/emscripten_temp/entry_0.o -Lzig-out/lib zig-out/lib/libemu.a zig-out/lib/libsokol.a -L/run/media/suso/SHARE/Programacion/Zig/maquina-sencilla/emsdk/upstream/emscripten/cache/sysroot/lib/wasm32-emscripten -lGL -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/emscripten_temp/tmpt6vedsnvlibemscripten_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-if-defined=fflush --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=stackSave --export=stackRestore --export=stackAlloc --export=__errno_location --export=__get_temp_ret --export=__set_temp_ret --export=__wasm_call_ctors --export-table -z stack-size=65536 --initial-memory=16777216 --no-entry --max-memory=16777216 --stack-first
wasm-ld: warning: function signature mismatch: drawAssemblyEditor
>>> defined as (i32) -> void in zig-out/lib/libemu.a(/run/media/suso/SHARE/Programacion/Zig/maquina-sencilla/zig-cache/o/0ed28ba9d1ef977fb7f4043874a6a18c/libemu.a.o)
>>> defined as () -> void in zig-out/lib/libemu.a(/run/media/suso/SHARE/Programacion/Zig/maquina-sencilla/zig-cache/o/cc6a7f9d6e74310385f34d10612d85a9/TextEditorWrappers.o)

wasm-ld: warning: function signature mismatch: getAssemblyEditorText
>>> defined as (i32) -> i32 in zig-out/lib/libemu.a(/run/media/suso/SHARE/Programacion/Zig/maquina-sencilla/zig-cache/o/0ed28ba9d1ef977fb7f4043874a6a18c/libemu.a.o)
>>> defined as () -> i32 in zig-out/lib/libemu.a(/run/media/suso/SHARE/Programacion/Zig/maquina-sencilla/zig-cache/o/cc6a7f9d6e74310385f34d10612d85a9/TextEditorWrappers.o)

wasm-ld: error: zig-out/lib/libemu.a(/run/media/suso/SHARE/Programacion/Zig/maquina-sencilla/zig-cache/o/d923a3e86ae0761c674437575ebe27b1/TextEditor.o): undefined symbol: std::__1::chrono::system_clock::now()
wasm-ld: error: zig-out/lib/libemu.a(/run/media/suso/SHARE/Programacion/Zig/maquina-sencilla/zig-cache/o/d923a3e86ae0761c674437575ebe27b1/TextEditor.o): undefined symbol: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>::~basic_string()
wasm-ld: error: zig-out/lib/libemu.a(/run/media/suso/SHARE/Programacion/Zig/maquina-sencilla/zig-cache/o/d923a3e86ae0761c674437575ebe27b1/TextEditor.o): undefined symbol: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>::~basic_string()
wasm-ld: error: zig-out/lib/libemu.a(/run/media/suso/SHARE/Programacion/Zig/maquina-sencilla/zig-cache/o/d923a3e86ae0761c674437575ebe27b1/TextEditor.o): undefined symbol: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>::~basic_string()
wasm-ld: error: zig-out/lib/libemu.a(/run/media/suso/SHARE/Programacion/Zig/maquina-sencilla/zig-cache/o/d923a3e86ae0761c674437575ebe27b1/TextEditor.o): undefined symbol: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>::~basic_string()
wasm-ld: error: zig-out/lib/libemu.a(/run/media/suso/SHARE/Programacion/Zig/maquina-sencilla/zig-cache/o/d923a3e86ae0761c674437575ebe27b1/TextEditor.o): undefined symbol: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>::~basic_string()
wasm-ld: error: zig-out/lib/libemu.a(/run/media/suso/SHARE/Programacion/Zig/maquina-sencilla/zig-cache/o/d923a3e86ae0761c674437575ebe27b1/TextEditor.o): undefined symbol: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>::~basic_string()
wasm-ld: error: zig-out/lib/libemu.a(/run/media/suso/SHARE/Programacion/Zig/maquina-sencilla/zig-cache/o/d923a3e86ae0761c674437575ebe27b1/TextEditor.o): undefined symbol: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>::~basic_string()
wasm-ld: error: zig-out/lib/libemu.a(/run/media/suso/SHARE/Programacion/Zig/maquina-sencilla/zig-cache/o/d923a3e86ae0761c674437575ebe27b1/TextEditor.o): undefined symbol: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>::~basic_string()
wasm-ld: error: zig-out/lib/libemu.a(/run/media/suso/SHARE/Programacion/Zig/maquina-sencilla/zig-cache/o/d923a3e86ae0761c674437575ebe27b1/TextEditor.o): undefined symbol: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>::~basic_string()
wasm-ld: error: zig-out/lib/libemu.a(/run/media/suso/SHARE/Programacion/Zig/maquina-sencilla/zig-cache/o/d923a3e86ae0761c674437575ebe27b1/TextEditor.o): undefined symbol: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>::~basic_string()
wasm-ld: error: zig-out/lib/libemu.a(/run/media/suso/SHARE/Programacion/Zig/maquina-sencilla/zig-cache/o/d923a3e86ae0761c674437575ebe27b1/TextEditor.o): undefined symbol: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>::~basic_string()
wasm-ld: error: zig-out/lib/libemu.a(/run/media/suso/SHARE/Programacion/Zig/maquina-sencilla/zig-cache/o/d923a3e86ae0761c674437575ebe27b1/TextEditor.o): undefined symbol: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>::operator=(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&)
wasm-ld: error: zig-out/lib/libemu.a(/run/media/suso/SHARE/Programacion/Zig/maquina-sencilla/zig-cache/o/d923a3e86ae0761c674437575ebe27b1/TextEditor.o): undefined symbol: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>::operator=(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&)
wasm-ld: error: zig-out/lib/libemu.a(/run/media/suso/SHARE/Programacion/Zig/maquina-sencilla/zig-cache/o/d923a3e86ae0761c674437575ebe27b1/TextEditor.o): undefined symbol: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>::operator=(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&)
wasm-ld: error: zig-out/lib/libemu.a(/run/media/suso/SHARE/Programacion/Zig/maquina-sencilla/zig-cache/o/d923a3e86ae0761c674437575ebe27b1/TextEditor.o): undefined symbol: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>::operator=(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&)
wasm-ld: error: zig-out/lib/libemu.a(/run/media/suso/SHARE/Programacion/Zig/maquina-sencilla/zig-cache/o/d923a3e86ae0761c674437575ebe27b1/TextEditor.o): undefined symbol: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>::assign(char const*)
wasm-ld: error: zig-out/lib/libemu.a(/run/media/suso/SHARE/Programacion/Zig/maquina-sencilla/zig-cache/o/d923a3e86ae0761c674437575ebe27b1/TextEditor.o): undefined symbol: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>::~basic_string()
wasm-ld: error: zig-out/lib/libemu.a(/run/media/suso/SHARE/Programacion/Zig/maquina-sencilla/zig-cache/o/d923a3e86ae0761c674437575ebe27b1/TextEditor.o): undefined symbol: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>::~basic_string()
wasm-ld: error: zig-out/lib/libemu.a(/run/media/suso/SHARE/Programacion/Zig/maquina-sencilla/zig-cache/o/d923a3e86ae0761c674437575ebe27b1/TextEditor.o): undefined symbol: std::__1::locale::locale()
wasm-ld: error: too many errors emitted, stopping now (use -error-limit=0 to see all errors)
emcc: error: '/run/media/suso/SHARE/Programacion/Zig/maquina-sencilla/emsdk/upstream/bin/wasm-ld -o zig-out/web/emu.wasm /tmp/emscripten_temp/entry_0.o -Lzig-out/lib zig-out/lib/libemu.a zig-out/lib/libsokol.a -L/run/media/suso/SHARE/Programacion/Zig/maquina-sencilla/emsdk/upstream/emscripten/cache/sysroot/lib/wasm32-emscripten -lGL -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/emscripten_temp/tmpt6vedsnvlibemscripten_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-if-defined=fflush --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=stackSave --export=stackRestore --export=stackAlloc --export=__errno_location --export=__get_temp_ret --export=__set_temp_ret --export=__wasm_call_ctors --export-table -z stack-size=65536 --initial-memory=16777216 --no-entry --max-memory=16777216 --stack-first' failed (returned 1)
profiler:DEBUG: block "link" raised an exception after 0.072 seconds
profiler:DEBUG: block "main" raised an exception after 0.444 seconds
not cleaning up temp files since in debug-save mode, see them in /tmp/emscripten_temp
tools.filelock:DEBUG: Attempting to release lock 140235424173648 on /tmp/emscripten_temp/emscripten.lock
tools.filelock:DEBUG: Lock 140235424173648 released on /tmp/emscripten_temp/emscripten.lock
sbc100 commented 1 year ago

It looks like zig-out/lib/libemu.a was compiled against a different version of libc++ to the one in emscripten. The symbol in zig-out/lib/libemu.a all start with std::__1:: but the symbols in emscripten's libc++ all start with std::__2::? How was libemu.a compiled? It looks like it was not compiled with emscripten.

susoferreira commented 1 year ago

Yes, they were both compiled with zig (which uses llvm)

zig cc --version
clang version 16.0.1 (https://github.com/ziglang/zig-bootstrap bf1b2cdb83141ad9336eec42160c9fe87f90198d)
Target: x86_64-unknown-linux-musl
Thread model: posix
InstalledDir: /usr/bin
sbc100 commented 1 year ago

Given that zig uses a different version of libc++ I don't see how you can expect to link zip-generated libraries into an emscripten project. Is that supposed to be something supported by zig?

In order to make that work I think the zip build would have to be run against the emscripten sysroot.. but I don't know how zig works. Maybe file a bug with them?