Skip to content

Commit 2746418

Browse files
committed
Add "ieeelib" and ENABLE_PREBUILT option
1 parent 709d6e3 commit 2746418

File tree

10 files changed

+65
-31
lines changed

10 files changed

+65
-31
lines changed

.github/workflows/build-artifact.yml

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
- name: Set alias
2727
id: has_files_changed
2828
run: |
29-
if [[ ${{ steps.files-changed.outputs.any_changed }} == true ]]; then
29+
if [[ ${{ steps.files-changed.outputs.any_modified }} == true ]]; then
3030
echo "has_files_changed=true" >> $GITHUB_OUTPUT
3131
else
3232
echo "has_files_changed=false" >> $GITHUB_OUTPUT
@@ -48,19 +48,37 @@ jobs:
4848
sudo apt-get update -q -y
4949
sudo apt-get upgrade -q -y
5050
sudo apt-get install -q -y gcc-multilib g++-multilib
51+
sudo apt-get install -q -y opam build-essential libgmp-dev z3 pkg-config zlib1g-dev
5152
.ci/riscv-toolchain-install.sh
5253
echo "$PWD/toolchain/bin" >> $GITHUB_PATH
5354
- name: Build binaries
5455
run: |
55-
make artifact USE_PREBUILT=0
56+
make artifact ENABLE_PREBUILT=0
57+
mkdir -p /tmp/rv32emu-prebuilt
58+
mv build/linux-x86-softfp build/riscv32 /tmp/rv32emu-prebuilt
59+
- name: Buile Sail model
60+
run: |
61+
cd /tmp
62+
opam init -y --disable-sandboxing
63+
opam switch create ocaml-base-compiler.4.06.1
64+
opam install sail -y
65+
eval $(opam config env)
66+
git clone https://github.com/riscv/sail-riscv.git
67+
cd sail-riscv
68+
git checkout 9547a30bf84572c458476591b569a95f5232c1c7
69+
ARCH=RV32 make -j
70+
mkdir -p /tmp/rv32emu-prebuilt/sail_cSim
71+
mv c_emulator/riscv_sim_RV32 /tmp/rv32emu-prebuilt/sail_cSim
5672
- name: Create tarball
5773
run: |
58-
tar -C build -zcf rv32emu-prebuilt.tar.gz linux-x64 riscv32
74+
cd /tmp
75+
tar -zcvf rv32emu-prebuilt.tar.gz rv32emu-prebuilt
5976
- name: Create GitHub Release
6077
env:
6178
GH_TOKEN: ${{ secrets.RV32EMU_PREBUILT_TOKEN }}
6279
run: |
6380
RELEASE_TAG=$(date +'%Y.%m.%d')
81+
cd /tmp
6482
gh release create $RELEASE_TAG \
6583
--repo sysprog21/rv32emu-prebuilt \
6684
--title "$RELEASE_TAG""-nightly"

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,14 @@ build/softfloat
1616
build/cache/
1717
build/map/
1818
build/path/
19-
build/linux-x64/
19+
build/linux-x86-softfp/
2020
build/riscv32/
21+
build/sail_cSim/
22+
*.a
2123
*.o
2224
*.o.d
2325
tests/**/*.elf
2426
tests/arch-test-target/config.ini
27+
tests/arch-test-target/sail_cSim/riscv_sim_RV32
2528
__pycache__/
2629
src/rv32_jit.c

.gitmodules

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,7 @@
1919
path = tests/rv8-bench
2020
url = https://github.com/sysprog21/rv8-bench
2121
shallow = true
22+
[submodule "src/ieeelib"]
23+
path = src/ieeelib
24+
url = https://github.com/sysprog21/ieeelib
25+
shallow = true

docs/prebuilt.md

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
# Prebuilt Binaries
22

