Skip to content

Instantly share code, notes, and snippets.

@carlosedp
Last active November 19, 2020 15:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save carlosedp/560d743dc183eda125deffa42629367b to your computer and use it in GitHub Desktop.
Save carlosedp/560d743dc183eda125deffa42629367b to your computer and use it in GitHub Desktop.
PS3 SPU Toolchain Build
#!/usr/bin/env bash
set -euxo pipefail
CURRPATH=$(pwd)
DEST_PATH=${HOME}/x-toolchain/spu
BINUTILS_VER=2.33.1
GCC_VER=9.3.0
NEWLIB_VER=2.5.0.20170519
GDB_VER=9.2
# Download
if [ ! -f binutils-${BINUTILS_VER}.tar.gz ]; then
wget https://ftp.gnu.org/gnu/binutils/binutils-${BINUTILS_VER}.tar.gz
tar vxf binutils-${BINUTILS_VER}.tar.gz
fi
if [ ! -f gcc-${GCC_VER}.tar.gz ]; then
wget https://ftp.gnu.org/gnu/gcc/gcc-${GCC_VER}/gcc-${GCC_VER}.tar.gz
tar vxf gcc-${GCC_VER}.tar.gz
fi
if [ ! -f newlib-${NEWLIB_VER}.tar.gz ]; then
wget ftp://sourceware.org/pub/newlib/newlib-${NEWLIB_VER}.tar.gz
tar vxf newlib-${NEWLIB_VER}.tar.gz
fi
if [ ! -f gdb-${GDB_VER}.tar.gz ]; then
wget https://ftp.gnu.org/gnu/gdb/gdb-${GDB_VER}.tar.gz
tar vxf gdb-${GDB_VER}.tar.gz
fi
rm -rf build
mkdir -p build/{binutils,gdb,gcc,newlib}
# Binutils
pushd build/binutils
../../binutils-${BINUTILS_VER}/configure \
--target=spu \
--prefix=${DEST_PATH} \
--program-prefix=spu- \
--disable-werror
make -j`nproc`
make install-strip
install -c ../../binutils-${BINUTILS_VER}/binutils/embedspu.sh ${DEST_PATH}/bin/embedspu
patch -p1 < ../../embedspu.patch ${DEST_PATH}/bin/embedspu
popd
# GCC
pushd gcc-${GCC_VER}
./contrib/download_prerequisites
popd
export PATH=${DEST_PATH}/bin:$PATH
# Build GCC
pushd build/gcc
../../gcc-${GCC_VER}/configure \
--prefix=${DEST_PATH} \
--target=spu \
--program-prefix=spu- \
--disable-libssp \
--disable-checking \
--disable-werror \
--disable-libquadmath \
--enable-languages="c" \
--enable-obsolete \
--without-headers
make all-gcc -j`nproc`
make install-gcc
popd
# Newlib
pushd build/newlib
../../newlib-${NEWLIB_VER}/configure \
--prefix=${DEST_PATH} \
--target=spu \
--program-prefix=spu- \
--disable-werror
make -j`nproc`
make install
popd
# GCC Step 2
pushd build/gcc
../../gcc-${GCC_VER}/configure \
--prefix=${DEST_PATH} \
--target=spu \
--program-prefix=spu- \
--disable-libssp \
--disable-checking \
--disable-werror \
--disable-shared \
--disable-libquadmath \
--disable-libgloss \
--enable-threads \
--enable-languages=c,c++ \
--enable-obsolete \
--with-newlib
make -j`nproc`
make install-strip
popd
# GDB
pushd build/gdb
../../gdb-${GDB_VER}/configure \
--prefix=${DEST_PATH} \
--target=spu \
--program-prefix=spu- \
--disable-nls \
--disable-sim \
--disable-werror
make -j`nproc`
make install-strip
popd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment