Working toolchain

This commit is contained in:
Drew Galbraith 2023-06-14 12:09:23 -07:00
parent bd5cd5a011
commit a9db73e443
4 changed files with 6005 additions and 35 deletions

View file

@ -18,11 +18,6 @@ BINUTILS_NAME="binutils-$BINUTILS_VERSION"
BINUTILS_PKG="${BINUTILS_NAME}.tar.xz"
BINUTILS_BASE_URL="https://ftp.gnu.org/gnu/binutils"
NEWLIB_VERSION="4.1.0"
NEWLIB_NAME="newlib-$NEWLIB_VERSION"
NEWLIB_PKG="${NEWLIB_NAME}.tar.gz"
NEWLIB_BASE_URL="ftp://sourceware.org/pub/newlib"
GCC_VERSION="13.1.0"
GCC_NAME="gcc-$GCC_VERSION"
GCC_PKG="${GCC_NAME}.tar.xz"
@ -38,18 +33,14 @@ pushd "$TOOLCHAIN/srcs"
if [ ! -d "$BINUTILS_NAME" ]; then
tar -xJf ${BINUTILS_PKG}
pushd $BINUTILS_NAME
# Set up a baseline to make it easier to create patches in the future.
git init
git add .
git commit -m "base"
patch -p1 <$TOOLCHAIN/patches/binutils/00-first.patch
popd
fi
if [ ! -e $NEWLIB_PKG ]; then
curl -LO $NEWLIB_BASE_URL/$NEWLIB_PKG
fi
if [ ! -d $NEWLIB_NAME ]; then
tar -xzf $NEWLIB_PKG
fi
if [ ! -e "$GCC_PKG" ]; then
curl -LO "$GCC_BASE_URL/$GCC_NAME/$GCC_PKG"
fi
@ -57,7 +48,12 @@ pushd "$TOOLCHAIN/srcs"
if [ ! -d "$GCC_NAME" ]; then
tar -xJf $GCC_PKG
pushd $GCC_NAME
# Set up a baseline to make it easier to create patches in the future.
git init
git add .
git commit -m "base"
patch -p1 <$TOOLCHAIN/patches/gcc/00-first.patch
patch -p1 <$TOOLCHAIN/patches/gcc/01-libstdc++.patch
popd
fi
@ -66,8 +62,7 @@ popd
mkdir -p "$TOOLCHAIN/build"
pushd "$TOOLCHAIN/build"
# rm -rf binutils
if [ ! -d binutils ]; then
rm -rf binutils
mkdir -p binutils
pushd binutils
# skip building documentation
@ -82,20 +77,6 @@ pushd "$TOOLCHAIN/build"
make MAKEINFO=true -j 8
make install MAKEINFO=true -j 8
popd
fi
# rm -rf newlib
if [ ! -d newlib ]; then
mkdir -p newlib
pushd newlib
$TOOLCHAIN/srcs/$NEWLIB_NAME/configure \
--prefix=$SYSROOT/usr \
--target=x86_64-elf \
--with-sysroot=$SYSROOT
make -j 8
make -j 8 install
popd
fi
rm -rf gcc
mkdir -p gcc
@ -104,6 +85,7 @@ pushd "$TOOLCHAIN/build"
--prefix=$PREFIX \
--target=$TARGET \
--with-sysroot=$SYSROOT \
--with-newlib \
--disable-nls \
--enable-languages=c,c++
@ -112,8 +94,6 @@ pushd "$TOOLCHAIN/build"
make -j 8 all-target-libgcc
make -j 8 install-gcc install-target-libgcc
popd
popd