diff --git a/README.md b/README.md index 550ac3d..cc08dd0 100644 --- a/README.md +++ b/README.md @@ -148,6 +148,9 @@ make install-strip ## Compiling GCC (Part 2) +> [!WARNING] +> Building gcc with c++ does not work + Build now the c++ support with ```bash @@ -167,7 +170,7 @@ mkdir build cd build cmake .. make -make install/local +make install/local # do not want to install it to the system but to ``` ## Adding our custom compiler to GPRBuild @@ -184,10 +187,3 @@ Sources used: --- Copyright (c) 2026 Ada Orbit. All Rights Reserved. - - -## TODO - -Idea space thingy - -Maybe try installing gcc the way Lephexnior does and just sneakally add --language=ada and no adalib to build everything? diff --git a/build-gcc.sh b/build-gcc.sh index 01fe553..0e19a2a 100755 --- a/build-gcc.sh +++ b/build-gcc.sh @@ -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 diff --git a/libfxcg b/libfxcg deleted file mode 160000 index daa76d9..0000000 --- a/libfxcg +++ /dev/null @@ -1 +0,0 @@ -Subproject commit daa76d9e37758ab5b9b0f614b7e0aa6acfbe2e18 diff --git a/stardust_build.sh b/stardust_build.sh new file mode 100755 index 0000000..063de1c --- /dev/null +++ b/stardust_build.sh @@ -0,0 +1,48 @@ +export PATH="$HOME/prefix/tools/bin:$HOME/prefix/stage1/bin:$HOME/prefix-$(uname -m)/bin:$PATH" +wget https://ftpmirror.gnu.org/gnu/binutils/binutils-2.46.0.tar.gz https://ftpmirror.gnu.org/gnu/gcc/gcc-15.2.0/gcc-15.2.0.tar.gz +git clone https://github.com/Jonimoose/libfxcg --depth=1 +tar xf gcc-15.2.0.tar.gz +tar xf binutils-2.46.0.tar.gz + +cd binutils-2.46.0 +mkdir stage{0,1} +cd stage0 +../configure --prefix=$HOME/prefix-$(uname -m) --sysconfdir=/etc --enable-ld=default --enable-plugins --enable-shared --disable-werror --enable-64-bit-bfd +make -j$(nproc) tooldir=$HOME/prefix-$(uname -m) +make -j$(nproc) check +make -j install-strip tooldir=$HOME/prefix-$(uname -m) + +cd ../../gcc-15.2.0 +mkdir stage{0,1,2} +sed -ie '/m64=/s/lib64/lib/' gcc/config/i386/t-linux64 +cd stage0 +../configure --prefix=$HOME/prefix-$(uname -m) LD=ld --enable-languages-c,c++,ada --enable-default-pie --enable-default-ssp --enable-host-pie --disable-multilib --disable-fixincludes +make -j$(nproc) +sed -i ../gcc/testsuite/gcc.dg/plugin/plugin.exp -e '/cpython/d' +make -j install-strip + +cd ../../binutils-2.46.0/stage1 +../configure --prefix=$HOME/prefix/stage1 --with-sysroot=$HOME/prefix --target=sh3eb-elf --disable-nls --disable-gprofng --disable-werror +make -j$(nproc) +make -j install-strip +../configure --prefix=$HOME/prefix/tools --with-sysroot=$HOME/prefix --target=sh3eb-elf --disable-nls --disable-gprofng --disable-werror +make -j$(nproc) +make -j install-strip + +cd ../../gcc-15.2.0/stage1 +../configure --target=sh3eb-elf --prefix=$HOME/prefix/stage1 --with-sysroot=$HOME/prefix --with-newlib --without-headers --enable-default-pie --enable-default-ssp --disable-nls --enable-languages=c,c++,ada --disable-libstdcxx --disable-libada --disable-libssp +make -j$(nproc) +make -j install-strip + +cd ../../libfxcg +make -j$(nproc) libc/libc.a +install -Dt $HOME/prefix/lib libc/libc.a libfxcg/libfxcg.a +mkdir -p $HOME/prefix/include +cp -r include/* $HOME/prefix/include/ + +cd ../gcc-15.2.0/stage2 +../configure --target=sh3eb-elf --prefix=$HOME/prefix/tools --with-sysroot=$HOME/prefix --enable-default-pie --disable-nls --enable-languages=c,c++,ada --with-native-system-header-dir=/include --disable-gcov --disable-libada --disable-libstdcxx --disable-libssp +make -j$(nproc) +make -j install-strip +rm -rf $HOME/prefix/stage1 + diff --git a/test/program.adb b/test/program.adb deleted file mode 100644 index fb3d8e6..0000000 --- a/test/program.adb +++ /dev/null @@ -1,6 +0,0 @@ -package body Program is - procedure Main is - begin - null; - end Main; -end Program; diff --git a/test/program.ads b/test/program.ads deleted file mode 100644 index 621326f..0000000 --- a/test/program.ads +++ /dev/null @@ -1,4 +0,0 @@ -package Program is - procedure Main; - pragma Export (C, Main, "main"); -end Program;