Browse Source

Add option '--with-sim' to set simulator

pull/1080/head
Liaoshihua 4 years ago
parent
commit
5a2b88b528
  1. 8
      .gitmodules
  2. 34
      Makefile.in
  3. 11
      README.md
  4. 59
      configure
  5. 10
      configure.ac
  6. 1
      pk
  7. 4
      scripts/wrapper/spike/riscv64-unknown-linux-gnu-run
  8. 1
      spike

8
.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

34
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 $@) && ../$</configure \
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
stamps/build-pk32: $(PK_SRCDIR) stamps/build-gcc-newlib-stage2
rm -rf $@ $(notdir $@)
mkdir $(notdir $@)
cd $(notdir $@) && ../$</configure \
cd $(notdir $@) && $</configure \
--prefix=$(INSTALL_DIR) \
--host=$(NEWLIB_TUPLE) \
--with-arch=rv32gc
@ -832,10 +830,10 @@ stamps/build-pk32: pk-src stamps/build-gcc-newlib-stage2
mkdir -p $(dir $@)
date > $@
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 $@) && ../$</configure \
cd $(notdir $@) && $</configure \
--prefix=$(INSTALL_DIR) \
--host=$(NEWLIB_TUPLE) \
--with-arch=rv64gc

11
README.md

@ -189,8 +189,9 @@ rv64imac with lp64 and rv64imafc with lp64 will reuse this multi-lib set.
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.
(experimental).In addition, the simulator can also be selected with the
configure time option `--with-sim=`.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
@ -201,6 +202,10 @@ To test GCC, run the following commands:
make linux
make report-linux SIM=qemu # Run with qemu
./configure --prefix=$RISCV --with-sim=spike
make linux
make report # Run with spike
Note:
- spike only support rv64* bare-metal/elf toolchain.
- gdb simulator only support bare-metal/elf toolchain.
@ -263,3 +268,5 @@ Here is the list of configure option for specify source tree:
--with-gdb-src
--with-linux-headers-src
--with-qemu-src
--with-spike-src
--with-pk-src

59
configure

@ -587,6 +587,8 @@ LIBOBJS
qemu_targets
enable_libsanitizer
with_linux_headers_src
with_pk_src
with_spike_src
with_qemu_src
with_gdb_src
with_musl_src
@ -607,6 +609,7 @@ newlib_multilib_names
glibc_multilib_names
multilib_flags
multilib_gen
WITH_SIM
WITH_ISA_SPEC
WITH_TUNE
WITH_ABI
@ -676,6 +679,7 @@ with_arch
with_abi
with_tune
with_isa_spec
with_sim
enable_multilib
with_multilib_generator
enable_gcc_checking
@ -693,6 +697,8 @@ with_glibc_src
with_musl_src
with_gdb_src
with_qemu_src
with_spike_src
with_pk_src
with_linux_headers_src
enable_libsanitizer
enable_qemu_system
@ -1344,6 +1350,7 @@ Optional Packages:
--with-tune=rocket Set the base RISC-V CPU, defaults to rocket
--with-isa-spec=2.2 Set the default ISA spec version, default to 2.2,
available options: 2.2, 20190608, 20191213
--with-sim=qemu Sets the base RISC-V Simulator, defaults to qemu
--with-multilib-generator
Multi-libs configuration string, only supported for
bare-metal/elf toolchain, this option implied
@ -1366,6 +1373,8 @@ Optional Packages:
--with-musl-src Set musl source path, use builtin source by default
--with-gdb-src Set gdb source path, use builtin source by default
--with-qemu-src Set qemu source path, use builtin source by default
--with-spike-src Set spike source path, use builtin source by default
--with-pk-src Set pk source path, use builtin source by default
--with-linux-headers-src
Set linux-headers source path, use builtin source by
default
@ -3322,6 +3331,16 @@ else
fi
# Check whether --with-sim was given.
if test "${with_sim+set}" = set; then :
withval=$with_sim;
else
with_sim=qemu
fi
if test "x$with_abi" = xdefault; then :
case $with_arch in #(
*rv64g* | *rv64*d*) :
@ -3352,6 +3371,8 @@ WITH_TUNE=--with-tune=$with_tune
WITH_ISA_SPEC=--with-isa-spec=$with_isa_spec
WITH_SIM=$with_sim
# Check whether --enable-multilib was given.
if test "${enable_multilib+set}" = set; then :
@ -3667,6 +3688,44 @@ fi
else
with_qemu_src="\$(srcdir)/qemu"
fi
}
{
# Check whether --with-spike-src was given.
if test "${with_spike_src+set}" = set; then :
withval=$with_spike_src;
else
with_spike_src=default
fi
if test "x$with_spike_src" != xdefault; then :
with_spike_src=$with_spike_src
else
with_spike_src="\$(srcdir)/spike"
fi
}
{
# Check whether --with-pk-src was given.
if test "${with_pk_src+set}" = set; then :
withval=$with_pk_src;
else
with_pk_src=default
fi
if test "x$with_pk_src" != xdefault; then :
with_pk_src=$with_pk_src
else
with_pk_src="\$(srcdir)/pk"
fi
}

10
configure.ac

@ -78,6 +78,13 @@ AC_ARG_WITH(isa-spec,
[with_isa_spec=2.2]
)
AC_ARG_WITH(sim,
[AS_HELP_STRING([--with-sim=qemu],
[Sets the base RISC-V Simulator, defaults to qemu])],
[],
[with_sim=qemu]
)
AS_IF([test "x$with_abi" = xdefault],
[AS_CASE([$with_arch],
[*rv64g* | *rv64*d*], [with_abi=lp64d],
@ -94,6 +101,7 @@ AC_SUBST(WITH_ARCH, --with-arch=$with_arch)
AC_SUBST(WITH_ABI, --with-abi=$with_abi)
AC_SUBST(WITH_TUNE, --with-tune=$with_tune)
AC_SUBST(WITH_ISA_SPEC, --with-isa-spec=$with_isa_spec)
AC_SUBST(WITH_SIM, $with_sim)
AC_ARG_ENABLE(multilib,
[AS_HELP_STRING([--enable-multilib],
@ -234,6 +242,8 @@ AX_ARG_WITH_SRC(glibc, glibc)
AX_ARG_WITH_SRC(musl, musl)
AX_ARG_WITH_SRC(gdb, riscv-gdb)
AX_ARG_WITH_SRC(qemu, qemu)
AX_ARG_WITH_SRC(spike, spike)
AX_ARG_WITH_SRC(pk, pk)
AC_ARG_WITH(linux-headers-src,
[AC_HELP_STRING([--with-linux-headers-src],

1
pk

@ -0,0 +1 @@
Subproject commit 2efabd3e6604b8a9e8f70baf52f57696680c7855

4
scripts/wrapper/spike/riscv64-unknown-linux-gnu-run

@ -1,7 +1,7 @@
#!/bin/sh
xlen="$(readelf -h $1 | grep 'Class' | cut -d: -f 2 | xargs echo | sed 's/^ELF//')"
arch="${ARCH_STR#*=}"
spike \
--isa=RV${xlen}GC \
--isa=${arch} \
${PK_PATH}/pk${xlen} "$@"

1
spike

@ -0,0 +1 @@
Subproject commit a0298a33e7b2091ba8d9f3a20838d96dc1164cac
Loading…
Cancel
Save