Skip to content

Commit 71e9e38

Browse files
authored
Merge pull request #1080 from Liaoshihua/spike-toolchain
Change default simulator from qemu to spike.
2 parents 1342cd7 + 5a2b88b commit 71e9e38

File tree

8 files changed

+106
-22
lines changed

8 files changed

+106
-22
lines changed

.gitmodules

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,11 @@
2828
path = musl
2929
url = git://git.musl-libc.org/musl
3030
branch = master
31+
[submodule "spike"]
32+
path = spike
33+
url = https://github.com/riscv-software-src/riscv-isa-sim.git
34+
branch = master
35+
[submodule "pk"]
36+
path = pk
37+
url = https://github.com/riscv-software-src/riscv-pk.git
38+
branch = master

Makefile.in

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,10 @@ MUSL_SRCDIR := @with_musl_src@
1010
LINUX_HEADERS_SRCDIR := @with_linux_headers_src@
1111
GDB_SRCDIR := @with_gdb_src@
1212
QEMU_SRCDIR := @with_qemu_src@
13+
SPIKE_SRCDIR := @with_spike_src@
14+
PK_SRCDIR := @with_pk_src@
1315

14-
SIM:=qemu
15-
16-
# Default branch for proxy kernel and spike
17-
SPIKE_BRANCH:=master
18-
PK_BRANCH:=master
16+
SIM ?= @WITH_SIM@
1917

2018
ifeq ($(srcdir)/riscv-gcc,$(GCC_SRCDIR))
2119
# We need a relative source dir for the gcc configure, to make msys2 mingw64
@@ -180,7 +178,7 @@ else
180178
ifeq ($(SIM),spike)
181179
# Using spike simulator.
182180
SIM_PATH:=$(srcdir)/scripts/wrapper/spike
183-
SIM_PREPARE:=PATH="$(SIM_PATH):$(INSTALL_DIR)/bin:$(PATH)" PK_PATH="$(INSTALL_DIR)/$(NEWLIB_TUPLE)/bin/"
181+
SIM_PREPARE:=PATH="$(SIM_PATH):$(INSTALL_DIR)/bin:$(PATH)" PK_PATH="$(INSTALL_DIR)/$(NEWLIB_TUPLE)/bin/" ARCH_STR="$(WITH_ARCH)"
184182
SIM_STAMP:= stamps/build-spike
185183
ifneq (,$(findstring rv32,$(NEWLIB_MULTILIB_NAMES)))
186184
SIM_STAMP+= stamps/build-pk32
@@ -259,6 +257,12 @@ else
259257
QEMU_SRC_GIT :=
260258
endif
261259

260+
ifeq ($(findstring $(srcdir),$(SPIKE_SRCDIR)),$(srcdir))
261+
SPIKE_SRC_GIT := $(SPIKE_SRCDIR)/.git
262+
else
263+
SPIKE_SRC_GIT :=
264+
endif
265+
262266
ifneq ("$(wildcard $(GCC_SRCDIR)/.git)","")
263267
GCCPKGVER := g$(shell git -C $(GCC_SRCDIR) describe --always --dirty --exclude '*')
264268
else
@@ -804,26 +808,20 @@ stamps/build-gcc-musl-stage2: $(GCC_SRCDIR) $(GCC_SRC_GIT) stamps/build-musl-lin
804808
cp -a $(INSTALL_DIR)/$(MUSL_TUPLE)/lib* $(SYSROOT)
805809
mkdir -p $(dir $@) && touch $@
806810

807-
spike-src:
808-
git clone https://github.com/riscv/riscv-isa-sim.git -b $(SPIKE_BRANCH) $@
809-
810-
pk-src:
811-
git clone https://github.com/riscv/riscv-pk.git -b $(PK_BRANCH) $@
812-
813-
stamps/build-spike: spike-src
811+
stamps/build-spike: $(SPIKE_SRCDIR) $(SPIKE_SRC_GIT)
814812
rm -rf $@ $(notdir $@)
815813
mkdir $(notdir $@)
816-
cd $(notdir $@) && ../$</configure \
814+
cd $(notdir $@) && $</configure \
817815
--prefix=$(INSTALL_DIR)
818816
$(MAKE) -C $(notdir $@)
819817
$(MAKE) -C $(notdir $@) install
820818
mkdir -p $(dir $@)
821819
date > $@
822820

