From 9b73da792263362fdc63b2523e439967f0a6e039 Mon Sep 17 00:00:00 2001 From: Danny Willems Date: Thu, 19 Dec 2024 19:13:15 +0100 Subject: [PATCH 1/3] gitignore: start ignoring temporary obj files for o1vm --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index c6f644327e..75a56fa0f0 100644 --- a/.gitignore +++ b/.gitignore @@ -42,4 +42,5 @@ state.json # Directory for the RISC-V 32bits toolchain _riscv32-gnu-toolchain -o1vm/resources/programs/riscv32im/bin/*.o \ No newline at end of file +o1vm/resources/programs/riscv32im/bin/*.o +o1vm/resources/programs/mips/bin/*.o From 5f773593d01d3108f16717763f57b54b1082642d Mon Sep 17 00:00:00 2001 From: Danny Willems Date: Mon, 23 Dec 2024 18:45:24 +0100 Subject: [PATCH 2/3] Makefile: add target to build all MIPS programs from Optimism And change the section .test into .text --- Makefile | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index c86e935ea1..41a35df28a 100644 --- a/Makefile +++ b/Makefile @@ -18,6 +18,13 @@ O1VM_RISCV32IM_BIN_DIR = ${O1VM_RESOURCES_PATH}/riscv32im/bin O1VM_RISCV32IM_BIN_FILES = $(patsubst ${O1VM_RISCV32IM_SOURCE_DIR}/%.S,${O1VM_RISCV32IM_BIN_DIR}/%.o,${O1VM_RISCV32IM_SOURCE_FILES}) RISCV32_AS_FLAGS = --warn --fatal-warnings +OPTIMISM_MIPS_SOURCE_DIR = $(shell pwd)/o1vm/ethereum-optimism/cannon/mipsevm/open_mips_tests/test +OPTIMISM_MIPS_SOURCE_FILES = $(wildcard ${OPTIMISM_MIPS_SOURCE_DIR}/*.asm) +O1VM_MIPS_SOURCE_DIR = ${O1VM_RESOURCES_PATH}/mips/src +O1VM_MIPS_SOURCE_FILES = $(patsubst ${OPTIMISM_MIPS_SOURCE_DIR}/%.asm,${O1VM_MIPS_SOURCE_DIR}/%.asm,${OPTIMISM_MIPS_SOURCE_FILES}) +O1VM_MIPS_BIN_DIR = ${O1VM_RESOURCES_PATH}/mips/bin +O1VM_MIPS_BIN_FILES = $(patsubst ${O1VM_MIPS_SOURCE_DIR}/%.asm,${O1VM_MIPS_BIN_DIR}/%.o,${O1VM_MIPS_SOURCE_FILES}) + # Default target all: release @@ -166,7 +173,31 @@ ${O1VM_RISCV32IM_BIN_DIR}/%.o: ${O1VM_RISCV32IM_SOURCE_DIR}/%.S ${RISCV32_TOOLCHAIN_PATH}/build/bin/riscv32-unknown-elf-ld -s -o $(basename $@) $@ @echo "" +build-mips-programs: ${O1VM_MIPS_SOURCE_FILES} ${O1VM_MIPS_BIN_FILES} ## Build all MIPS programs written for the o1vm + +${O1VM_MIPS_SOURCE_DIR}/%.asm: ${OPTIMISM_MIPS_SOURCE_DIR}/%.asm + @mkdir -p ${O1VM_MIPS_SOURCE_DIR} + @echo "Transforming $< to $@, making it compatible for o1vm" + @sed \ + -e '/\.balign 4/d' \ + -e '/\.set\s*noreorder/d' \ + -e '/\.ent\s*test/d' \ + -e '/\.end test/d' \ + -e 's/\.section .test, "x"/.section .text/' \ + -e 's/\s*\.section .text/.section .text/' \ + -e 's/\.global test/.global __start/' \ + -e "s/^\s*\.global __start/.global __start/" \ + -e "s/test\:/__start:/" \ + -e "/\.global __start/a\\" \ + $< > $@ + +${O1VM_MIPS_BIN_DIR}/%.o: ${O1VM_MIPS_SOURCE_DIR}/%.asm + @echo "Building the MIPS binary: $(basename $@) using $<" + @mkdir -p ${O1VM_MIPS_BIN_DIR} + @mips-linux-gnu-as -defsym big_endian=1 -march=mips32r2 -o $@ $< + @mips-linux-gnu-ld -s -o $(basename $@) $@ + fclean: clean ## Clean the tooling artefacts in addition to running clean rm -rf ${RISCV32_TOOLCHAIN_PATH} -.PHONY: all setup install-test-deps clean build release test-doc test-doc-with-coverage test test-with-coverage test-heavy test-heavy-with-coverage test-all test-all-with-coverage nextest nextest-with-coverage nextest-heavy nextest-heavy-with-coverage nextest-all nextest-all-with-coverage format lint generate-test-coverage-report generate-doc setup-riscv32-toolchain help fclean build-riscv32-programs +.PHONY: all setup install-test-deps clean build release test-doc test-doc-with-coverage test test-with-coverage test-heavy test-heavy-with-coverage test-all test-all-with-coverage nextest nextest-with-coverage nextest-heavy nextest-heavy-with-coverage nextest-all nextest-all-with-coverage format lint generate-test-coverage-report generate-doc setup-riscv32-toolchain help fclean build-riscv32-programs build-mips-programs From 2637499c5d915f383e2dc186a71b7e9a489ee36e Mon Sep 17 00:00:00 2001 From: Danny Willems Date: Mon, 23 Dec 2024 19:13:26 +0100 Subject: [PATCH 3/3] Makefile: clean MIPS bin dir when clean called --- Makefile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 41a35df28a..43f57c5021 100644 --- a/Makefile +++ b/Makefile @@ -54,8 +54,9 @@ install-test-deps: ## Install test dependencies clean: ## Clean the project - cargo clean - rm -rf $(O1VM_RISCV32IM_BIN_FILES) + @cargo clean + @rm -rf $(O1VM_RISCV32IM_BIN_FILES) + @rm -rf $(O1VM_MIPS_BIN_DIR) build: ## Build the project