From a09004698377e72eb9794c03131ca2c62b1c6d75 Mon Sep 17 00:00:00 2001 From: Kartatz <105828205+Kartatz@users.noreply.github.com> Date: Fri, 10 May 2024 00:16:06 -0300 Subject: [PATCH] Update to GCC 14.1.0 --- .github/workflows/build.yml | 6 +- build.sh | 65 ++++++++++++++----- ...g-local-symbol-warning-on-bfd-linker.patch | 41 ++++++++++++ 3 files changed, 94 insertions(+), 18 deletions(-) create mode 100644 patches/0001-Disable-annoying-local-symbol-warning-on-bfd-linker.patch diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d92b700..289939f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -17,7 +17,7 @@ jobs: id: check-cache uses: actions/cache@main with: - key: gcc-14.1.0 + key: gcc-14.1.0-1 lookup-only: true path: | /tmp/x86_64-linux-gnu.tar.xz @@ -45,7 +45,7 @@ jobs: if: ${{ steps.check-cache.outputs.cache-hit != 'true' }} uses: actions/cache@main with: - key: gcc-14.1.0 + key: gcc-14.1.0-1 path: | /tmp/x86_64-linux-gnu.tar.xz /tmp/x86_64-linux-gnu.tar.xz.sha256 @@ -79,7 +79,7 @@ jobs: - name: Restore from cache uses: actions/cache@main with: - key: gcc-14.1.0 + key: gcc-14.1.0-1 fail-on-cache-miss: true path: | /tmp/x86_64-linux-gnu.tar.xz diff --git a/build.sh b/build.sh index da62082..f9009c6 100644 --- a/build.sh +++ b/build.sh @@ -18,13 +18,55 @@ 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.xz' -declare -r gcc_directory='/tmp/gcc-14.1.0' +declare gcc_directory='' + +function setup_gcc_source() { + + local gcc_version='' + local gcc_url='' + local gcc_tarball='' + local tgt="${1}" + + declare -r tgt + + if [ "${tgt}" = 'hpcsh' ] || [ "${tgt}" = 'hpcsh' ]; then + gcc_version='12' + gcc_directory='/tmp/gcc-12.3.0' + gcc_url='https://ftp.gnu.org/gnu/gcc/gcc-12.3.0/gcc-12.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" + + if ! [ -f "${gcc_directory}/patched" ]; then + if (( gcc_version >= 14 )); then + patch --directory="${gcc_directory}" --strip='1' --input="${workdir}/patches/0001-Disable-libfunc-support-for-hppa-unknown-netbsd.patch" + patch --directory="${gcc_directory}" --strip='1' --input="${workdir}/patches/0001-Fix-issues-with-fenv.patch" + fi + + touch "${gcc_directory}/patched" + fi + +} declare -r optflags='-Os' declare -r linkflags='-Wl,-s' -declare -r max_jobs="$(($(nproc) * 16))" +declare -r max_jobs="$(($(nproc) * 17))" declare build_type="${1}" @@ -68,18 +110,9 @@ if ! [ -f "${binutils_tarball}" ]; then tar --directory="$(dirname "${binutils_directory}")" --extract --file="${binutils_tarball}" patch --directory="${binutils_directory}" --strip='1' --input="${workdir}/patches/0001-Revert-gold-Use-char16_t-char32_t-instead-of-uint16_.patch" + patch --directory="${binutils_directory}" --strip='1' --input="${workdir}/patches/0001-Disable-annoying-local-symbol-warning-on-bfd-linker.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-Disable-libfunc-support-for-hppa-unknown-netbsd.patch" - patch --directory="${gcc_directory}" --strip='1' --input="${workdir}/patches/0001-Fix-issues-with-fenv.patch" -fi - -[ -d "${gcc_directory}/build" ] || mkdir "${gcc_directory}/build" - declare -r toolchain_directory="/tmp/dakini" [ -d "${gmp_directory}/build" ] || mkdir "${gmp_directory}/build" @@ -142,11 +175,11 @@ sed -i 's/#include /#include \n#include /g' "${tool declare -r targets=( 'hpcsh' 'vax' + 'emips' 'evbppc' 'hppa' 'amd64' 'i386' - 'emips' 'alpha' 'sparc' 'sparc64' @@ -239,6 +272,8 @@ for target in "${targets[@]}"; do fi done <<< "$(find "${toolchain_directory}/${triplet}/include" "${toolchain_directory}/${triplet}/lib")" + setup_gcc_source "${target}" + cd "${gcc_directory}/build" rm --force --recursive ./* @@ -342,7 +377,7 @@ for target in "${targets[@]}"; do for name in $(ls '!m3'); do if ! [ -f "./${name}" ]; then - ln --symbolic "./\!m3/${name}" "./${name}" + ln --symbolic './!m3/'"${name}" "./${name}" fi done fi diff --git a/patches/0001-Disable-annoying-local-symbol-warning-on-bfd-linker.patch b/patches/0001-Disable-annoying-local-symbol-warning-on-bfd-linker.patch new file mode 100644 index 0000000..15ba113 --- /dev/null +++ b/patches/0001-Disable-annoying-local-symbol-warning-on-bfd-linker.patch @@ -0,0 +1,41 @@ +From d3254de82bf38235c4e714440a93454f91cd71d8 Mon Sep 17 00:00:00 2001 +From: Kartatz <105828205+Kartatz@users.noreply.github.com> +Date: Fri, 10 May 2024 05:12:10 +0200 +Subject: [PATCH] Disable annoying 'local symbol' warning on bfd linker + +--- + bfd/elflink.c | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +diff --git a/bfd/elflink.c b/bfd/elflink.c +index c2494b3..6910577 100644 +--- a/bfd/elflink.c ++++ b/bfd/elflink.c +@@ -4820,7 +4820,7 @@ elf_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info) + bool common; + bool discarded; + unsigned int old_alignment; +- unsigned int shindex; ++ /* unsigned int shindex; */ + bfd *old_bfd; + bool matched; + +@@ -4852,13 +4852,14 @@ elf_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info) + /* If we aren't prepared to handle locals within the globals + then we'll likely segfault on a NULL symbol hash if the + symbol is ever referenced in relocations. */ ++ /* + shindex = elf_elfheader (abfd)->e_shstrndx; + name = bfd_elf_string_from_elf_section (abfd, shindex, hdr->sh_name); + _bfd_error_handler (_("%pB: %s local symbol at index %lu" + " (>= sh_info of %lu)"), + abfd, name, (long) (isym - isymbuf + extsymoff), + (long) extsymoff); +- ++ */ + /* Dynamic object relocations are not processed by ld, so + ld won't run into the problem mentioned above. */ + if (dynamic) +-- +2.36.6 +