diff --git a/README.md b/README.md index 4b50f9c6..bc855899 100644 --- a/README.md +++ b/README.md @@ -333,9 +333,9 @@ $ tools/rv_profiler [--start-address|--stop-address|--graph-ir] [test_program] Thus, the target system should have the Emscripten version 3.1.51 installed. Moreover, `rv32emu` leverages the tail call optimization (TCO) and we have tested the WebAssembly -execution in Chrome with at least MAJOR 112 and Firefox with at least MAJOR 121 since they supports -tail call feature. Thus, please check and update your browsers if necessary or install the suitable browsers -before going further. +execution in Chrome with at least MAJOR 112, Firefox with at least MAJOR 121 and Safari with at least version 18.2 +since they supports tail call feature. Please check your browser version and update if necessary, or install a compatible +browser before proceeding. Source your Emscripten SDK environment before make. For macOS and Linux user: ```shell diff --git a/mk/wasm.mk b/mk/wasm.mk index ee59a865..90cb9da6 100644 --- a/mk/wasm.mk +++ b/mk/wasm.mk @@ -44,7 +44,7 @@ $(OUT)/elf_list.js: tools/gen-elf-list-js.py # used to download all dependencies of elf executable and bundle into single wasm deps_emcc += artifact $(OUT)/elf_list.js $(DOOM_DATA) $(QUAKE_DATA) $(TIMIDITY_DATA) -# check browser MAJOR version if supports TCO +# check browser version if supports TCO CHROME_MAJOR := CHROME_MAJOR_VERSION_CHECK_CMD := CHROME_SUPPORT_TCO_AT_MAJOR := 112 @@ -57,10 +57,21 @@ FIREFOX_SUPPORT_TCO_AT_MAJOR := 121 FIREFOX_SUPPORT_TCO_INFO := Firefox supports TCO, you can use Firefox to request the wasm FIREFOX_NO_SUPPORT_TCO_WARNING := Firefox not found or Firefox must have at least version $(FIREFOX_SUPPORT_TCO_AT_MAJOR) in MAJOR to support TCO in wasm +# Check WebAssembly section at https://webkit.org/blog/16301/webkit-features-in-safari-18-2/ +ifeq ($(UNAME_S),Darwin) +SAFARI_MAJOR := +SAFARI_MINOR := +SAFARI_VERSION_CHECK_CMD := +SAFARI_SUPPORT_TCO_AT_MAJOR_MINOR := 18.2 +SAFARI_SUPPORT_TCO_INFO := Safari supports TCO, you can use Safari to request the wasm +SAFARI_NO_SUPPORT_TCO_WARNING := Safari not found or Safari must have at least version $(SAFARI_SUPPORT_TCO_AT_MAJOR_MINOR) to support TCO in wasm +endif + # FIXME: for Windows ifeq ($(UNAME_S),Darwin) CHROME_MAJOR_VERSION_CHECK_CMD := "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" --version | awk '{print $$3}' | cut -f1 -d. FIREFOX_MAJOR_VERSION_CHECK_CMD := /Applications/Firefox.app/Contents/MacOS/firefox --version | awk '{print $$3}' | cut -f1 -d. + SAFARI_VERSION_CHECK_CMD := mdls -name kMDItemVersion /Applications/Safari.app | sed 's/"//g' | awk '{print $$3}' else ifeq ($(UNAME_S),Linux) CHROME_MAJOR_VERSION_CHECK_CMD := google-chrome --version | awk '{print $$3}' | cut -f1 -d. FIREFOX_MAJOR_VERSION_CHECK_CMD := firefox -v | awk '{print $$3}' | cut -f1 -d. @@ -82,6 +93,19 @@ else $(warning $(shell echo "$(YELLOW)$(FIREFOX_NO_SUPPORT_TCO_WARNING)$(NC)")) endif +# Safari +ifeq ($(UNAME_S),Darwin) +# ignore PATCH because the expression with PATCH(e.g., double dots x.x.x) becomes invalid number for the following bc cmd +SAFARI_VERSION := $(shell $(SAFARI_VERSION_CHECK_CMD)) +SAFARI_MAJOR := $(shell echo $(SAFARI_VERSION) | cut -f1 -d.) +SAFARI_MINOR := $(shell echo $(SAFARI_VERSION) | cut -f2 -d.) +ifeq ($(shell echo "$(SAFARI_MAJOR).$(SAFARI_MINOR)>=$(SAFARI_SUPPORT_TCO_AT_MAJOR_MINOR)" | bc), 1) + $(info $(shell echo "$(GREEN)$(SAFARI_SUPPORT_TCO_INFO)$(NC)")) +else + $(warning $(shell echo "$(YELLOW)$(SAFARI_NO_SUPPORT_TCO_WARNING)$(NC)")) +endif +endif + # used to serve wasm locally DEMO_IP := 127.0.0.1 DEMO_PORT := 8000