-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstage2-container-build.sh
52 lines (46 loc) · 1.51 KB
/
stage2-container-build.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/bin/bash
# stage1-container-build.sh
# This does the inital configuration of the container
# and is a shell file for simplicity and to perform
# actions that are hard to define in a Containerfile
# This is run during the container creation process
# and then removed from the container. It is not
# needed to be run by container users.
# Get to the HOME directory
cd $HOME
# Compute make -j number
THREADCOUNT=$(grep processor /proc/cpuinfo | wc -l)
# Assume SMT
CORECOUNT=$((THREADCOUNT/2))
# Reduce by 2
JCOUNT=$((CORECOUNT-2))
# Check we're not below 1
if [ 1 -gt "$JCOUNT" ]; then
JCOUNT=1
fi
echo Threads: $THREADCOUNT
echo Cores Estimate: $CORECOUNT
echo Final J number: $JCOUNT
# Download, Build, Install, and Cleanup the RISC-V GNU Toolchain
git clone https://github.com/riscv-collab/riscv-gnu-toolchain $HOME/riscv-gnu-toolchain
cd $HOME/riscv-gnu-toolchain
./configure --prefix=/opt/riscv-newlib --enable-multilib
time make -j$JCOUNT
echo ^^^ GCC Toolchain compile and install time
cd $HOME
rm -r $HOME/riscv-gnu-toolchain
echo '#Add RISC-V multilib newlib toolchain to path' >> $HOME/.bashrc
echo 'export PATH=$PATH:/opt/riscv-newlib/bin' >> $HOME/.bashrc
# Download, Build, Install, and Cleanup the SPIKE model
cd $HOME
git clone https://github.com/riscv/riscv-isa-sim.git -b master
cd riscv-isa-sim
mkdir build
cd build
../configure --prefix=/opt/spike
make -j${JCOUNT}
make install
cd $HOME
rm -r riscv-isa-sim
echo '#Add RISC-V spike model to path' >> $HOME/.bashrc
echo 'export PATH=$PATH:/opt/spike/bin' >> $HOME/.bashrc