823-
stamps/build-pk32: pk-src stamps/build-gcc-newlib-stage2
821+
stamps/build-pk32: $(PK_SRCDIR) stamps/build-gcc-newlib-stage2
824822
rm -rf $@ $(notdir $@)
825823
mkdir $(notdir $@)
826-
cd $(notdir $@) && ../$</configure \
824+
cd $(notdir $@) && $</configure \
827825
--prefix=$(INSTALL_DIR) \
828826
--host=$(NEWLIB_TUPLE) \
829827
--with-arch=rv32gc
@@ -832,10 +830,10 @@ stamps/build-pk32: pk-src stamps/build-gcc-newlib-stage2
832830
mkdir -p $(dir $@)
833831
date > $@
834832

835-
stamps/build-pk64: pk-src stamps/build-gcc-newlib-stage2
833+
stamps/build-pk64: $(PK_SRCDIR) stamps/build-gcc-newlib-stage2
836834
rm -rf $@ $(notdir $@)
837835
mkdir $(notdir $@)
838-
cd $(notdir $@) && ../$</configure \
836+
cd $(notdir $@) && $</configure \
839837
--prefix=$(INSTALL_DIR) \
840838
--host=$(NEWLIB_TUPLE) \
841839
--with-arch=rv64gc

README.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,9 @@ rv64imac with lp64 and rv64imafc with lp64 will reuse this multi-lib set.
189189
The Dejagnu test suite has been ported to RISC-V. This can be run with a
190190
simulator for the elf and linux toolchains. The simulator can be selected
191191
by the SIM variable in the Makefile, e.g. SIM=qemu, SIM=gdb, or SIM=spike
192-
(experimental). However, the testsuite allowlist is only mintained for qemu.
193-
Other simulators might get extra failures.
192+
(experimental).In addition, the simulator can also be selected with the
193+
configure time option `--with-sim=`.However, the testsuite allowlist is
194+
only mintained for qemu.Other simulators might get extra failures.
194195
To test GCC, run the following commands:
195196

196197
./configure --prefix=$RISCV --disable-linux --with-arch=rv64ima # or --with-arch=rv32ima
@@ -201,6 +202,10 @@ To test GCC, run the following commands:
201202
make linux
202203
make report-linux SIM=qemu # Run with qemu
203204

205+
./configure --prefix=$RISCV --with-sim=spike
206+
make linux
207+
make report # Run with spike
208+
204209
Note:
205210
- spike only support rv64* bare-metal/elf toolchain.
206211
- gdb simulator only support bare-metal/elf toolchain.
@@ -263,3 +268,5 @@ Here is the list of configure option for specify source tree:
263268
--with-gdb-src
264269
--with-linux-headers-src
265270
--with-qemu-src
271+
--with-spike-src
272+
--with-pk-src

