From f2bac6ed617e9e85269048c09d39a950d0332e89 Mon Sep 17 00:00:00 2001 From: ChinYikMing Date: Mon, 2 Sep 2024 01:09:52 +0800 Subject: [PATCH 1/2] Bring wasm service up After merging #474, multiple executables were moved to other location (build/riscv32), which caused the wasm service to fail. The intuitive solution is to embed build/riscv32 into the wasm. Also, executables that stored in rv32emu-prebuilt must be pulled before embedding into wasm, so emcc_deps should depend on the artifact target. Additionally, the Makefile's distclean target does not fully clean wasm artifacts, as CC=emcc might not be set during make distclean. To fix this, the declaration of the WEB_FILES and DEMO_DIR wasm-related variables has been reordered. Related: #486 --- assets/html/index.html | 38 +++++++++++++++++++------------------- mk/wasm.mk | 9 +++++---- 2 files changed, 24 insertions(+), 23 deletions(-) diff --git a/assets/html/index.html b/assets/html/index.html index 163213f4..47fda9c1 100644 --- a/assets/html/index.html +++ b/assets/html/index.html @@ -136,32 +136,32 @@ var spinnerElement = document.getElementById('spinner'); var elfFiles = [ - "doom.elf", + "riscv32/doom", "smolnes.elf", - "quake.elf", - "coremark.elf", - "dhrystone.elf", - "pi.elf", - "donut.elf", - "aes.elf", + "riscv32/quake", + "riscv32/coremark", + "riscv32/dhrystone", + "riscv32/pi", + "riscv32/donut", + "riscv32/aes", "coro.elf", - "fcalc.elf", - "hamilton.elf", + "riscv32/fcalc", + "riscv32/hamilton", "hello.elf", "ieee754.elf", "jit-bf.elf", - "maj2random.elf", - "mandelbrot.elf", - "nqueens.elf", - "nyancat.elf", + "riscv32/maj2random", + "riscv32/mandelbrot", + "riscv32/nqueens", + "riscv32/nyancat", "perfcount.elf", - "qrcode.elf", + "riscv32/qrcode", "readelf.elf", - "richards.elf", - "rvsim.elf", - "scimark2.elf", - "spirograph.elf", - "stream.elf", + "riscv32/richards", + "riscv32/rvsim", + "riscv32/scimark2", + "riscv32/spirograph", + "riscv32/stream", ]; var runButton = document.getElementById("runButton"); diff --git a/mk/wasm.mk b/mk/wasm.mk index b1327da5..a2b104d5 100644 --- a/mk/wasm.mk +++ b/mk/wasm.mk @@ -1,14 +1,15 @@ CFLAGS_emcc ?= -deps_emcc := +deps_emcc := artifact ASSETS := assets WEB_HTML_RESOURCES := $(ASSETS)/html WEB_JS_RESOURCES := $(ASSETS)/js EXPORTED_FUNCS := _main,_indirect_rv_halt - -ifeq ("$(CC_IS_EMCC)", "1") +DEMO_DIR := demo WEB_FILES := $(BIN).js \ $(BIN).wasm \ $(BIN).worker.js + +ifeq ("$(CC_IS_EMCC)", "1") BIN := $(BIN).js # TCO @@ -28,6 +29,7 @@ CFLAGS_emcc += -sINITIAL_MEMORY=2GB \ -sSTACK_SIZE=4MB \ -sPTHREAD_POOL_SIZE=navigator.hardwareConcurrency \ --embed-file build@/ \ + --embed-file build/riscv32@/riscv32 \ --embed-file build/timidity@/etc/timidity \ -DMEM_SIZE=0x40000000 \ -DCYCLE_PER_STEP=2000000 \ @@ -77,7 +79,6 @@ else endif # used to serve wasm locally -DEMO_DIR := demo DEMO_IP := 127.0.0.1 DEMO_PORT := 8000 From 785bf15a9ebb8e9e5f409d27b3db3fc73a34c122 Mon Sep 17 00:00:00 2001 From: ChinYikMing Date: Mon, 2 Sep 2024 03:26:37 +0800 Subject: [PATCH 2/2] Add a generator for the ELF executables list As the number of ELF executables may increase over time, manually updating the HTML ELF list becomes tedious. Therefore, an ELF list generator has been introduced. When new ELF executables are added to the build or build/riscv32 directories, the list will be generated dynamically. Close: #486 --- assets/html/index.html | 31 +------------------------------ mk/wasm.mk | 7 +++++-- tools/gen-elf-list-js.py | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 39 insertions(+), 32 deletions(-) create mode 100755 tools/gen-elf-list-js.py diff --git a/assets/html/index.html b/assets/html/index.html index 47fda9c1..5beae7e6 100644 --- a/assets/html/index.html +++ b/assets/html/index.html @@ -130,40 +130,11 @@ +