diff --git a/broadway.mk b/broadway.mk index b6100d4..e677878 100644 --- a/broadway.mk +++ b/broadway.mk @@ -2,9 +2,9 @@ ifeq ($(strip $(WIIDEV)),) $(error "Set WIIDEV in your environment.") endif -PREFIX = $(WIIDEV)/bin/powerpc-elf- +PREFIX = $(WIIDEV)/bin/powerpc-none-elf- -CFLAGS = -mcpu=750 -mpaired -m32 -mhard-float -mno-eabi -mno-sdata +CFLAGS = -mcpu=750 -m32 -mhard-float -mno-eabi -mno-sdata CFLAGS += -ffreestanding -ffunction-sections CFLAGS += -Wall -Wextra -Os -pipe ASFLAGS = diff --git a/buildtoolchain/binutils-2.21.1.patch b/buildtoolchain/binutils-2.21.1.patch deleted file mode 100644 index 165d044..0000000 --- a/buildtoolchain/binutils-2.21.1.patch +++ /dev/null @@ -1,39 +0,0 @@ -diff -burN '--exclude=.git' binutils-2.21.1/ld/emultempl/spuelf.em binutils-2.21.1-PS3/ld/emultempl/spuelf.em ---- binutils-2.21.1/ld/emultempl/spuelf.em 2009-08-10 04:50:56.000000000 -0300 -+++ binutils-2.21.1-PS3/ld/emultempl/spuelf.em 2011-05-25 10:15:21.220050910 -0300 -@@ -396,7 +396,11 @@ - argv[my_argc++] = "-T"; - argv[my_argc++] = auto_overlay_file; - argv[my_argc] = 0; -+#if defined(_WIN32) -+ execvp (argv[0], (const char* const*) argv); -+#else - execvp (argv[0], (char *const *) argv); -+#endif - perror (argv[0]); - _exit (127); - } -diff -burN '--exclude=.git' binutils-2.21.1/binutils/Makefile.am binutils-2.21.1-PS3/binutils/Makefile.am ---- binutils-2.21.1/binutils/Makefile.am 2011-07-06 13:27:16.000000000 +0200 -+++ binutils-2.21.1-PS3/binutils/Makefile.am 2011-07-06 13:28:06.000000000 +0200 -@@ -283,7 +283,7 @@ - $(CC_FOR_BUILD) -o $@ $(AM_CPPFLAGS) $(AM_CFLAGS) $(CFLAGS_FOR_BUILD) $(LDFLAGS_FOR_BUILD) $(srcdir)/bin2c.c - - embedspu: embedspu.sh Makefile -- sed "/^program_transform_name=/cprogram_transform_name=$(program_transform_name)" < $< > $@ -+ awk '/^program_transform_name=/ {print "program_transform_name=\"$(program_transform_name)\""; next} {print}' < $< > $@ - chmod a+x $@ - - # We need these for parallel make. -diff -burN '--exclude=.git' binutils-2.21.1/binutils/Makefile.in binutils-2.21.1-PS3/binutils/Makefile.in ---- binutils-2.21.1/binutils/Makefile.in 2011-07-06 13:27:23.000000000 +0200 -+++ binutils-2.21.1-PS3/binutils/Makefile.in 2011-07-06 13:28:35.000000000 +0200 -@@ -1295,7 +1295,7 @@ - $(CC_FOR_BUILD) -o $@ $(AM_CPPFLAGS) $(AM_CFLAGS) $(CFLAGS_FOR_BUILD) $(LDFLAGS_FOR_BUILD) $(srcdir)/bin2c.c - - embedspu: embedspu.sh Makefile -- sed "/^program_transform_name=/cprogram_transform_name=$(program_transform_name)" < $< > $@ -+ awk '/^program_transform_name=/ {print "program_transform_name=\"$(program_transform_name)\""; next} {print}' < $< > $@ - chmod a+x $@ - - # We need these for parallel make. diff --git a/buildtoolchain/buildit.sh b/buildtoolchain/buildit.sh index 0bf292f..e279844 100755 --- a/buildtoolchain/buildit.sh +++ b/buildtoolchain/buildit.sh @@ -3,34 +3,38 @@ # Copyright (C) 2007 Segher Boessenkool # Copyright (C) 2009 Hector Martin "marcan" # Copyright (C) 2009 Andre Heider "dhewg" +# Copyright (C) 2022 Shiz # Released under the terms of the GNU GPL, version 2 SCRIPTDIR=`dirname $PWD/$0` -BINUTILS_VER=2.21.1 +BINUTILS_VER=2.39 BINUTILS_DIR="binutils-$BINUTILS_VER" -BINUTILS_TARBALL="binutils-${BINUTILS_VER}a.tar.bz2" +BINUTILS_TARBALL="binutils-${BINUTILS_VER}.tar.bz2" BINUTILS_URI="http://ftp.gnu.org/gnu/binutils/$BINUTILS_TARBALL" -GMP_VER=4.3.2 +GMP_VER=6.2.1 GMP_DIR="gmp-$GMP_VER" GMP_TARBALL="gmp-$GMP_VER.tar.bz2" GMP_URI="http://ftp.gnu.org/gnu/gmp/$GMP_TARBALL" -MPFR_VER=2.4.2 +MPFR_VER=4.1.0 MPFR_DIR="mpfr-$MPFR_VER" MPFR_TARBALL="mpfr-$MPFR_VER.tar.bz2" MPFR_URI="http://ftp.gnu.org/gnu/mpfr/$MPFR_TARBALL" -GCC_VER=4.4.7 +MPC_VER=1.2.1 +MPC_DIR=mpc-$MPC_VER +MPC_TARBALL="mpc-$MPC_VER.tar.gz" +MPC_URI="http://ftp.gnu.org/gnu/mpc/$MPC_TARBALL" + +GCC_VER=11.3.0 GCC_DIR="gcc-$GCC_VER" -GCC_TARBALL="gcc-core-$GCC_VER.tar.bz2" +GCC_TARBALL="gcc-$GCC_VER.tar.gz" GCC_URI="http://ftp.gnu.org/gnu/gcc/gcc-$GCC_VER/$GCC_TARBALL" -BUILDTYPE=$1 - -ARM_TARGET=armeb-eabi -POWERPC_TARGET=powerpc-elf +ARM_TARGET=armeb-none-eabi +POWERPC_TARGET=powerpc-none-elf if [ -z $MAKEOPTS ]; then MAKEOPTS=-j3 @@ -46,63 +50,90 @@ case `uname -s` in MAKE=make esac -export PATH=$WIIDEV/bin:$PATH - die() { - echo $@ + echo "$@" exit 1 } -cleansrc() { - [ -e $WIIDEV/$BINUTILS_DIR ] && rm -rf $WIIDEV/$BINUTILS_DIR - [ -e $WIIDEV/$GCC_DIR ] && rm -rf $WIIDEV/$GCC_DIR -} - -cleanbuild() { - [ -e $WIIDEV/build_binutils ] && rm -rf $WIIDEV/build_binutils - [ -e $WIIDEV/build_gcc ] && rm -rf $WIIDEV/build_gcc -} - download() { DL=1 - if [ -f "$WIIDEV/$2" ]; then - echo "Testing $2..." - tar tf "$WIIDEV/$2" >/dev/null 2>&1 && DL=0 + if [ -f "$1" ]; then + echo "Testing $1..." + tar tf "$1" >/dev/null 2>&1 && DL=0 fi if [ $DL -eq 1 ]; then echo "Downloading $2..." - wget "$1" -c -O "$WIIDEV/$2" || die "Could not download $2" + if command -v wget >/dev/null 2>&1; then + wget "$2" -c -O "$1" || die "Could not download $2 using wget" + elif command -v curl >/dev/null 2>&1; then + curl -o "$1" -fL "$2" || die "Could not download $2 using cURL" + else + die "Could not download $2 (no wget or cURL)" + fi fi } extract() { - echo "Extracting $1..." - tar xf "$WIIDEV/$1" -C "$2" || die "Error unpacking $1" + echo "Extracting $2..." + tar xf "$2" -C "$1" || die "Could not unpack $2" } -makedirs() { - mkdir -p $WIIDEV/build_binutils || die "Error making binutils build directory $WIIDEV/build_binutils" - mkdir -p $WIIDEV/build_gcc || die "Error making gcc build directory $WIIDEV/build_gcc" + +cleansrc() { + [ -e "$1/src/$BINUTILS_DIR" ] && rm -rf "$1/src/$BINUTILS_DIR" + [ -e "$1/src/$GCC_DIR" ] && rm -rf "$1/src/$GCC_DIR" +} + +cleanbuild() { + [ -e "$(printf "%s\n" "$1/var/build/$BINUTILS_DIR"-* | head -n 1)" ] && rm -rf "$1/var/build/$BINUTILS_DIR"-* + [ -e "$(printf "%s\n" "$1/var/build/$GCC_DIR"-* | head -n 1)" ] && rm -rf "$1/var/build/$GCC_DIR"-* +} + +prepsrc() { + mkdir -p "$1/var/cache" || die "Could not create cache directory $1/var/cache" + + download "$1/var/cache/$BINUTILS_TARBALL" "$BINUTILS_URI" + download "$1/var/cache/$GMP_TARBALL" "$GMP_URI" + download "$1/var/cache/$MPFR_TARBALL" "$MPFR_URI" + download "$1/var/cache/$MPC_TARBALL" "$MPC_URI" + download "$1/var/cache/$GCC_TARBALL" "$GCC_URI" + + cleansrc "$1" + + mkdir -p "$1/src" || die "Could not create source directory $1/src" + + extract "$1/src" "$1/var/cache/$BINUTILS_TARBALL" + extract "$1/src" "$1/var/cache/$GCC_TARBALL" + patch -d "$1"/src/gcc-* -u -p1 -i $SCRIPTDIR/gcc-11.3.0.patch || die "Error applying GCC patch" + + extract "$1/src/$GCC_DIR" "$1/var/cache/$GMP_TARBALL" + mv "$1/src/$GCC_DIR/$GMP_DIR" "$1/src/$GCC_DIR/gmp" || die "Error renaming $GMP_DIR -> gmp" + extract "$1/src/$GCC_DIR" "$1/var/cache/$MPFR_TARBALL" + mv "$1/src/$GCC_DIR/$MPFR_DIR" "$1/src/$GCC_DIR/mpfr" || die "Error renaming $MPFR_DIR -> mpfr" + extract "$1/src/$GCC_DIR" "$1/var/cache/$MPC_TARBALL" + mv "$1/src/$GCC_DIR/$MPC_DIR" "$1/src/$GCC_DIR/mpc" || die "Error renaming $MPC_DIR -> mpc" } buildbinutils() { - TARGET=$1 ( - cd $WIIDEV/build_binutils && \ - $WIIDEV/$BINUTILS_DIR/configure --target=$TARGET \ + export PATH="$1/bin:$PATH" + mkdir -p "$1/var/build/$BINUTILS_DIR-$2" + cd "$1/var/build/$BINUTILS_DIR-$2" && \ + "$1/src/$BINUTILS_DIR/configure" --target="$2" \ --prefix=$WIIDEV --disable-nls --disable-werror \ --disable-multilib && \ nice $MAKE $MAKEOPTS && \ $MAKE install - ) || die "Error building binutils for target $TARGET" + ) || die "Error building binutils for target $2" } buildgcc() { - TARGET=$1 ( - cd $WIIDEV/build_gcc && \ - $WIIDEV/$GCC_DIR/configure --target=$TARGET --enable-targets=all \ + export PATH="$1/bin:$PATH" + mkdir -p "$1/var/build/$GCC_DIR-$2" + cd "$1/var/build/$GCC_DIR-$2" && \ + "$1/src/$GCC_DIR/configure" --target="$2" --enable-targets=all \ --prefix=$WIIDEV --disable-multilib \ --enable-languages=c --without-headers \ --disable-nls --disable-threads --disable-shared \ @@ -112,35 +143,44 @@ buildgcc() { CFLAGS='-fgnu89-inline -g -O2' && \ nice $MAKE $MAKEOPTS && \ $MAKE install - ) || die "Error building gcc for target $TARGET" + ) || die "Error building gcc for target $2" } -buildarm() { - cleanbuild - makedirs - echo "******* Building ARM binutils" - buildbinutils $ARM_TARGET - echo "******* Building ARM GCC" - buildgcc $ARM_TARGET - echo "******* ARM toolchain built and installed" -} -buildpowerpc() { - cleanbuild - makedirs - echo "******* Building PowerPC binutils" - buildbinutils $POWERPC_TARGET - echo "******* Building PowerPC GCC" - buildgcc $POWERPC_TARGET - echo "******* PowerPC toolchain built and installed" +build() { + cleanbuild "$1" + echo "******* Building $2 binutils" + [ -f "$1/bin/$2-ld" ] || buildbinutils "$1" "$2" + echo "******* Building $2 GCC" + [ -f "$1/bin/$2-gcc" ] || buildgcc "$1" "$2" + echo "******* $2 toolchain built and installed" } if [ -z "$WIIDEV" ]; then die "Please set WIIDEV in your environment." fi +BUILDTYPE="$1" case $BUILDTYPE in - arm|powerpc|both|clean) ;; + arm) + prepsrc "$WIIDEV" + build "$WIIDEV" $ARM_TARGET + ;; + powerpc) + prepsrc "$WIIDEV" + build "$WIIDEV" $POWERPC_TARGET + ;; + both) + prepsrc "$WIIDEV" + build "$WIIDEV" $ARM_TARGET + build "$WIIDEV" $POWERPC_TARGET + cleanbuild "$WIIDEV" + cleansrc "$WIIDEV" + ;; + clean) + cleanbuild "$WIIDEV" + cleansrc "$WIIDEV" + ;; "") die "Please specify build type (arm/powerpc/both/clean)" ;; @@ -148,34 +188,3 @@ case $BUILDTYPE in die "Unknown build type $BUILDTYPE" ;; esac - -if [ "$BUILDTYPE" = "clean" ]; then - cleanbuild - cleansrc - exit 0 -fi - -download "$BINUTILS_URI" "$BINUTILS_TARBALL" -download "$GMP_URI" "$GMP_TARBALL" -download "$MPFR_URI" "$MPFR_TARBALL" -download "$GCC_URI" "$GCC_TARBALL" - -cleansrc - -extract "$BINUTILS_TARBALL" "$WIIDEV" -extract "$GCC_TARBALL" "$WIIDEV" -extract "$GMP_TARBALL" "$WIIDEV/$GCC_DIR" -extract "$MPFR_TARBALL" "$WIIDEV/$GCC_DIR" - -# http://sourceware.org/bugzilla/show_bug.cgi?id=12964 -patch -d $WIIDEV/$BINUTILS_DIR -u -p1 -i $SCRIPTDIR/binutils-2.21.1.patch || die "Error applying binutils patch" - -# in-tree gmp and mpfr -mv "$WIIDEV/$GCC_DIR/$GMP_DIR" "$WIIDEV/$GCC_DIR/gmp" || die "Error renaming $GMP_DIR -> gmp" -mv "$WIIDEV/$GCC_DIR/$MPFR_DIR" "$WIIDEV/$GCC_DIR/mpfr" || die "Error renaming $MPFR_DIR -> mpfr" - -case $BUILDTYPE in - arm) buildarm ;; - powerpc) buildpowerpc ;; - both) buildarm ; buildpowerpc; cleanbuild; cleansrc ;; -esac diff --git a/buildtoolchain/gcc-11.3.0.patch b/buildtoolchain/gcc-11.3.0.patch new file mode 100644 index 0000000..763be06 --- /dev/null +++ b/buildtoolchain/gcc-11.3.0.patch @@ -0,0 +1,20 @@ +https://github.com/richfelker/musl-cross-make/issues/116#issuecomment-823612404 + +diff -Nru gcc-11.3.0/gcc/config/host-darwin.c gcc-11.3.0-patched/gcc/config/host-darwin.c +--- gcc-11.3.0/gcc/config/host-darwin.c 2022-04-21 09:58:52 ++++ gcc-11.3.0-patched/gcc/config/host-darwin.c 2024-01-03 00:34:29 +@@ -22,6 +22,8 @@ + #include "coretypes.h" + #include "diagnostic-core.h" + #include "config/host-darwin.h" ++#include "hosthooks.h" ++#include "hosthooks-def.h" + + /* Yes, this is really supposed to work. */ + /* This allows for a pagesize of 16384, which we have on Darwin20, but should +@@ -79,3 +81,5 @@ + + return ret; + } ++ ++const struct host_hooks host_hooks = HOST_HOOKS_INITIALIZER; diff --git a/common.mk b/common.mk index cd9fdcb..d9d79ac 100644 --- a/common.mk +++ b/common.mk @@ -7,7 +7,7 @@ OBJCOPY = $(PREFIX)objcopy RANLIB = $(PREFIX)ranlib STRIP = $(PREFIX)strip -BIN2S = $(DEVKITPPC)/bin/bin2s +BIN2S = $(DEVKITPRO)/tools/bin/bin2s ifeq ($(NOMAPFILE),) LDFLAGS += -Wl,-Map,$(TARGET).map diff --git a/starlet.mk b/starlet.mk index 9f83704..16a5599 100644 --- a/starlet.mk +++ b/starlet.mk @@ -2,7 +2,7 @@ ifeq ($(strip $(WIIDEV)),) $(error "Set WIIDEV in your environment.") endif -PREFIX = $(WIIDEV)/bin/armeb-eabi- +PREFIX = $(WIIDEV)/bin/armeb-none-eabi- CFLAGS = -mbig-endian -mcpu=arm926ej-s CFLAGS += -fomit-frame-pointer -ffunction-sections