diff --git a/build.sh b/build.sh index d5ce080..08a31ce 100644 --- a/build.sh +++ b/build.sh @@ -2,29 +2,29 @@ set -eu -declare -r revision="$(git rev-parse --short HEAD)" +declare -r workdir="${PWD}" -declare -r toolchain_tarball="${PWD}/netbsd-cross.tar.xz" +declare -r revision="$(git rev-parse --short HEAD)" declare -r gmp_tarball='/tmp/gmp.tar.xz' -declare -r gmp_directory='/tmp/gmp-6.2.1' +declare -r gmp_directory='/tmp/gmp-6.3.0' declare -r mpfr_tarball='/tmp/mpfr.tar.xz' -declare -r mpfr_directory='/tmp/mpfr-4.2.0' +declare -r mpfr_directory='/tmp/mpfr-4.2.1' declare -r mpc_tarball='/tmp/mpc.tar.gz' declare -r mpc_directory='/tmp/mpc-1.3.1' declare -r binutils_tarball='/tmp/binutils.tar.xz' -declare -r binutils_directory='/tmp/binutils-2.41' +declare -r binutils_directory='/tmp/binutils-2.42' declare -r gcc_tarball='/tmp/gcc.tar.xz' -declare -r gcc_directory='/tmp/gcc-12.3.0' +declare -r gcc_directory='/tmp/gcc-14.1.0' declare -r optflags='-Os' declare -r linkflags='-Wl,-s' -declare -r max_jobs="$(($(nproc) * 8))" +declare -r max_jobs="$(($(nproc) * 16))" declare build_type="${1}" @@ -49,12 +49,12 @@ if ! (( is_native )); then fi if ! [ -f "${gmp_tarball}" ]; then - wget --no-verbose 'https://ftp.gnu.org/gnu/gmp/gmp-6.2.1.tar.xz' --output-document="${gmp_tarball}" + wget --no-verbose 'https://ftp.gnu.org/gnu/gmp/gmp-6.3.0.tar.xz' --output-document="${gmp_tarball}" tar --directory="$(dirname "${gmp_directory}")" --extract --file="${gmp_tarball}" fi if ! [ -f "${mpfr_tarball}" ]; then - wget --no-verbose 'https://ftp.gnu.org/gnu/mpfr/mpfr-4.2.0.tar.xz' --output-document="${mpfr_tarball}" + wget --no-verbose 'https://ftp.gnu.org/gnu/mpfr/mpfr-4.2.1.tar.xz' --output-document="${mpfr_tarball}" tar --directory="$(dirname "${mpfr_directory}")" --extract --file="${mpfr_tarball}" fi @@ -64,13 +64,15 @@ if ! [ -f "${mpc_tarball}" ]; then fi if ! [ -f "${binutils_tarball}" ]; then - wget --no-verbose 'https://ftp.gnu.org/gnu/binutils/binutils-2.41.tar.xz' --output-document="${binutils_tarball}" + wget --no-verbose 'https://ftp.gnu.org/gnu/binutils/binutils-2.42.tar.xz' --output-document="${binutils_tarball}" tar --directory="$(dirname "${binutils_directory}")" --extract --file="${binutils_tarball}" fi if ! [ -f "${gcc_tarball}" ]; then - wget --no-verbose 'https://ftp.gnu.org/gnu/gcc/gcc-12.3.0/gcc-12.3.0.tar.xz' --output-document="${gcc_tarball}" + 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-Disable-libfunc-support-for-hppa-unknown-netbsd.patch" fi [ -d "${gcc_directory}/build" ] || mkdir "${gcc_directory}/build" @@ -148,7 +150,7 @@ declare -r targets=( ) for target in "${targets[@]}"; do - declare url="https://cdn.netbsd.org/pub/NetBSD/NetBSD-8.0/${target}/binary/sets" + declare url="https://web.archive.org/web/0if_/https://archive.netbsd.org/pub/NetBSD-archive/NetBSD-8.0/${target}/binary/sets" case "${target}" in amd64) @@ -179,8 +181,27 @@ for target in "${targets[@]}"; do declare base_output="/tmp/$(basename "${base_url}")" declare comp_output="/tmp/$(basename "${comp_url}")" - wget --no-verbose "${base_url}" --output-document="${base_output}" - wget --no-verbose "${comp_url}" --output-document="${comp_output}" + curl \ + --url "${base_url}" \ + --retry '30' \ + --retry-all-errors \ + --retry-delay '0' \ + --retry-max-time '0' \ + --location \ + --verbose \ + --silent \ + --output "${base_output}" + + curl \ + --url "${comp_url}" \ + --retry '30' \ + --retry-all-errors \ + --retry-delay '0' \ + --retry-max-time '0' \ + --location \ + --verbose \ + --silent \ + --output "${comp_output}" cd "${binutils_directory}/build" rm --force --recursive ./* @@ -206,6 +227,15 @@ for target in "${targets[@]}"; do tar --directory="${toolchain_directory}/${triplet}" --extract --file="${base_output}" './lib' tar --directory="${toolchain_directory}/${triplet}" --strip=2 --extract --file="${comp_output}" './usr/lib' './usr/include' + # Update permissions + while read name; do + if [ -f "${name}" ]; then + chmod 644 "${name}" + elif [ -d "${name}" ]; then + chmod 755 "${name}" + fi + done <<< "$(find "${toolchain_directory}/${triplet}/include" "${toolchain_directory}/${triplet}/lib")" + cd "${gcc_directory}/build" rm --force --recursive ./* @@ -226,7 +256,7 @@ for target in "${targets[@]}"; do if [ "${target}" == 'hpcsh' ]; then CXXFLAGS_FOR_TARGET+=' -include sh3/fenv.h' fi - + ../configure \ --target="${triplet}" \ --prefix="${toolchain_directory}" \ @@ -236,7 +266,7 @@ for target in "${targets[@]}"; do --with-mpfr="${toolchain_directory}" \ --with-bugurl='https://github.com/AmanoTeam/Dakini/issues' \ --with-gcc-major-version-only \ - --with-pkgversion="Dakini v0.4-${revision}" \ + --with-pkgversion="Dakini v0.5-${revision}" \ --with-sysroot="${toolchain_directory}/${triplet}" \ --with-native-system-header-dir='/include' \ --enable-__cxa_atexit \ @@ -287,4 +317,26 @@ for target in "${targets[@]}"; do patchelf --add-rpath '$ORIGIN/../../../../lib' "${toolchain_directory}/libexec/gcc/${triplet}/"*"/cc1" patchelf --add-rpath '$ORIGIN/../../../../lib' "${toolchain_directory}/libexec/gcc/${triplet}/"*"/cc1plus" patchelf --add-rpath '$ORIGIN/../../../../lib' "${toolchain_directory}/libexec/gcc/${triplet}/"*"/lto1" + + # Strip debug symbols from shared libraries + while read name; do + name="$(realpath "${name}")" + + if [[ "$(file --brief --mime-type "${name}")" != 'application/x-sharedlib' ]]; then + continue + fi + + "${toolchain_directory}/bin/${triplet}-strip" "${name}" + done <<< "$(find "${toolchain_directory}/${triplet}/lib" -wholename '*.so')" + + # Fix some libraries not being found during linkage + if [ "${target}" == 'hpcsh' ]; then + cd "${toolchain_directory}/${triplet}/lib" + + for name in $(ls '!m3'); do + if ! [ -f "./${name}" ]; then + ln --symbolic "./\!m3/${name}" "./${name}" + fi + done + fi done diff --git a/patches/0001-Disable-libfunc-support-for-hppa-unknown-netbsd.patch b/patches/0001-Disable-libfunc-support-for-hppa-unknown-netbsd.patch new file mode 100644 index 0000000..6eed898 --- /dev/null +++ b/patches/0001-Disable-libfunc-support-for-hppa-unknown-netbsd.patch @@ -0,0 +1,28 @@ +From 615edd6d30f1e43107b639d13661be148e197471 Mon Sep 17 00:00:00 2001 +From: Kartatz <105828205+Kartatz@users.noreply.github.com> +Date: Tue, 7 May 2024 23:43:09 +0200 +Subject: [PATCH] Disable libfunc support for hppa-unknown-netbsd + +For some reason, it does not work for that target. The following error is printed when attempting to link a specific object file of the libgcc: + +/tmp/ccigQ6Ux.s: Assembler messages: +/tmp/ccigQ6Ux.s:80: Error: Unknown opcode: `stws|stw %r23,-16(%sp)' +/tmp/ccigQ6Ux.s:83: Error: Invalid operands + +I do not know if this is a GCC bug or it just happens that our target does not support this feature. +--- + libgcc/config/pa/t-netbsd | 1 - + 1 file changed, 1 deletion(-) + +diff --git a/libgcc/config/pa/t-netbsd b/libgcc/config/pa/t-netbsd +index 13943940a..8b99068ce 100644 +--- a/libgcc/config/pa/t-netbsd ++++ b/libgcc/config/pa/t-netbsd +@@ -7,4 +7,3 @@ LIB1ASMFUNCS = _divI _divU _remI _remU _div_const _mulI _dyncall + HOST_LIBGCC2_CFLAGS += -DELF=1 -DLINUX=1 + + LIB2ADD = $(srcdir)/config/pa/fptr.c +-LIB2ADD_ST = $(srcdir)/config/pa/sync-libfuncs.c +-- +2.36.6 +