Skip to content

Commit 59cbef8

Browse files
committed
Add spike-stf and stf_tools to the Dockerfile
1 parent 26fd7e9 commit 59cbef8

File tree

3 files changed

+105
-33
lines changed

3 files changed

+105
-33
lines changed
Lines changed: 94 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,97 @@
1-
FROM ubuntu:22.04
1+
FROM ubuntu:24.04
22

3-
RUN apt-get update
4-
RUN apt-get install -y device-tree-compiler libboost-regex-dev libboost-system-dev git binutils build-essential cmake gcc-riscv64-linux-gnu zstd libzstd-dev autoconf automake autotools-dev curl python3 python3-pip python3-tomli libmpc-dev libmpfr-dev libgmp-dev gawk build-essential bison flex texinfo gperf libtool patchutils bc zlib1g-dev libexpat-dev ninja-build git cmake libglib2.0-dev libslirp-dev
3+
# Combine apt-get commands and clean up to reduce image size
4+
RUN apt-get update && apt-get install -y \
5+
device-tree-compiler \
6+
libboost-regex-dev \
7+
libboost-system-dev \
8+
libboost-program-options-dev \
9+
libboost-json-dev \
10+
rapidjson-dev \
11+
libhdf5-dev \
12+
liblzma-dev \
13+
libbz2-dev \
14+
cython3 \
15+
git \
16+
binutils \
17+
build-essential \
18+
cmake \
19+
gcc-riscv64-linux-gnu \
20+
zstd \
21+
libzstd-dev \
22+
autoconf \
23+
automake \
24+
autotools-dev \
25+
curl \
26+
python3 \
27+
python3-pip \
28+
python3-tomli \
29+
libmpc-dev \
30+
libmpfr-dev \
31+
libgmp-dev \
32+
gawk \
33+
bison \
34+
flex \
35+
texinfo \
36+
gperf \
37+
libtool \
38+
patchutils \
39+
bc \
40+
zlib1g-dev \
41+
libexpat-dev \
42+
ninja-build \
43+
libglib2.0-dev \
44+
libslirp-dev \
45+
wget \
46+
&& rm -rf /var/lib/apt/lists/*
547

6-
RUN mkdir riscv
48+
# Set up RISCV environment
749
ENV RISCV=/riscv
8-
ENV PATH=$RISCV/bin:$PATH
9-
10-
RUN git clone https://github.com/jeffnye-gh/riscv-isa-sim.git
11-
RUN git clone https://github.com/riscv-software-src/riscv-pk.git
12-
RUN git clone https://github.com/riscv-collab/riscv-gnu-toolchain.git
13-
14-
WORKDIR /riscv-gnu-toolchain
15-
RUN ./configure --prefix=/opt/riscv
16-
ENV PATH=/opt/riscv/bin:$PATH
17-
RUN make -j$(nproc)
18-
19-
WORKDIR /riscv-pk/build
20-
RUN ../configure --prefix=$RISCV --host=riscv64-unknown-elf
21-
RUN make -j$(nproc)
22-
RUN make install
23-
24-
WORKDIR /riscv-isa-sim/build
25-
RUN git checkout spike_stf
26-
RUN git submodule update --init --recursive
27-
RUN ../configure --prefix=$RISCV
28-
RUN make -j$(nproc)
29-
RUN make install
50+
ENV PATH=$RISCV/bin:/opt/riscv/bin:$PATH
51+
RUN mkdir -p $RISCV
52+
53+
# Using HTTP instead of SSH to avoid setting git credentials
54+
RUN git config --global url."https://github.com/".insteadOf "git@github.com:"
55+
56+
# Generic config details required during the cloning (git am, apply,patch done during the toolchain build process)
57+
RUN git config --global user.email "builder@example.com" && \
58+
git config --global user.name "Docker Builder"
59+
60+
61+
# Clone repositories
62+
WORKDIR $RISCV
63+
RUN git clone https://github.com/condorcomputing/condor.riscv-isa-sim.git --recurse-submodules || exit 1
64+
RUN git clone https://github.com/sparcians/stf_tools || exit 1
65+
RUN git clone https://github.com/riscv-software-src/riscv-pk.git || exit 1
66+
RUN git clone https://github.com/riscv-collab/riscv-gnu-toolchain.git || exit 1
67+
68+
# Build riscv-gnu-toolchain
69+
WORKDIR $RISCV/riscv-gnu-toolchain
70+
RUN ./configure --prefix=/opt/riscv && make -j$(nproc) && make install
71+
72+
# Build riscv-pk
73+
WORKDIR $RISCV/riscv-pk/build
74+
RUN ../configure --prefix=$RISCV --host=riscv64-unknown-elf && make -j$(nproc) && make install
75+
76+
# Build stf_tools
77+
WORKDIR $RISCV/stf_tools
78+
RUN git submodule update --init --recursive || exit 1
79+
WORKDIR $RISCV/stf_tools/release
80+
RUN cmake .. -DCMAKE_BUILD_TYPE=Release && make -j$(nproc)
81+
82+
# Build condor.riscv-isa-sim
83+
WORKDIR $RISCV/condor.riscv-isa-sim
84+
RUN bash scripts/download-bm-compiler.sh && \
85+
COMPILER_DIR=$(find . -maxdepth 1 -type d -name "riscv-embecosm-*" | head -n 1) && \
86+
[ -n "$COMPILER_DIR" ] || (echo "Error: riscv-embecosm-* directory not found!" && exit 1) && \
87+
export PATH=$(pwd)/$COMPILER_DIR/bin:$PATH && \
88+
echo "export PATH=/riscv/condor.riscv-isa-sim/$COMPILER_DIR/bin:\$PATH" >> /root/.bashrc && \
89+
mkdir -p build && cd build && \
90+
../configure --prefix=$RISCV/condor.riscv-isa-sim/install && \
91+
make -j$(nproc) && \
92+
make regress && \
93+
make install
94+
95+
# shell
96+
CMD ["/bin/bash"]
97+

traces/docker_stf_trace_gen/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ This setup provides a containerized workflow to generate STF traces using Spike-
2424

2525
```bash
2626
qemu-simpoint-dhrystone/
27-
├── Dockerfile # Creates a Docker image with the RISC-V GNU toolchain, pk, and Spike-STF
27+
├── Dockerfile # Creates a Docker image with the RISC-V GNU toolchain, pk, stf_tools and Spike-STF
2828
├── run_in_docker.sh # Runs an STF trace generation example inside the container
2929
├── build_docker.sh # Builds the Docker image
3030
├── build_and_run.sh # Executes both build_docker and run_in_docker scripts
@@ -51,9 +51,9 @@ docker build -t spike-stf .
5151
mkdir -p trace_output
5252

5353
docker run --rm \
54-
-v ./trace_output:/output \
55-
spike-stf \
54+
-v "$OUTPUT_DIR":/riscv/condor.riscv-isa-sim/trace_out \
55+
"$IMAGE_NAME" \
5656
bash -c "
57-
echo '<REPLACE THIS ECHO COMMAND WITH SPIKE STF TRACE GENERATION COMMAND>' >> /output/EXAMPLE.zstf
57+
bash scripts/run-spike-stf.sh $BINARY_NAME $TRACEOUT_NAME
5858
"
5959
```

traces/docker_stf_trace_gen/run_in_docker.sh

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,15 @@ set -e
55
IMAGE_NAME="spike-stf"
66
OUTPUT_DIR="$(pwd)/trace_output"
77

8+
# The binary to run on spike (bare-metal)
9+
BINARY_NAME="dhrystone/bin/dhrystone_opt1.1000.gcc.bare.riscv"
10+
TRACEOUT_NAME="trace_output.zstf"
11+
812
mkdir -p "$OUTPUT_DIR"
913

1014
docker run --rm \
11-
-v "$OUTPUT_DIR":/output \
15+
-v "$OUTPUT_DIR":/riscv/condor.riscv-isa-sim/trace_out \
1216
"$IMAGE_NAME" \
1317
bash -c "
14-
echo '<REPLACE THIS ECHO COMMAND WITH SPIKE STF TRACE GENERATION COMMAND>' >> /output/EXAMPLE.zstf
15-
"
18+
bash scripts/run-spike-stf.sh $BINARY_NAME $TRACEOUT_NAME
19+
"

0 commit comments

Comments
 (0)