未验证 提交 e723045e 编辑于 作者: Kito Cheng's avatar Kito Cheng 提交者: GitHub
浏览文件

Merge pull request #761 from riscv/extra-sim

Support spike as simulator to run gcc testsuite
......@@ -10,6 +10,12 @@ MUSL_SRCDIR := @with_musl_src@
LINUX_HEADERS_SRCDIR := @with_linux_headers_src@
GDB_SRCDIR := @with_gdb_src@
SIM:=qemu
# Default branch for proxy kernel and spike
SPIKE_BRANCH:=master
PK_BRANCH:=master
ifeq ($(srcdir)/riscv-gcc,$(GCC_SRCDIR))
# We need a relative source dir for the gcc configure, to make msys2 mingw64
# builds work. Mayberelsrcdir is relative if a relative path was used to run
......@@ -148,6 +154,35 @@ report-binutils: report-binutils-@default_target@
.PHONY: report-gdb
report-gdb: report-gdb-@default_target@
.PHONY: build-sim
build-sim:
ifeq ($(SIM),qemu)
SIM_PATH:=$(srcdir)/scripts/wrapper/qemu
SIM_PREPARE:=PATH="$(SIM_PATH):$(INSTALL_DIR)/bin:$(PATH)" RISC_V_SYSROOT="$(SYSROOT)"
build-sim: stamps/build-qemu
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/"
build-sim: stamps/build-spike
ifneq (,$(findstring rv32,$(NEWLIB_MULTILIB_NAMES)))
build-sim: stamps/build-pk32
endif
ifneq (,$(findstring rv64,$(NEWLIB_MULTILIB_NAMES)))
build-sim: stamps/build-pk64
endif
else
ifeq ($(SIM),gdb)
# Using gdb simulator.
SIM_PATH:=$(INSTALL_DIR)/bin
SIM_PREPARE:=
else
$(error "Only support SIM=spike, SIM=gdb or SIM=qemu (default).")
endif
endif
endif
stamps/check-write-permission:
mkdir -p $(INSTALL_DIR)/.test || \
(echo "Sorry, you don't have permission to write to" \
......@@ -688,6 +723,45 @@ stamps/build-gcc-musl-stage2: $(GCC_SRCDIR) stamps/build-musl-linux \
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
rm -rf $@ $(notdir $@)
mkdir $(notdir $@)
cd $(notdir $@) && ../$</configure \
--prefix=$(INSTALL_DIR)
$(MAKE) -C $(notdir $@)
$(MAKE) -C $(notdir $@) install
mkdir -p $(dir $@)
date > $@
stamps/build-pk32: pk-src stamps/build-gcc-newlib-stage2
rm -rf $@ $(notdir $@)
mkdir $(notdir $@)
cd $(notdir $@) && ../$</configure \
--prefix=$(INSTALL_DIR) \
--host=$(NEWLIB_TUPLE) \
--with-arch=rv32gc
$(MAKE) -C $(notdir $@)
cp $(notdir $@)/pk $(INSTALL_DIR)/$(NEWLIB_TUPLE)/bin/pk32
mkdir -p $(dir $@)
date > $@
stamps/build-pk64: pk-src stamps/build-gcc-newlib-stage2
rm -rf $@ $(notdir $@)
mkdir $(notdir $@)
cd $(notdir $@) && ../$</configure \
--prefix=$(INSTALL_DIR) \
--host=$(NEWLIB_TUPLE) \
--with-arch=rv64gc
$(MAKE) -C $(notdir $@)
cp $(notdir $@)/pk $(INSTALL_DIR)/$(NEWLIB_TUPLE)/bin/pk64
mkdir -p $(dir $@)
date > $@
stamps/build-qemu: $(srcdir)/qemu
rm -rf $@ $(notdir $@)
......@@ -712,18 +786,18 @@ stamps/build-dejagnu: $(srcdir)/riscv-dejagnu
mkdir -p $(dir $@)
date > $@
stamps/check-gcc-newlib: stamps/build-gcc-newlib-stage2 stamps/build-qemu stamps/build-dejagnu
PATH="$(srcdir)/scripts/wrapper/qemu:$(INSTALL_DIR)/bin:$(PATH)" RISC_V_SYSROOT="$(SYSROOT)" $(MAKE) -C build-gcc-newlib-stage2 check-gcc "RUNTESTFLAGS=--target_board='$(NEWLIB_TARGET_BOARDS)'"
stamps/check-gcc-newlib: stamps/build-gcc-newlib-stage2 build-sim stamps/build-dejagnu
$(SIM_PREPARE) $(MAKE) -C build-gcc-newlib-stage2 check-gcc "RUNTESTFLAGS=--target_board='$(NEWLIB_TARGET_BOARDS)'"
mkdir -p $(dir $@)
date > $@
stamps/check-gcc-newlib-nano: stamps/build-gcc-newlib-stage2 stamps/build-qemu stamps/build-dejagnu
PATH="$(srcdir)/scripts/wrapper/qemu:$(INSTALL_DIR)/bin:$(PATH)" RISC_V_SYSROOT="$(SYSROOT)" $(MAKE) -C build-gcc-newlib-stage2 check-gcc "RUNTESTFLAGS=--target_board='$(NEWLIB_NANO_TARGET_BOARDS)'"
stamps/check-gcc-newlib-nano: stamps/build-gcc-newlib-stage2 build-sim stamps/build-dejagnu
$(SIM_PREPARE) $(MAKE) -C build-gcc-newlib-stage2 check-gcc "RUNTESTFLAGS=--target_board='$(NEWLIB_NANO_TARGET_BOARDS)'"
mkdir -p $(dir $@)
date > $@
stamps/check-gcc-linux: stamps/build-gcc-linux-stage2 stamps/build-qemu stamps/build-dejagnu
PATH="$(srcdir)/scripts/wrapper/qemu:$(INSTALL_DIR)/bin:$(PATH)" RISC_V_SYSROOT="$(SYSROOT)" $(MAKE) -C build-gcc-linux-stage2 check-gcc "RUNTESTFLAGS=--target_board='$(GLIBC_TARGET_BOARDS)'"
stamps/check-gcc-linux: stamps/build-gcc-linux-stage2 build-sim stamps/build-dejagnu
$(SIM_PREPARE) $(MAKE) -C build-gcc-linux-stage2 check-gcc "RUNTESTFLAGS=--target_board='$(GLIBC_TARGET_BOARDS)'"
mkdir -p $(dir $@)
date > $@
......@@ -733,56 +807,56 @@ check-dhrystone-newlib-nano: $(patsubst %,stamps/check-dhrystone-newlib-nano-%,$
stamps/check-dhrystone-newlib-%: \
stamps/build-gcc-newlib-stage2 \
stamps/build-qemu \
build-sim \
$(wildcard $(srcdir)/test/benchmarks/dhrystone/*)
$(eval $@_ARCH := $(word 4,$(subst -, ,$@)))
$(eval $@_ABI := $(word 5,$(subst -, ,$@)))
$(eval $@_XLEN := $(patsubst rv32%,32,$(patsubst rv64%,64,$($@_ARCH))))
PATH="$(srcdir)/scripts/wrapper/qemu:$(INSTALL_DIR)/bin:$(PATH)" RISC_V_SYSROOT="$(SYSROOT)" $(srcdir)/test/benchmarks/dhrystone/check -march=$($@_ARCH) -mabi=$($@_ABI) -cc=riscv$(XLEN)-unknown-elf-gcc -objdump=riscv$(XLEN)-unknown-elf-objdump -sim=riscv$($@_XLEN)-unknown-elf-run -out=$@ $(filter %.c,$^) || true
$(SIM_PREPARE) $(srcdir)/test/benchmarks/dhrystone/check -march=$($@_ARCH) -mabi=$($@_ABI) -cc=riscv$(XLEN)-unknown-elf-gcc -objdump=riscv$(XLEN)-unknown-elf-objdump -sim=riscv$($@_XLEN)-unknown-elf-run -out=$@ $(filter %.c,$^) || true
stamps/check-dhrystone-newlib-nano-%: \
stamps/build-gcc-newlib-stage2 \
stamps/build-qemu \
build-sim \
$(wildcard $(srcdir)/test/benchmarks/dhrystone/*)
$(eval $@_ARCH := $(word 5,$(subst -, ,$@)))
$(eval $@_ABI := $(word 6,$(subst -, ,$@)))
$(eval $@_XLEN := $(patsubst rv32%,32,$(patsubst rv64%,64,$($@_ARCH))))
PATH="$(srcdir)/scripts/wrapper/qemu:$(INSTALL_DIR)/bin:$(PATH)" RISC_V_SYSROOT="$(SYSROOT)" $(srcdir)/test/benchmarks/dhrystone/check -march=$($@_ARCH) -mabi=$($@_ABI) -specs=nano.specs -cc=riscv$(XLEN)-unknown-elf-gcc -objdump=riscv$(XLEN)-unknown-elf-objdump -sim=riscv$($@_XLEN)-unknown-elf-run -out=$@ $(filter %.c,$^) || true
$(SIM_PREPARE) $(srcdir)/test/benchmarks/dhrystone/check -march=$($@_ARCH) -mabi=$($@_ABI) -specs=nano.specs -cc=riscv$(XLEN)-unknown-elf-gcc -objdump=riscv$(XLEN)-unknown-elf-objdump -sim=riscv$($@_XLEN)-unknown-elf-run -out=$@ $(filter %.c,$^) || true
.PHONY: check-dhrystone-linux
check-dhrystone-linux: $(patsubst %,stamps/check-dhrystone-linux-%,$(GLIBC_MULTILIB_NAMES))
stamps/check-dhrystone-linux-%: \
stamps/build-gcc-linux-stage2 \
stamps/build-qemu \
build-sim \
$(wildcard $(srcdir)/test/benchmarks/dhrystone/*)
$(eval $@_ARCH := $(word 4,$(subst -, ,$@)))
$(eval $@_ABI := $(word 5,$(subst -, ,$@)))
$(eval $@_XLEN := $(patsubst rv32%,32,$(patsubst rv64%,64,$($@_ARCH))))
PATH="$(srcdir)/scripts/wrapper/qemu:$(INSTALL_DIR)/bin:$(PATH)" RISC_V_SYSROOT="$(SYSROOT)" $(srcdir)/test/benchmarks/dhrystone/check -march=$($@_ARCH) -mabi=$($@_ABI) -cc=riscv$(XLEN)-unknown-elf-gcc -objdump=riscv$(XLEN)-unknown-elf-objdump -sim=riscv$($@_XLEN)-unknown-elf-run -out=$@ $(filter %.c,$^) || true
$(SIM_PREPARE) $(srcdir)/test/benchmarks/dhrystone/check -march=$($@_ARCH) -mabi=$($@_ABI) -cc=riscv$(XLEN)-unknown-elf-gcc -objdump=riscv$(XLEN)-unknown-elf-objdump -sim=riscv$($@_XLEN)-unknown-elf-run -out=$@ $(filter %.c,$^) || true
stamps/check-binutils-newlib: stamps/build-gcc-newlib-stage2 stamps/build-qemu stamps/build-dejagnu
PATH="$(srcdir)/scripts/wrapper/qemu:$(INSTALL_DIR)/bin:$(PATH)" RISC_V_SYSROOT="$(SYSROOT)" $(MAKE) -C build-binutils-newlib check-binutils check-gas check-ld -k "RUNTESTFLAGS=--target_board='$(NEWLIB_TARGET_BOARDS)'" || true
stamps/check-binutils-newlib: stamps/build-gcc-newlib-stage2 build-sim stamps/build-dejagnu
$(SIM_PREPARE) $(MAKE) -C build-binutils-newlib check-binutils check-gas check-ld -k "RUNTESTFLAGS=--target_board='$(NEWLIB_TARGET_BOARDS)'" || true
date > $@
stamps/check-binutils-newlib-nano: stamps/build-gcc-newlib-stage2 stamps/build-qemu stamps/build-dejagnu
PATH="$(srcdir)/scripts/wrapper/qemu:$(INSTALL_DIR)/bin:$(PATH)" RISC_V_SYSROOT="$(SYSROOT)" $(MAKE) -C build-binutils-newlib check-binutils check-gas check-ld -k "RUNTESTFLAGS=--target_board='$(NEWLIB_NANO_TARGET_BOARDS)'" || true
stamps/check-binutils-newlib-nano: stamps/build-gcc-newlib-stage2 build-sim stamps/build-dejagnu
$(SIM_PREPARE) $(MAKE) -C build-binutils-newlib check-binutils check-gas check-ld -k "RUNTESTFLAGS=--target_board='$(NEWLIB_NANO_TARGET_BOARDS)'" || true
date > $@
stamps/check-binutils-linux: stamps/build-gcc-linux-stage2 stamps/build-qemu stamps/build-dejagnu
PATH="$(srcdir)/scripts/wrapper/qemu:$(INSTALL_DIR)/bin:$(PATH)" RISC_V_SYSROOT="$(SYSROOT)" $(MAKE) -C build-binutils-linux check-binutils check-gas check-ld -k "RUNTESTFLAGS=--target_board='$(GLIBC_TARGET_BOARDS)'" || true
stamps/check-binutils-linux: stamps/build-gcc-linux-stage2 build-sim stamps/build-dejagnu
$(SIM_PREPARE) $(MAKE) -C build-binutils-linux check-binutils check-gas check-ld -k "RUNTESTFLAGS=--target_board='$(GLIBC_TARGET_BOARDS)'" || true
date > $@
stamps/check-gdb-newlib: stamps/build-gcc-newlib-stage2 stamps/build-gdb-newlib stamps/build-qemu stamps/build-dejagnu
PATH="$(srcdir)/scripts/wrapper/qemu:$(INSTALL_DIR)/bin:$(PATH)" RISC_V_SYSROOT="$(SYSROOT)" $(MAKE) -C build-gdb-newlib check-gdb -k "RUNTESTFLAGS=--target_board='$(NEWLIB_TARGET_BOARDS)'" || true
stamps/check-gdb-newlib: stamps/build-gcc-newlib-stage2 stamps/build-gdb-newlib build-sim stamps/build-dejagnu
$(SIM_PREPARE) $(MAKE) -C build-gdb-newlib check-gdb -k "RUNTESTFLAGS=--target_board='$(NEWLIB_TARGET_BOARDS)'" || true
date > $@
stamps/check-gdb-newlib-nano: stamps/build-gcc-newlib-stage2 stamps/build-gdb-newlib stamps/build-qemu stamps/build-dejagnu
PATH="$(srcdir)/scripts/wrapper/qemu:$(INSTALL_DIR)/bin:$(PATH)" RISC_V_SYSROOT="$(SYSROOT)" $(MAKE) -C build-gdb-newlib check-gdb -k "RUNTESTFLAGS=--target_board='$(NEWLIB_NANO_TARGET_BOARDS)'" || true
stamps/check-gdb-newlib-nano: stamps/build-gcc-newlib-stage2 stamps/build-gdb-newlib build-sim stamps/build-dejagnu
$(SIM_PREPARE) $(MAKE) -C build-gdb-newlib check-gdb -k "RUNTESTFLAGS=--target_board='$(NEWLIB_NANO_TARGET_BOARDS)'" || true
date > $@
stamps/check-gdb-linux: stamps/build-gcc-linux-stage2 stamps/build-gdb-linux stamps/build-qemu stamps/build-dejagnu
PATH="$(srcdir)/scripts/wrapper/qemu:$(INSTALL_DIR)/bin:$(PATH)" RISC_V_SYSROOT="$(SYSROOT)" $(MAKE) -C build-gdb-linux check-gdb -k "RUNTESTFLAGS=--target_board='$(GLIBC_TARGET_BOARDS)'" || true
stamps/check-gdb-linux: stamps/build-gcc-linux-stage2 stamps/build-gdb-linux build-sim stamps/build-dejagnu
$(SIM_PREPARE) $(MAKE) -C build-gdb-linux check-gdb -k "RUNTESTFLAGS=--target_board='$(GLIBC_TARGET_BOARDS)'" || true
date > $@
.PHONY: report-gcc-newlib report-gcc-newlib-nano
......
......@@ -129,15 +129,21 @@ configure. See './configure --help' for more details.
### Test Suite
The DejaGnu test suite has been ported to RISC-V. This can run with GDB
simulator for elf toolchain or Qemu for linux toolchain, and GDB simulator
doesn't support floating-point.
The Dejagnu test suite has been ported to RISC-V. This can be run with a
simulator for the elf and linux toolchains. The simulator can be selected
by the SIM variable in the Makefile, e.g. SIM=qemu, SIM=gdb, or SIM=spike
(experimental). However, the testsuite allowlist is only mintained for qemu.
Other simulators might get extra failures.
To test GCC, run the following commands:
./configure --prefix=$RISCV --disable-linux --with-arch=rv64ima # or --with-arch=rv32ima
make newlib
make report-newlib
make report-newlib SIM=gdb # Run with gdb simulator
./configure --prefix=$RISCV
make linux
make report-linux
make report-linux SIM=qemu # Run with qemu
Note:
- spike only support rv64* bare-metal/elf toolchain.
- gdb simulator only support bare-metal/elf toolchain.
riscv64-unknown-linux-gnu-run
\ No newline at end of file
riscv64-unknown-linux-gnu-run
\ No newline at end of file
riscv64-unknown-linux-gnu-run
\ No newline at end of file
#!/bin/sh
xlen="$(readelf -h $1 | grep 'Class' | cut -d: -f 2 | xargs echo | sed 's/^ELF//')"
spike \
--isa=RV${xlen}GC \
${PK_PATH}/pk${xlen} "$@"
支持 Markdown
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册