Skip to content

Commit

Permalink
[wip] Update to GCC 14.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Kartatz committed May 11, 2024
1 parent bbf6042 commit e969646
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 13 deletions.
57 changes: 44 additions & 13 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,51 @@ 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='/tmp/gcc.tar.xz'
local tgt="${1}"

declare -r tgt
declare -r gcc_tarball

if [ "${tgt}" = 'hpcsh' ] || [ "${tgt}" = 'hpcsh' ];
gcc_version='12'
gcc_directory="/tmp/gcc-${gcc_version}"
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-${gcc_version}"
gcc_url='https://ftp.gnu.org/gnu/gcc/gcc-14.1.0/gcc-14.1.0.tar.xz'
fi

declare -r gcc_version
declare -r gcc_url

if ! [ -f "${gcc_tarball}" ]; then
wget --no-verbose "${gcc_url}" --output-document="${gcc_tarball}"
tar --directory="$(dirname "${gcc_directory}")" --extract --file="${gcc_tarball}"
fi

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}"

Expand Down Expand Up @@ -71,15 +109,6 @@ if ! [ -f "${binutils_tarball}" ]; then
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"
patch --directory="${gcc_directory}" --strip='1' --input="${workdir}/patches/0001-Revert___atomic_test_and_set_Fall_back_to_library,_not_non-atomic_code.patch"
fi

[ -d "${gcc_directory}/build" ] || mkdir "${gcc_directory}/build"

declare -r toolchain_directory="/tmp/dakini"
Expand Down Expand Up @@ -142,7 +171,7 @@ sed -i 's/#include <stdint.h>/#include <stdint.h>\n#include <stdio.h>/g' "${tool
[ -d "${binutils_directory}/build" ] || mkdir "${binutils_directory}/build"

declare -r targets=(
'hpcsh'
# 'hpcsh'
# 'vax'
# 'evbppc'
# 'hppa'
Expand Down Expand Up @@ -241,6 +270,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 ./*
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
From d3254de82bf38235c4e714440a93454f91cd71d8 Mon Sep 17 00:00:00 2001
From: Kartatz <[email protected]>
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

0 comments on commit e969646

Please sign in to comment.