configure

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -587,6 +587,8 @@ LIBOBJS
587587
qemu_targets
588588
enable_libsanitizer
589589
with_linux_headers_src
590+
with_pk_src
591+
with_spike_src
590592
with_qemu_src
591593
with_gdb_src
592594
with_musl_src
@@ -607,6 +609,7 @@ newlib_multilib_names
607609
glibc_multilib_names
608610
multilib_flags
609611
multilib_gen
612+
WITH_SIM
610613
WITH_ISA_SPEC
611614
WITH_TUNE
612615
WITH_ABI
@@ -676,6 +679,7 @@ with_arch
676679
with_abi
677680
with_tune
678681
with_isa_spec
682+
with_sim
679683
enable_multilib
680684
with_multilib_generator
681685
enable_gcc_checking
@@ -693,6 +697,8 @@ with_glibc_src
693697
with_musl_src
694698
with_gdb_src
695699
with_qemu_src
700+
with_spike_src
701+
with_pk_src
696702
with_linux_headers_src
697703
enable_libsanitizer
698704
enable_qemu_system
@@ -1344,6 +1350,7 @@ Optional Packages:
13441350
--with-tune=rocket Set the base RISC-V CPU, defaults to rocket
13451351
--with-isa-spec=2.2 Set the default ISA spec version, default to 2.2,
13461352
available options: 2.2, 20190608, 20191213
1353+
--with-sim=qemu Sets the base RISC-V Simulator, defaults to qemu
13471354
--with-multilib-generator
13481355
Multi-libs configuration string, only supported for
13491356
bare-metal/elf toolchain, this option implied
@@ -1366,6 +1373,8 @@ Optional Packages:
13661373
--with-musl-src Set musl source path, use builtin source by default
13671374
--with-gdb-src Set gdb source path, use builtin source by default
13681375
--with-qemu-src Set qemu source path, use builtin source by default
1376+
--with-spike-src Set spike source path, use builtin source by default
1377+
--with-pk-src Set pk source path, use builtin source by default
13691378
--with-linux-headers-src
13701379
Set linux-headers source path, use builtin source by
13711380
default
@@ -3322,6 +3331,16 @@ else
33223331
fi
33233332
33243333
3334+
3335+
# Check whether --with-sim was given.
3336+
if test "${with_sim+set}" = set; then :
3337+
withval=$with_sim;
3338+
else
3339+
with_sim=qemu
3340+
3341+
fi
3342+
3343+
33253344
if test "x$with_abi" = xdefault; then :
33263345
case $with_arch in #(
33273346
*rv64g* | *rv64*d*) :
@@ -3352,6 +3371,8 @@ WITH_TUNE=--with-tune=$with_tune
33523371
33533372
WITH_ISA_SPEC=--with-isa-spec=$with_isa_spec
33543373
3374+
WITH_SIM=$with_sim
3375+
33553376
33563377
# Check whether --enable-multilib was given.
33573378
if test "${enable_multilib+set}" = set; then :
@@ -3667,6 +3688,44 @@ fi
36673688
else
36683689
with_qemu_src="\$(srcdir)/qemu"
36693690
3691+
fi
3692+
3693+
}
3694+
{
3695+
3696+
# Check whether --with-spike-src was given.
3697+
if test "${with_spike_src+set}" = set; then :
3698+
withval=$with_spike_src;
3699+
else
3700+
with_spike_src=default
3701+
3702+
fi
3703+
3704+
if test "x$with_spike_src" != xdefault; then :
3705+
with_spike_src=$with_spike_src
3706+
3707+
else
3708+
with_spike_src="\$(srcdir)/spike"
3709+
3710+
fi
3711+
3712+
}
3713+
{
3714+
3715+
# Check whether --with-pk-src was given.
3716+
if test "${with_pk_src+set}" = set; then :
3717+
withval=$with_pk_src;
3718+
else
3719+
with_pk_src=default
3720+
3721+
fi
3722+
3723+
if test "x$with_pk_src" != xdefault; then :
3724+
with_pk_src=$with_pk_src
3725+
3726+
else
3727+
with_pk_src="\$(srcdir)/pk"
3728+
36703729
fi
36713730
36723731
}

configure.ac

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,13 @@ AC_ARG_WITH(isa-spec,
7878
[with_isa_spec=2.2]
7979
)
8080

81+
AC_ARG_WITH(sim,
82+
[AS_HELP_STRING([--with-sim=qemu],
83+
[Sets the base RISC-V Simulator, defaults to qemu])],
84+
[],
85+
[with_sim=qemu]
86+
)
87+
8188
AS_IF([test "x$with_abi" = xdefault],
8289
[AS_CASE([$with_arch],
8390
[*rv64g* | *rv64*d*], [with_abi=lp64d],
@@ -94,6 +101,7 @@ AC_SUBST(WITH_ARCH, --with-arch=$with_arch)
94101
AC_SUBST(WITH_ABI, --with-abi=$with_abi)
95102
AC_SUBST(WITH_TUNE, --with-tune=$with_tune)
96103
AC_SUBST(WITH_ISA_SPEC, --with-isa-spec=$with_isa_spec)
104+
AC_SUBST(WITH_SIM, $with_sim)
97105

98106
AC_ARG_ENABLE(multilib,
99107
[AS_HELP_STRING([--enable-multilib],
@@ -234,6 +242,8 @@ AX_ARG_WITH_SRC(glibc, glibc)
234242
AX_ARG_WITH_SRC(musl, musl)
235243
AX_ARG_WITH_SRC(gdb, riscv-gdb)
236244
AX_ARG_WITH_SRC(qemu, qemu)
245+
AX_ARG_WITH_SRC(spike, spike)
246+
AX_ARG_WITH_SRC(pk, pk)
237247

238248
AC_ARG_WITH(linux-headers-src,
239249
[AC_HELP_STRING([--with-linux-headers-src],

pk

Submodule pk added at 2efabd3
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/sh
22

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

spike

Submodule spike added at a0298a3

0 commit comments

Comments
 (0)