Skip to content

Commit 37c83f5

Browse files
committed
Add build instruction
1 parent fdd11b9 commit 37c83f5

File tree

4 files changed

+52
-5
lines changed

4 files changed

+52
-5
lines changed

Makefile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# TODO: check unsupported extensions
2-
RV32_EXT ?= rv32i
3-
OPT_LEVEL := 0 1 2
2+
3+
RV32_EXT ?= rv32gc
4+
OPT_LEVEL ?= 0 1 2
45

56
CFLAGS := -std=c99
67
LDFLAGS := -lsemihost -lm

README.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# The test suite for [rv32emu project](https://github.com/sysprog21/rv32emu)
2+
3+
## Prerequisites
4+
5+
This test suite relies RISC-V GNU toolchain to build the ELF files. See the [prerequisites section](https://github.com/riscv-collab/riscv-gnu-toolchain?tab=readme-ov-file#prerequisites) of RISC-V GNU toolchain.
6+
7+
## Build ELFs
8+
9+
Run `make` to build the binaries.
10+
The default enabled extensions of RISC-V are `rv32gc` (a.k.a. rv32imafdc) and the optimization levels are `O0, O1, O2`.
11+
These two options can be overrided by the argument `RV32_EXT` and `OPT_LEVEL`.
12+
13+
```shell
14+
$ make [RV32_EXT=<rv32_ext>] [OPT_LEVEL=<opt_level>]
15+
```
16+
17+
The `RV32_EXT` takes the same value that passing to `--with-arch` of the RISC-V GNU toolchain, and the `OPT_LEVEL` takes the combination of the whitespace separated number of 0, 1, 2 and quoted with the (double) quotation marks.
18+
19+
e.g.
20+
21+
```shell
22+
$ make RV32_EXT=rv32im OPT_LEVEL="0 2"
23+
```
24+
25+
Notice that the above command will build the corresponding toolchain first if it doesn't exist and might take a few time.
26+
You can set the `--jobs (-j)` option to enable the parallel build.
27+
28+
---
29+
30+
The built binaries will be placed in the corresponding subdirectories under the `build` directory.
31+
32+
```
33+
rv32emu-prebuilt/
34+
+-- build/
35+
| +-- <RV32_EXT>/
36+
| +-- O0/
37+
| | ...
38+
| |
39+
| +-- O1/
40+
| | ...
41+
| |
42+
| +-- O2/
43+
| | ...
44+
|
45+
+-- ...
46+
```

src/ansibench/nbench/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ SRC_DIR := $(CURDIR)/src
77
CFLAGS := -c -std=c99 -I$(CURDIR)/include
88
LDFLAGS := -lm
99

10-
# prevent lazy set if not providing initial value
10+
# prevent lazy set
1111
ifeq ($(BUILD_DIR),)
1212
BUILD_DIR := $(CURDIR)/build
1313
endif

src/asm-hello/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
RV32_EXT ?= rv32i
1+
RV32_EXT ?= rv32gc
22
OPT_LEVEL ?= 0 1 2
33

44
ASFLAGS := -march=$(RV32_EXT) -mabi=ilp32
@@ -7,7 +7,7 @@ LDFLAGS := --oformat=elf32-littleriscv
77
CURDIR := $(abspath $(dir $(lastword $(MAKEFILE_LIST))))
88
SRC_DIR := $(CURDIR)
99

10-
# prevent lazy set if not providing initial value
10+
# prevent lazy set
1111
ifeq ($(BUILD_DIR),)
1212
BUILD_DIR := $(CURDIR)/build
1313
endif

0 commit comments

Comments
 (0)