Last active
November 16, 2020 04:26
-
-
Save ibndias/41ffbf9004b27105064be24823f9d659 to your computer and use it in GitHub Desktop.
bti-build-instruction.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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