CEmu
CEmu copied to clipboard
Compiling to WebAssembly
(Thanks for reporting an issue! Please make sure to fill out the blanks below.)
What's wrong, and with what software version?
- Operating System: MacOS Ventura (Also tried in Fedora 36)
- CEmu version: Commit d606eb3982442a8df0d044b453cf5fc195c6f45d
-
Describe your issue: When attempting to compile to WebAssembly (using
emmake make -f emscripten.mk
andmake -f emscripten.mk
), the compilation fails, as symbols are not found by wasm-ld. This is done by just recursively cloning the repo (git clone --recursive https://github.com/CE-Programming/CEmu
), going to the core directory (cd CEmu/core
) and compiling (with above command)
What are the steps to reproduce this issue?
-
git clone --recursive https://github.com/CE-Programming/CEmu
-
cd CEmu/core
-
emmake make -f emscripten.mk
ormake -f emscripten.mk
Any logs, error output, screenshot, other comments...?
(Same in both cases):
Error log from make command
emcc -W -Wall -O3 -DDEBUG_SUPPORT -s TOTAL_MEMORY=33554432 --llvm-lto 3 -s INVOKE_RUN=0 -s NO_EXIT_RUNTIME=1 -s ASSERTIONS=0 -s "EXTRA_EXPORTED_RUNTIME_METHODS=['callMain', 'ccall', 'cwrap']" --closure 0 -s WASM=0 asic.c -o asic.bc
emcc:WARNING: --llvm-lto ignored when using llvm backend
emcc: warning: EXTRA_EXPORTED_RUNTIME_METHODS is deprecated, please use EXPORTED_RUNTIME_METHODS instead [-Wdeprecated]
emcc: warning: object file output extension (.bc) used for non-object output. If you meant to build an object file please use `-c, `-r`, or `-shared` [-Wemcc]
emcc -W -Wall -O3 -DDEBUG_SUPPORT -s TOTAL_MEMORY=33554432 --llvm-lto 3 -s INVOKE_RUN=0 -s NO_EXIT_RUNTIME=1 -s ASSERTIONS=0 -s "EXTRA_EXPORTED_RUNTIME_METHODS=['callMain', 'ccall', 'cwrap']" --closure 0 -s WASM=0 backlight.c -o backlight.bc
emcc:WARNING: --llvm-lto ignored when using llvm backend
emcc: warning: EXTRA_EXPORTED_RUNTIME_METHODS is deprecated, please use EXPORTED_RUNTIME_METHODS instead [-Wdeprecated]
emcc: warning: object file output extension (.bc) used for non-object output. If you meant to build an object file please use `-c, `-r`, or `-shared` [-Wemcc]
emcc -W -Wall -O3 -DDEBUG_SUPPORT -s TOTAL_MEMORY=33554432 --llvm-lto 3 -s INVOKE_RUN=0 -s NO_EXIT_RUNTIME=1 -s ASSERTIONS=0 -s "EXTRA_EXPORTED_RUNTIME_METHODS=['callMain', 'ccall', 'cwrap']" --closure 0 -s WASM=0 bus.c -o bus.bc
emcc:WARNING: --llvm-lto ignored when using llvm backend
emcc: warning: EXTRA_EXPORTED_RUNTIME_METHODS is deprecated, please use EXPORTED_RUNTIME_METHODS instead [-Wdeprecated]
emcc: warning: object file output extension (.bc) used for non-object output. If you meant to build an object file please use `-c, `-r`, or `-shared` [-Wemcc]
emcc -W -Wall -O3 -DDEBUG_SUPPORT -s TOTAL_MEMORY=33554432 --llvm-lto 3 -s INVOKE_RUN=0 -s NO_EXIT_RUNTIME=1 -s ASSERTIONS=0 -s "EXTRA_EXPORTED_RUNTIME_METHODS=['callMain', 'ccall', 'cwrap']" --closure 0 -s WASM=0 cert.c -o cert.bc
emcc:WARNING: --llvm-lto ignored when using llvm backend
emcc: warning: EXTRA_EXPORTED_RUNTIME_METHODS is deprecated, please use EXPORTED_RUNTIME_METHODS instead [-Wdeprecated]
emcc: warning: object file output extension (.bc) used for non-object output. If you meant to build an object file please use `-c, `-r`, or `-shared` [-Wemcc]
emcc -W -Wall -O3 -DDEBUG_SUPPORT -s TOTAL_MEMORY=33554432 --llvm-lto 3 -s INVOKE_RUN=0 -s NO_EXIT_RUNTIME=1 -s ASSERTIONS=0 -s "EXTRA_EXPORTED_RUNTIME_METHODS=['callMain', 'ccall', 'cwrap']" --closure 0 -s WASM=0 control.c -o control.bc
emcc:WARNING: --llvm-lto ignored when using llvm backend
emcc: warning: EXTRA_EXPORTED_RUNTIME_METHODS is deprecated, please use EXPORTED_RUNTIME_METHODS instead [-Wdeprecated]
emcc: warning: object file output extension (.bc) used for non-object output. If you meant to build an object file please use `-c, `-r`, or `-shared` [-Wemcc]
emcc -W -Wall -O3 -DDEBUG_SUPPORT -s TOTAL_MEMORY=33554432 --llvm-lto 3 -s INVOKE_RUN=0 -s NO_EXIT_RUNTIME=1 -s ASSERTIONS=0 -s "EXTRA_EXPORTED_RUNTIME_METHODS=['callMain', 'ccall', 'cwrap']" --closure 0 -s WASM=0 cpu.c -o cpu.bc
emcc:WARNING: --llvm-lto ignored when using llvm backend
emcc: warning: EXTRA_EXPORTED_RUNTIME_METHODS is deprecated, please use EXPORTED_RUNTIME_METHODS instead [-Wdeprecated]
emcc: warning: object file output extension (.bc) used for non-object output. If you meant to build an object file please use `-c, `-r`, or `-shared` [-Wemcc]
emcc -W -Wall -O3 -DDEBUG_SUPPORT -s TOTAL_MEMORY=33554432 --llvm-lto 3 -s INVOKE_RUN=0 -s NO_EXIT_RUNTIME=1 -s ASSERTIONS=0 -s "EXTRA_EXPORTED_RUNTIME_METHODS=['callMain', 'ccall', 'cwrap']" --closure 0 -s WASM=0 emu.c -o emu.bc
emcc:WARNING: --llvm-lto ignored when using llvm backend
emcc: warning: EXTRA_EXPORTED_RUNTIME_METHODS is deprecated, please use EXPORTED_RUNTIME_METHODS instead [-Wdeprecated]
emcc: warning: object file output extension (.bc) used for non-object output. If you meant to build an object file please use `-c, `-r`, or `-shared` [-Wemcc]
wasm-ld: error: /var/folders/5h/z9gzm9hj5kvdxr9bqtrqx95r0000gn/T/emscripten_temp__sygnx5u/emu_0.o: undefined symbol: cpu
emcc: error: '/opt/homebrew/Cellar/emscripten/3.1.20/libexec/llvm/bin/wasm-ld -o emu.wasm /var/folders/5h/z9gzm9hj5kvdxr9bqtrqx95r0000gn/T/emscripten_temp__sygnx5u/emu_0.o -L/opt/homebrew/Cellar/emscripten/3.1.20/libexec/cache/sysroot/lib/wasm32-emscripten -lGL -lal -lhtml5 -lstubs -lnoexit -lc -ldlmalloc -lcompiler_rt -lc++-noexcept -lc++abi-noexcept -lsockets -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr --import-undefined --import-memory --strip-debug --export-if-defined=main --export-if-defined=__start_em_asm --export-if-defined=__stop_em_asm --export-if-defined=__start_em_js --export-if-defined=__stop_em_js --export-if-defined=__main_argc_argv --export=stackSave --export=stackRestore --export=stackAlloc --export=__wasm_call_ctors --export=__errno_location --export=getTempRet0 --export=setTempRet0 --export=__get_temp_ret --export=__set_temp_ret --export-table -z stack-size=5242880 --initial-memory=33554432 --no-entry --max-memory=33554432 --global-base=1024' failed (returned 1)
make: *** [emu.bc] Error 1
Oh, also to note, the regular build with just make
works; I am able to build the core.
I'm not able to repro with the latest commit on master (as of this comment) and emscripten (after an update, it shows emcc (Emscripten gcc/clang-like replacement) 1.39.8 (commit 1458145cf4f3db0fb548343e6acab267eef8e4ef)
.
No error here, it builds cemu_web.js and cemu_web.js.mem just fine, hmmm
ok for some reason, I guess my emscripten is the latest of... an old branch. I'll update to the actual-latest one in a bit.
Alright, I updated to emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.24-git (f6c46570e3780e52050bf822a07b342ec4bdddbe)
and I'm still not getting errors (a buunch of warnings because some things are obsolete/deprecated, but...)
Ok, I will try that. I installed the brew version of emscripten on my Mac and compiled from source (installing latest) on Fedora
I am on the same version of Emscripten as you are (3.1.24-git (f6c46570e3780e52050bf822a07b342ec4bdddbe)
), but I am still getting the error wasm-ld: error: /tmp/emscripten_temp_k39cf52w/emu_0.o: undefined symbol: cpu
. Am I running the right command (make -f emscripten.mk
)?
Yep, and I'm also running it on macOS... this is weird.
Oh I did it on Fedora, I'll try on my mac