CE-Programming / CEmu

Third-party TI-84 Plus CE / TI-83 Premium CE emulator, focused on developer features
https://ce-programming.github.io/CEmu/
Other
1.07k stars 76 forks source link

Compiling to WebAssembly #435

Closed Vishram1123 closed 1 year ago

Vishram1123 commented 1 year ago

(Thanks for reporting an issue! Please make sure to fill out the blanks below.)

What's wrong, and with what software version?


What are the steps to reproduce this issue?


  1. git clone --recursive https://github.com/CE-Programming/CEmu
  2. cd CEmu/core
  3. emmake make -f emscripten.mk or make -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 ```
Vishram1123 commented 1 year ago

Oh, also to note, the regular build with just make works; I am able to build the core.

adriweb commented 1 year ago

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

adriweb commented 1 year ago

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.

adriweb commented 1 year ago

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...)

Vishram1123 commented 1 year ago

Ok, I will try that. I installed the brew version of emscripten on my Mac and compiled from source (installing latest) on Fedora

Vishram1123 commented 1 year ago

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)?

adriweb commented 1 year ago

Yep, and I'm also running it on macOS... this is weird.

Vishram1123 commented 1 year ago

Oh I did it on Fedora, I'll try on my mac