3-
There are some prebuilt binaries placed in [rv32emu-prebuilt](https://github.com/sysprog21/rv32emu-prebuilt).
4-
When invoking testing or benchmarking, the prebuilt binaries will be pulled into `build/linux-x64/` and `build/riscv32/` directory in default.
5-
The RISC-V binaries are built from [xPack RISC-V GCC toolchain](https://github.com/xpack-dev-tools/riscv-none-elf-gcc-xpack) with `-march=rv32im -mabi=ilp32` options.
3+
The prebuilt binaries for [rv32emu](https://github.com/sysprog21/rv32emu) are prepared primarily because the [RISC-V Sail Model](https://github.com/riscv/sail-riscv) executable is required for the [RISC-V Architecture Test](https://github.com/riscv-non-isa/riscv-arch-test), and selected RISC-V ELF files are useful for ISA simulation validation and testing. Some of these prebuilt binaries are stored in [rv32emu-prebuilt](https://github.com/sysprog21/rv32emu-prebuilt). During testing or benchmarking, these binaries are automatically downloaded into the `build/linux-x86-softfp/` and `build/riscv32/` directories by default. The RISC-V binaries are compiled using the [xPack RISC-V GCC toolchain](https://github.com/xpack-dev-tools/riscv-none-elf-gcc-xpack) with the options `-march=rv32im -mabi=ilp32`.
64

75
To fetch the prebuilt binaries manually, run:
86

@@ -13,18 +11,18 @@ $ make artifact
1311
Or build the binaries from scratch (the RISC-V cross-compiler is required):
1412

1513
```shell
16-
$ make artifact USE_PREBUILT=0 [CROSS_COMPILE=<COMPILER_PREFIX>]
14+
$ make artifact ENABLE_PREBUILT=0 [CROSS_COMPILE=<COMPILER_PREFIX>]
1715
```
1816

1917
The compiler prefix varies according to the used toolchain, such as `riscv-none-elf-`, `riscv32-unknwon-elf-`, etc.
2018

2119
The prebuilt binaries in `rv32emu-prebuilt` are built from the following repositories and resources:
2220

23-
- [ansibench](https://github.com/nfinit/ansibench)
21+
- [ansibench](https://github.com/sysprog21/ansibench)
2422
- coremark
2523
- stream
2624
- nbench
27-
- [rv8-bench](https://github.com/michaeljclark/rv8-bench)
25+
- [rv8-bench](https://github.com/sysprog21/rv8-bench)
2826
- aes
2927
- dhrystone
3028
- miniz
@@ -51,8 +49,6 @@ The prebuilt binaries in `rv32emu-prebuilt` are built from the following reposit
5149
- `spirograph` : See [tests/spirograph.c](tests/spirograph.c)
5250
- `uaes` : See [tests/uaes.c](tests/uaes.c)
5351

54-
---
55-
5652
There are still some prebuilt standalone RISC-V binaries under `build/` directory only for testing purpose:
5753

5854
- `hello.elf` : See [tests/asm-hello](tests/asm-hello)

mk/artifact.mk

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
USE_PREBUILT ?= 1
1+
ENABLE_PREBUILT ?= 1
22

33
CC ?= gcc
44
CROSS_COMPILE ?= riscv-none-elf-
@@ -16,7 +16,6 @@ TESTBENCHES += \
1616
donut \
1717
fcalc \
1818
hamilton \
19-
$(ieee754) \
2019
jit \
2120
lena \
2221
line \
@@ -29,29 +28,41 @@ TESTBENCHES += \
2928
qrcode \
3029
richards \
3130
rvsim \
32-
$(smolnes) \
3331
spirograph \
34-
$(ticks) \
3532
uaes
3633

37-
ifeq ($(USE_PREBUILT),1)
34+
SHELL_HACK := $(shell mkdir -p $(BINDIR)/linux-x86-softfp $(BINDIR)/riscv32)
35+
36+
ifeq ($(call has, PREBUILT), 1)
3837
LATEST_RELEASE := $(shell wget -q https://api.github.com/repos/sysprog21/rv32emu-prebuilt/releases/latest -O- | grep -Po '(?<="tag_name": ").+(?=",)')
38+
else
39+
CFLAGS := -m32 -mno-sse -mno-sse2 -msoft-float -O2 -L$(BINDIR)
40+
LDFLAGS := -lsoft-fp -lm
41+
42+
CFLAGS_CROSS := -march=rv32im -mabi=ilp32 -O2
43+
LDFLAGS_CROSS := -lm -lsemihost
3944
endif
4045

4146
.PHONY: artifact
4247

4348
artifact:
44-
ifeq ($(USE_PREBUILT),1)
45-
@echo "Fetching prebuilt executables in \"rv32emu-prebuilt\"..."
46-
@wget -q --show-progress https://github.com/sysprog21/rv32emu-prebuilt/releases/download/$(LATEST_RELEASE)/rv32emu-prebuilt.tar.gz -O- | tar -C build -xz
49+
ifeq ($(call has, PREBUILT), 1)
50+
$(Q)$(PRINTF) "Fetching prebuilt executables from \"rv32emu-prebuilt\" ...\n"
51+
$(Q)wget -q --show-progress https://github.com/sysprog21/rv32emu-prebuilt/releases/download/$(LATEST_RELEASE)/rv32emu-prebuilt.tar.gz -O- | tar -C build --strip-components=1 -xz
4752
else
48-
@$(foreach tb,$(TEST_SUITES), \
49-
git submodule update --init ./tests/$(tb) &&) true
50-
@$(foreach tb,$(TEST_SUITES), \
51-
$(MAKE) -C ./tests/$(tb) all BINDIR=$(BINDIR) &&) true
52-
@$(foreach tb,$(TESTBENCHES), \
53-
$(CC) -m32 -O2 -Wno-unused-result -o $(BINDIR)/linux-x64/$(tb) tests/$(tb).c -lm &&) true
54-
@$(foreach tb,$(TESTBENCHES), \
55-
$(CROSS_COMPILE)gcc -march=rv32im -mabi=ilp32 -O2 -Wno-unused-result -Wno-implicit-function-declaration \
56-
-o $(BINDIR)/riscv32/$(tb) tests/$(tb).c -lm -lsemihost &&) true
53+
git submodule update --init ./src/ieeelib $(addprefix ./tests/,$(foreach tb,$(TEST_SUITES),$(tb)))
54+
$(Q)$(MAKE) -C ./src/ieeelib CC=$(CC) CFLAGS="$(CFLAGS)" BINDIR=$(BINDIR)
55+
$(Q)for tb in $(TEST_SUITES); do \
56+
CC=$(CC) CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" BINDIR=$(BINDIR)/linux-x86-softfp $(MAKE) -C ./tests/$$tb; \
57+
done
58+
$(Q)for tb in $(TEST_SUITES); do \
59+
CC=$(CROSS_COMPILE)gcc CFLAGS="$(CFLAGS_CROSS)" LDFLAGS="$(LDFLAGS_CROSS)" BINDIR=$(BINDIR)/riscv32 $(MAKE) -C ./tests/$$tb; \
60+
done
61+
$(Q)$(PRINTF) "Building standalone testbenches ...\n"
62+
$(Q)for tb in $(TESTBENCHES); do \
63+
$(CC) $(CFLAGS) -Wno-unused-result -o $(BINDIR)/linux-x86-softfp/$$tb ./tests/$$tb.c $(LDFLAGS); \
64+
done
65+
$(Q)for tb in $(TESTBENCHES); do \
66+
$(CROSS_COMPILE)gcc $(CFLAGS_CROSS) -o $(BINDIR)/riscv32/$$tb ./tests/$$tb.c $(LDFLAGS_CROSS); \
67+
done
5768
endif

mk/riscv-arch-test.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ ifeq ($(CROSS_COMPILE),)
1414
$(error GNU Toolchain for RISC-V is required to build architecture tests. Please check package installation)
1515
endif
1616
git submodule update --init $(dir $(ARCH_TEST_DIR))
17+
$(Q)cp $(OUT)/sail_cSim/riscv_sim_RV32 tests/arch-test-target/sail_cSim/riscv_sim_RV32
1718
$(Q)python3 -B $(RISCV_TARGET)/setup.py --riscv_device=$(RISCV_DEVICE)
1819
$(Q)riscof run --work-dir=$(WORK) \
1920
--config=$(RISCV_TARGET)/config.ini \

src/ieeelib

Submodule ieeelib added at 8bd3044
-607 KB
Binary file not shown.

tests/rv8-bench

Submodule rv8-bench updated 1 file

0 commit comments

Comments
 (0)