forked from riscv-collab/riscv-gnu-toolchain
-
Notifications
You must be signed in to change notification settings - Fork 0
Build script for riscv toolchain
Fan Yang edited this page May 24, 2023
·
1 revision
** Build script for Linux
PREFIX=$HOME/riscv32-gnu-toolchain
TARGET=riscv32-unknown-elf
if [ -d $PREFIX ]; then
rm -rf $PREFIX
fi
make clean
./configure --disable-shared --enable-static --with-abi=ilp32 --with-arch=rv32imac --enable-multilib --with-multilib-generator="rv32imac-ilp32--;rv32imafc-ilp32--;rv32imafc-ilp32f--;rv32imafdc-ilp32--;rv32imafdc-ilp32f--;rv32imafdc-ilp32d--" --prefix=${PREFIX} 'CFLAGS_FOR_TARGET=-Os -mstrict-align -mcmodel=medlow ' 'CXXFLAGS_FOR_TARGET=-Os -mstrict-align -mcmodel=medlow ' --target=$TARGET LDFLAGS="-static" --with-isa-spec=2.2
make -j8
# Strip
strip -s `find $PREFIX/ -type f -executable`
** Cross-compiling script for Windows on Ubuntu
BUILD_HOST=x86_64-w64-mingw32
PREFIX=${HOME}/riscv32-gnu-toolchain-win
TARGET=riscv32-unknown-elf
export PATH=$PATH:${HOME}/riscv32-gnu-toolchain:${HOME}/riscv32-gnu-toolchain/bin
MULTILIB_LIST="rv32imac-ilp32--;rv32imafc-ilp32--;rv32imafc-ilp32f--;rv32imafdc-ilp32--;rv32imafdc-ilp32f--;rv32imafdc-ilp32d--"
cd gcc
./contrib/download_prerequisites
cd ..
./configure --with-abi=ilp32 --with-arch=rv32imac --enable-multilib -with-multilib-generator=${MULTILIB_LIST} --with-host=${BUILD_HOST} --prefix=${PREFIX} --without-system-zlib 'CFLAGS_FOR_TARGET=-Os -mcmodel=medlow ' 'CXXFLAGS_FOR_TARGET=-Os -mcmodel=medlow ' --target=${TARGET} LDFLAGS="-static" --with-isa-spec=2.2
make clean
make -j8
cd build-gdb-newlib
make distclean
../riscv-gdb/configure --target=$TARGET --host=${BUILD_HOST} --prefix=${PREFIX} --disable-werror --with-expat=yes --enable-gdb --disable-gas --disable-binutils --disable-ld --disable-gold --disable-gprof --disable-shared --with-static-standard-libraries --disable-source-highlight LDFLAGS="-static"
make -j8
make install
cd $PREFIX
# Strip unused symbols in toolchain binaries
for i in `find . -name *.dll`; do x86_64-w64-mingw32-strip -s $i ; done
for i in `find . -name *.exe`; do x86_64-w64-mingw32-strip -s $i ; done
cd ..