diff --git a/build.sh b/build.sh index 2783145..3cf838b 100644 --- a/build.sh +++ b/build.sh @@ -20,11 +20,44 @@ declare -r mpc_directory='/tmp/mpc-1.3.1' declare -r binutils_tarball='/tmp/binutils.tar.xz' declare -r binutils_directory='/tmp/binutils-2.42' -declare -r gcc_tarball='/tmp/gcc.tar.gz' -declare -r gcc_directory='/tmp/gcc-14.1.0' +declare gcc_directory='' declare -r sysroot_tarball='/tmp/sysroot.tar.xz' +function setup_gcc_source() { + + local gcc_version='' + local gcc_url='' + local gcc_tarball='' + local tgt="${1}" + + declare -r tgt + + if [ "${tgt}" = 'powerpc64le-unknown-linux-musl' ]; then + gcc_version='13' + gcc_directory='/tmp/gcc-13.3.0' + gcc_url='https://ftp.gnu.org/gnu/gcc/gcc-13.3.0/gcc-13.3.0.tar.xz' + else + gcc_version='14' + gcc_directory='/tmp/gcc-14.1.0' + gcc_url='https://ftp.gnu.org/gnu/gcc/gcc-14.1.0/gcc-14.1.0.tar.xz' + fi + + gcc_tarball="/tmp/gcc-${gcc_version}.tar.xz" + + declare -r gcc_version + declare -r gcc_url + declare -r gcc_tarball + + if ! [ -f "${gcc_tarball}" ]; then + wget --no-verbose "${gcc_url}" --output-document="${gcc_tarball}" + tar --directory="$(dirname "${gcc_directory}")" --extract --file="${gcc_tarball}" + fi + + [ -d "${gcc_directory}/build" ] || mkdir "${gcc_directory}/build" + +} + declare -r optflags='-Os' declare -r linkflags='-Wl,-s' @@ -74,13 +107,6 @@ if ! [ -f "${binutils_tarball}" ]; then patch --directory="${binutils_directory}" --strip='1' --input="${workdir}/patches/0001-Revert-gold-Use-char16_t-char32_t-instead-of-uint16_.patch" fi -if ! [ -f "${gcc_tarball}" ]; then - wget --no-verbose 'https://ftp.gnu.org/gnu/gcc/gcc-14.1.0/gcc-14.1.0.tar.xz' --output-document="${gcc_tarball}" - tar --directory="$(dirname "${gcc_directory}")" --extract --file="${gcc_tarball}" - - # patch --directory="${gcc_directory}" --strip='1' --input="${workdir}/patches/0001-x.patch" -fi - # sed --in-place 's/LDBL_MANT_DIG == 106/defined(__powerpc64__)/g' "${gcc_directory}/libgcc/dfp-bit.h" [ -d "${gmp_directory}/build" ] || mkdir "${gmp_directory}/build" @@ -189,6 +215,8 @@ for target in "${targets[@]}"; do make all --jobs="${max_jobs}" make install + setup_gcc_source "${triplet}" + [ -d "${gcc_directory}/build" ] || mkdir "${gcc_directory}/build" cd "${gcc_directory}/build"