This commit is contained in:
Ada Orbit 2026-04-15 19:23:44 +02:00
parent 948d39427f
commit cad5c37dab
6 changed files with 88 additions and 32 deletions

View file

@ -1,4 +1,7 @@
#!/usr/bin/env bash
# Copyright (c) 2026 Ada Orbit. All Rights Reserved.
# simple small script to build gcc with superh and ada support
set -e
@ -8,30 +11,31 @@ ADACASIO_GCC_VERSION="15.2.0"
ADACASIO_BINUTILS_URL="https://ftp.gnu.org/gnu/binutils/binutils-$ADACASIO_BINUTILS_VERSION.tar.gz"
ADACASIO_GCC_URL="https://ftp.gnu.org/gnu/gcc/gcc-15.2.0/gcc-$ADACASIO_GCC_VERSION.tar.gz"
ADACASIO_PREFIX="$(pwd)/sysroot"
ADACASIO_TARGET="sh-elf"
ADACASIO_TARGET="sh3eb-elf"
# Install dependencies
# For now I have only tested Fedora 43. YMMV
sudo -i
dnf install mg
dnf upgrade
dnf install @c-development gnat gprbuild gmp-devel mpfr-devel libmpc-devel git
#sudo -i
#dnf install mg
#dnf upgrade
#dnf install @c-development gnat gprbuild gmp-devel mpfr-devel libmpc-devel git
# prepare configure and build enviornment
wget -O binutils.tar.gz $ADACASIO_BINUTILS_URL
wget -O gcc.tar.gz $ADACASIO_GCC_URL
#wget -O binutils.tar.gz $ADACASIO_BINUTILS_URL
#wget -O gcc.tar.gz $ADACASIO_GCC_URL
tar -xf binutils.tar.gz
tar -xf gcc.tar.gz
# Got the command list from https://git.planet-casio.com/Lephenixnoir/sh-elf-binutils Method 3
# Step 2. configure and build GCC and binutils
mkdir build-binutils build-gcc $ADACASIO_PREFIX
cd build-binutils
../binutils-*/configure \
--prefix="$ADACASIO_PREFIX" \
--target="sh3eb-elf" \
--with-multilib-list="m3,m4-nofpu" \
--program-prefix="$ADACASIO_TARGET-" \
--program-prefix="" \
--enable-libssp \
--enable-lto
@ -42,14 +46,14 @@ make install-strip
# https://git.planet-casio.com/Lephenixnoir/sh-elf-gcc
cd ../build-gcc/
../gcc-$VERSION/configure \
--prefix="$SYSROOT" \
../gcc-*/configure \
--prefix="$ADACASIO_PREFIX" \
--target="sh3eb-elf" \
--with-multilib-list="m3,m4-nofpu" \
--enable-languages="c,c++,ada" \
--disable-libada \
--without-headers \
--program-prefix="sh-elf-" \
--program-prefix="$ADACASIO_TARGET-" \
--enable-libssp \
--enable-lto \
--enable-clocale="generic" \
@ -61,5 +65,24 @@ cd ../build-gcc/
make -j$(nproc) all-gcc all-target-libgcc
make install-strip-gcc install-strip-target-libgcc
# TODO:
# install openlibm and fxlibc for C++ support later on
# TODO: C++ support is currenlty not working on gcc15 with superh target
# It does work with gcc14 but ada does not :/
# I'll leave the c++ flags here for future use
cd ..
export PATH="$PATH:$ADACASIO_PREFIX/bin"
ADACASIO_GCCPREFIX="$($ADACASIO_TARGET-gcc --print-file-name=.)"
# WARNING: this library uses "sh3eb-elf-gcc"
# TODO: replace sh3eb-elf-gcc with $ADACASIO_TARGET-gcc
git clone https://github.com/Jonimoose/libfxcg.git
cd libfxcg
make
cp lib/* ../sysroot/lib/
cp -r include/* ../sysroot/lib/gcc/sh3eb-elf/15.2.0/include/
# Going back to gcc-build to build gnattools using the libc
cd ../build-gcc
make -C gcc cross-gnattools
make install-strip