From 5a2b88b5286aa7fbe4ce14f65ec12c8e9ab69353 Mon Sep 17 00:00:00 2001 From: Liaoshihua <18990054834@163.com> Date: Mon, 23 May 2022 09:52:08 +0800 Subject: [PATCH] Add option '--with-sim' to set simulator --- .gitmodules | 8 +++ Makefile.in | 34 +++++------ README.md | 11 +++- configure | 59 +++++++++++++++++++ configure.ac | 10 ++++ pk | 1 + .../spike/riscv64-unknown-linux-gnu-run | 4 +- spike | 1 + 8 files changed, 106 insertions(+), 22 deletions(-) create mode 160000 pk create mode 160000 spike diff --git a/.gitmodules b/.gitmodules index 229b9718..2204feb6 100644 --- a/.gitmodules +++ b/.gitmodules @@ -28,3 +28,11 @@ path = musl url = git://git.musl-libc.org/musl branch = master +[submodule "spike"] + path = spike + url = https://github.com/riscv-software-src/riscv-isa-sim.git + branch = master +[submodule "pk"] + path = pk + url = https://github.com/riscv-software-src/riscv-pk.git + branch = master diff --git a/Makefile.in b/Makefile.in index 03fa8329..f908f59e 100644 --- a/Makefile.in +++ b/Makefile.in @@ -10,12 +10,10 @@ MUSL_SRCDIR := @with_musl_src@ LINUX_HEADERS_SRCDIR := @with_linux_headers_src@ GDB_SRCDIR := @with_gdb_src@ QEMU_SRCDIR := @with_qemu_src@ +SPIKE_SRCDIR := @with_spike_src@ +PK_SRCDIR := @with_pk_src@ -SIM:=qemu - -# Default branch for proxy kernel and spike -SPIKE_BRANCH:=master -PK_BRANCH:=master +SIM ?= @WITH_SIM@ ifeq ($(srcdir)/riscv-gcc,$(GCC_SRCDIR)) # We need a relative source dir for the gcc configure, to make msys2 mingw64 @@ -180,7 +178,7 @@ else ifeq ($(SIM),spike) # Using spike simulator. SIM_PATH:=$(srcdir)/scripts/wrapper/spike -SIM_PREPARE:=PATH="$(SIM_PATH):$(INSTALL_DIR)/bin:$(PATH)" PK_PATH="$(INSTALL_DIR)/$(NEWLIB_TUPLE)/bin/" +SIM_PREPARE:=PATH="$(SIM_PATH):$(INSTALL_DIR)/bin:$(PATH)" PK_PATH="$(INSTALL_DIR)/$(NEWLIB_TUPLE)/bin/" ARCH_STR="$(WITH_ARCH)" SIM_STAMP:= stamps/build-spike ifneq (,$(findstring rv32,$(NEWLIB_MULTILIB_NAMES))) SIM_STAMP+= stamps/build-pk32 @@ -259,6 +257,12 @@ else QEMU_SRC_GIT := endif +ifeq ($(findstring $(srcdir),$(SPIKE_SRCDIR)),$(srcdir)) +SPIKE_SRC_GIT := $(SPIKE_SRCDIR)/.git +else +SPIKE_SRC_GIT := +endif + ifneq ("$(wildcard $(GCC_SRCDIR)/.git)","") GCCPKGVER := g$(shell git -C $(GCC_SRCDIR) describe --always --dirty --exclude '*') else @@ -804,26 +808,20 @@ stamps/build-gcc-musl-stage2: $(GCC_SRCDIR) $(GCC_SRC_GIT) stamps/build-musl-lin cp -a $(INSTALL_DIR)/$(MUSL_TUPLE)/lib* $(SYSROOT) mkdir -p $(dir $@) && touch $@ -spike-src: - git clone https://github.com/riscv/riscv-isa-sim.git -b $(SPIKE_BRANCH) $@ - -pk-src: - git clone https://github.com/riscv/riscv-pk.git -b $(PK_BRANCH) $@ - -stamps/build-spike: spike-src +stamps/build-spike: $(SPIKE_SRCDIR) $(SPIKE_SRC_GIT) rm -rf $@ $(notdir $@) mkdir $(notdir $@) - cd $(notdir $@) && ../$ $@ -stamps/build-pk32: pk-src stamps/build-gcc-newlib-stage2 +stamps/build-pk32: $(PK_SRCDIR) stamps/build-gcc-newlib-stage2 rm -rf $@ $(notdir $@) mkdir $(notdir $@) - cd $(notdir $@) && ../$ $@ -stamps/build-pk64: pk-src stamps/build-gcc-newlib-stage2 +stamps/build-pk64: $(PK_SRCDIR) stamps/build-gcc-newlib-stage2 rm -rf $@ $(notdir $@) mkdir $(notdir $@) - cd $(notdir $@) && ../$