Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
bti-build-instruction.sh
# Ubuntu, install prerequisites
sudo apt-get install autoconf automake autotools-dev curl python3 libmpc-dev libmpfr-dev libgmp-dev gawk build-essential bison flex texinfo gperf libtool patchutils bc zlib1g-dev libexpat-dev
# Install RISCV toolchain
git clone https://github.com/riscv/riscv-gnu-toolchain
cd riscv-gnu-toolchain
git submodule update --init --recursive
./configure --prefix=/opt/riscv --with-arch=rv32g --with-abi=ilp32d
make linux
# Clone RISCV tools 32 on bti branch
git clone https://github.com/ibndias/riscv-tools-32/tree/bti
cd riscv-tools-32
git submodule update --init --recursive
export RISCV=/opt/riscv
./build-rv32g.sh
#Now running 'spike pk' on terminal should work, example output
#$ spike pk
#bbl loader
#tell me what ELF to load!
#Clone LLVM
git clone https://github.com/ibndias/riscv-llvm/tree/bti
cd riscv-llvm
mkdir build
cd build
#LLVM make
cmake -G Ninja -DCMAKE_BUILD_TYPE="Release" -DLLVM_ENABLE_PROJECTS=clang -DBUILD_SHARED_LIBS=True -DLLVM_USE_SPLIT_DWARF=True -DCMAKE_INSTALL_PREFIX="/opt/riscv/" -DLLVM_OPTIMIZED_TABLEGEN=True -DLLVM_BUILD_TESTS=False -DLLVM_PARALLEL_LINK_JOBS=False -DDEFAULT_SYSROOT="/opt/riscv/riscv32-unknown-elf" -DLLVM_DEFAULT_TARGET_TRIPLE="riscv32-unknown-elf" -DLLVM_TARGETS_TO_BUILD="RISCV" ../llvm
#or if failed, try disable the shared libs
cmake -G Ninja -DCMAKE_BUILD_TYPE="Release" -DLLVM_ENABLE_PROJECTS=clang -DBUILD_SHARED_LIBS=False -DLLVM_USE_SPLIT_DWARF=True -DCMAKE_INSTALL_PREFIX="/opt/riscv/" -DLLVM_OPTIMIZED_TABLEGEN=True -DLLVM_BUILD_TESTS=False -DLLVM_PARALLEL_LINK_JOBS=False -DDEFAULT_SYSROOT="/opt/riscv/riscv32-unknown-elf" -DLLVM_DEFAULT_TARGET_TRIPLE="riscv32-unknown-elf" -DLLVM_TARGETS_TO_BUILD="RISCV" ../llvm
cmake --build . --target install
#To compile c file using this llvm
clang hi.c -o hi --target=riscv32 -march=rv32g
#BEEBS
git clone https://github.com/ibndias/riscv-benchmark/tree/bti
source init_submodules.sh
#Now open the env.sh, update the environment variables to match with our current RISCV toolchain configuration.
#export RISCV=/opt/riscv
#export PK=$RISCV/riscv32-unknown-elf/bin/pk
#export PATH=$RISCV/bin:$PATH
#export RISCV_XLEN=32
#Running Benchmark
source run-benchmark.sh
# This will generate the logs and instruction histogram for each test in results.
# In order to collect and summarize all of the test result for visualization
python instruction-histogram.py
# Then we can calculate the code size using
source calculate-code-size.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment