From 47d7c0e4082055523684c2ce34a21acf909ce3aa Mon Sep 17 00:00:00 2001 From: Kartatz <105828205+Kartatz@users.noreply.github.com> Date: Mon, 12 Aug 2024 23:12:39 -0300 Subject: [PATCH] Update to GCC 14.2.0 --- .github/workflows/build.yml | 38 +++++++-- arm-bookeen-linux-gnueabi.sh | 3 +- build.sh | 34 ++++---- ...e-about-turning-Wimplicit-function-d.patch | 62 +++++++++++++++ ...char16_t-char32_t-instead-of-uint16_.patch | 77 +++++++++++++++++++ submodules/obggcc | 2 +- 6 files changed, 193 insertions(+), 23 deletions(-) create mode 100644 patches/0001-Revert-GCC-change-about-turning-Wimplicit-function-d.patch create mode 100644 patches/0001-Revert-gold-Use-char16_t-char32_t-instead-of-uint16_.patch diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 254135c..bf97da2 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -13,15 +13,27 @@ jobs: - uses: actions/checkout@main with: submodules: true + - name: Check for cache + id: check-cache + uses: actions/cache@main + with: + key: gcc-14.2.0 + lookup-only: true + path: | + /tmp/x86_64-linux-gnu.tar.xz + /tmp/x86_64-linux-gnu.tar.xz.sha256 - name: Build Ai + if: ${{ steps.check-cache.outputs.cache-hit != 'true' }} run: | bash './build.sh' 'native' - name: Generate tarball + if: ${{ steps.check-cache.outputs.cache-hit != 'true' }} run: | declare tarball_filename='/tmp/x86_64-linux-gnu.tar.xz' tar --directory='/tmp' --create --file=- 'ai' | xz --threads='0' --compress -9 > "${tarball_filename}" sha256sum "${tarball_filename}" | sed 's|/tmp/||' > "${tarball_filename}.sha256" - name: Upload artifact + if: ${{ steps.check-cache.outputs.cache-hit != 'true' }} uses: actions/upload-artifact@main with: name: native-toolchain @@ -29,6 +41,14 @@ jobs: path: | /tmp/x86_64-linux-gnu.tar.xz /tmp/x86_64-linux-gnu.tar.xz.sha256 + - name: Cache artifact + if: ${{ steps.check-cache.outputs.cache-hit != 'true' }} + uses: actions/cache@main + with: + key: gcc-14.2.0 + path: | + /tmp/x86_64-linux-gnu.tar.xz + /tmp/x86_64-linux-gnu.tar.xz.sha256 cross-build: name: 'Cross build' @@ -38,6 +58,7 @@ jobs: strategy: matrix: target: [ + 'ia64-unknown-linux-gnu', 'alpha-unknown-linux-gnu', 'x86_64-unknown-linux-gnu', 'i386-unknown-linux-gnu', @@ -51,19 +72,24 @@ jobs: 's390-unknown-linux-gnu', 's390x-unknown-linux-gnu', 'sparc-unknown-linux-gnu', - 'powerpc64le-unknown-linux-gnu' + 'powerpc64le-unknown-linux-gnu', + 'mips64el-unknown-linux-gnuabi64' ] steps: - uses: actions/checkout@main with: submodules: true - - name: Download artifact - uses: actions/download-artifact@main + - name: Restore from cache + uses: actions/cache@main with: - name: native-toolchain + key: gcc-14.2.0 + fail-on-cache-miss: true + path: | + /tmp/x86_64-linux-gnu.tar.xz + /tmp/x86_64-linux-gnu.tar.xz.sha256 - name: Setup toolchain run: | - tar --directory='/tmp' --extract --file='./x86_64-linux-gnu.tar.xz' + tar --directory='/tmp' --extract --file='/tmp/x86_64-linux-gnu.tar.xz' mv '/tmp/ai' '/tmp/ai-toolchain' - name: Build Ai with OBGGCC run: | @@ -79,7 +105,7 @@ jobs: - name: Upload artifact uses: actions/upload-artifact@main with: - name: cross-toolchain + name: ${{ matrix.target }} if-no-files-found: error path: | /tmp/${{ matrix.target }}.tar.xz diff --git a/arm-bookeen-linux-gnueabi.sh b/arm-bookeen-linux-gnueabi.sh index 9e80956..dc53cdb 100644 --- a/arm-bookeen-linux-gnueabi.sh +++ b/arm-bookeen-linux-gnueabi.sh @@ -4,4 +4,5 @@ declare extra_configure_flags='--with-cpu=cortex-a8 --with-fpu=neon --with-float declare triplet='arm-bookeen-linux-gnueabi' -declare sysroot='https://web.archive.org/web/0if_/https://github.com/koreader/koxtoolchain/releases/latest/download/bookeen.zip' +# https://web.archive.org/web/0if_/https://github.com/koreader/koxtoolchain/releases/latest/download/bookeen.zip +declare sysroot='https://github.com/koreader/koxtoolchain/releases/latest/download/bookeen.zip' diff --git a/build.sh b/build.sh index 09b5cda..4a82ba3 100644 --- a/build.sh +++ b/build.sh @@ -2,31 +2,29 @@ set -eu -declare -r current_source_directory="${PWD}" +declare -r workdir="${PWD}" declare -r revision="$(git rev-parse --short HEAD)" -declare -r toolchain_directory='/tmp/ai' - 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.43' -declare -r gcc_tarball='/tmp/gcc.tar.gz' -declare -r gcc_directory='/tmp/gcc-13.2.0' +declare -r gcc_tarball='/tmp/gcc.tar.xz' +declare -r gcc_directory='/tmp/gcc-14.2.0' declare -r optflags='-Os' declare -r linkflags='-Wl,-s' -declare -r max_jobs="$(($(nproc) * 8))" +declare -r max_jobs="$(($(nproc) * 17))" declare build_type="${1}" @@ -51,30 +49,36 @@ if ! (( is_native )); then fi if ! [ -f "${gmp_tarball}" ]; then - curl --connect-timeout '10' --retry '15' --retry-all-errors --fail --silent --url 'https://mirrors.kernel.org/gnu/gmp/gmp-6.2.1.tar.xz' --output "${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 - curl --connect-timeout '10' --retry '15' --retry-all-errors --fail --silent --url 'https://mirrors.kernel.org/gnu/mpfr/mpfr-4.2.0.tar.xz' --output "${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 if ! [ -f "${mpc_tarball}" ]; then - curl --connect-timeout '10' --retry '15' --retry-all-errors --fail --silent --url 'https://mirrors.kernel.org/gnu/mpc/mpc-1.3.1.tar.gz' --output "${mpc_tarball}" + wget --no-verbose 'https://ftp.gnu.org/gnu/mpc/mpc-1.3.1.tar.gz' --output-document="${mpc_tarball}" tar --directory="$(dirname "${mpc_directory}")" --extract --file="${mpc_tarball}" fi if ! [ -f "${binutils_tarball}" ]; then - curl --connect-timeout '10' --retry '15' --retry-all-errors --fail --silent --url 'https://mirrors.kernel.org/gnu/binutils/binutils-2.41.tar.xz' --output "${binutils_tarball}" + wget --no-verbose 'https://ftp.gnu.org/gnu/binutils/binutils-2.43.tar.xz' --output-document="${binutils_tarball}" 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" fi if ! [ -f "${gcc_tarball}" ]; then - curl --connect-timeout '10' --retry '15' --retry-all-errors --fail --silent --url 'https://mirrors.kernel.org/gnu/gcc/gcc-13.2.0/gcc-13.2.0.tar.xz' --output "${gcc_tarball}" + wget --no-verbose 'https://ftp.gnu.org/gnu/gcc/gcc-14.2.0/gcc-14.2.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-Revert-GCC-change-about-turning-Wimplicit-function-d.patch" fi +declare -r toolchain_directory="/tmp/ai" + [ -d "${gmp_directory}/build" ] || mkdir "${gmp_directory}/build" cd "${gmp_directory}/build" @@ -206,7 +210,7 @@ for target in "${targets[@]}"; do --with-mpc="${toolchain_directory}" \ --with-mpfr="${toolchain_directory}" \ --with-bugurl='https://github.com/AmanoTeam/Ai/issues' \ - --with-pkgversion="Ai v0.1-${revision}" \ + --with-pkgversion="Ai v0.2-${revision}" \ --with-sysroot="${toolchain_directory}/${triplet}" \ --with-native-system-header-dir='/include' \ --enable-__cxa_atexit \ diff --git a/patches/0001-Revert-GCC-change-about-turning-Wimplicit-function-d.patch b/patches/0001-Revert-GCC-change-about-turning-Wimplicit-function-d.patch new file mode 100644 index 0000000..6fa6e7e --- /dev/null +++ b/patches/0001-Revert-GCC-change-about-turning-Wimplicit-function-d.patch @@ -0,0 +1,62 @@ +From 9088a8ce453a6b66d51b87d096bf9cf15042794d Mon Sep 17 00:00:00 2001 +From: Kartatz <105828205+Kartatz@users.noreply.github.com> +Date: Sun, 11 Aug 2024 22:06:07 +0200 +Subject: [PATCH] Revert GCC change about turning -Wimplicit-function-declaration into errors + +Unfortunately, the new behavior breaks the compilation of some GCC dependencies and even GCC itself when building for very old targets. + +This is due to these platforms lacking support for some required standard library functions and APIs: Until GCC 13, the compiler always fell back to a built-in alternative in case one of those functions was missing (see https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html). The compiler, however, used to just issue an "implicit function declaration" warning for the usage of those builtins. Since this warning is now treated as an error, this simply made the compilation fail. +--- + gcc/c/c-decl.cc | 10 +++++----- + 1 file changed, 5 insertions(+), 5 deletions(-) + +diff --git a/gcc/c/c-decl.cc b/gcc/c/c-decl.cc +index 0e52f2176..dde2b207c 100644 +--- a/gcc/c/c-decl.cc ++++ b/gcc/c/c-decl.cc +@@ -3566,7 +3566,7 @@ pushdecl (tree x) + or NULL_TREE. */ + + static void +-implicit_decl_permerror (location_t loc, tree id, tree olddecl) ++implicit_decl_warning (location_t loc, tree id, tree olddecl) + { + if (!warn_implicit_function_declaration) + return; +@@ -3583,13 +3583,13 @@ implicit_decl_permerror (location_t loc, tree id, tree olddecl) + { + gcc_rich_location richloc (loc); + richloc.add_fixit_replace (suggestion); +- warned = permerror_opt (&richloc, OPT_Wimplicit_function_declaration, ++ warned = pedwarn (&richloc, OPT_Wimplicit_function_declaration, + "implicit declaration of function %qE;" + " did you mean %qs?", + id, suggestion); + } + else +- warned = permerror_opt (loc, OPT_Wimplicit_function_declaration, ++ warned = pedwarn (loc, OPT_Wimplicit_function_declaration, + "implicit declaration of function %qE", id); + } + else if (const char *suggestion = hint.suggestion ()) +@@ -3880,7 +3880,7 @@ implicitly_declare (location_t loc, tree functionid) + then recycle the old declaration but with the new type. */ + if (!C_DECL_IMPLICIT (decl)) + { +- implicit_decl_permerror (loc, functionid, decl); ++ implicit_decl_warning (loc, functionid, decl); + C_DECL_IMPLICIT (decl) = 1; + } + if (fndecl_built_in_p (decl)) +@@ -3933,7 +3933,7 @@ implicitly_declare (location_t loc, tree functionid) + DECL_EXTERNAL (decl) = 1; + TREE_PUBLIC (decl) = 1; + C_DECL_IMPLICIT (decl) = 1; +- implicit_decl_permerror (loc, functionid, 0); ++ implicit_decl_warning (loc, functionid, 0); + asmspec_tree = maybe_apply_renaming_pragma (decl, /*asmname=*/NULL); + if (asmspec_tree) + set_user_assembler_name (decl, TREE_STRING_POINTER (asmspec_tree)); +-- +2.36.6 + diff --git a/patches/0001-Revert-gold-Use-char16_t-char32_t-instead-of-uint16_.patch b/patches/0001-Revert-gold-Use-char16_t-char32_t-instead-of-uint16_.patch new file mode 100644 index 0000000..9a850ab --- /dev/null +++ b/patches/0001-Revert-gold-Use-char16_t-char32_t-instead-of-uint16_.patch @@ -0,0 +1,77 @@ +From c5fcba3bc2b47e1061e066deac04efbbdb53362d Mon Sep 17 00:00:00 2001 +From: Kartatz <105828205+Kartatz@users.noreply.github.com> +Date: Wed, 8 May 2024 07:04:54 +0200 +Subject: [PATCH] Revert "gold: Use char16_t, char32_t instead of uint16_t, + uint32_t as character types" + +This reverts commit 5e9091dab8858b25210a91d22fbbbfdee9c969ad. +--- +diff --git a/gold/merge.cc b/gold/merge.cc +index ca15149c767..55de3013a1b 100644 +--- a/gold/merge.cc ++++ b/gold/merge.cc +@@ -665,10 +665,10 @@ template + class Output_merge_string; + + template +-class Output_merge_string; ++class Output_merge_string; + + template +-class Output_merge_string; ++class Output_merge_string; + + #if defined(HAVE_TARGET_32_LITTLE) || defined(HAVE_TARGET_32_BIG) + template +diff --git a/gold/output.cc b/gold/output.cc +index ead67f20363..3375d322506 100644 +--- a/gold/output.cc ++++ b/gold/output.cc +@@ -29,7 +29,6 @@ + #include + #include + #include +-#include + + #ifdef HAVE_SYS_MMAN_H + #include +@@ -2707,10 +2706,10 @@ Output_section::add_merge_input_section(Relobj* object, unsigned int shndx, + pomb = new Output_merge_string(addralign); + break; + case 2: +- pomb = new Output_merge_string(addralign); ++ pomb = new Output_merge_string(addralign); + break; + case 4: +- pomb = new Output_merge_string(addralign); ++ pomb = new Output_merge_string(addralign); + break; + default: + return false; +diff --git a/gold/stringpool.cc b/gold/stringpool.cc +index d8f38cfabc1..2e4a746d1a8 100644 +--- a/gold/stringpool.cc ++++ b/gold/stringpool.cc +@@ -25,7 +25,6 @@ + #include + #include + #include +-#include + + #include "output.h" + #include "parameters.h" +@@ -528,9 +527,9 @@ template + class Stringpool_template; + + template +-class Stringpool_template; ++class Stringpool_template; + + template +-class Stringpool_template; ++class Stringpool_template; + + } // End namespace gold. +-- +2.36.6 + diff --git a/submodules/obggcc b/submodules/obggcc index 9499bd3..335914a 160000 --- a/submodules/obggcc +++ b/submodules/obggcc @@ -1 +1 @@ -Subproject commit 9499bd3eeb8a005cbea5c22c1c839f79e2f34e25 +Subproject commit 335914a684c154b99bf894cce96e7786c9733e39