Skip to content

Commit

Permalink
Update to GCC 14.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Kartatz committed May 31, 2024
1 parent 7f68de8 commit c68b232
Show file tree
Hide file tree
Showing 16 changed files with 205 additions and 160 deletions.
38 changes: 32 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,42 @@ jobs:
- uses: actions/checkout@main
with:
submodules: true
- name: Check for cache
id: check-cache
uses: actions/cache@main
with:
key: gcc-14.1.0-1
lookup-only: true
path: |
/tmp/x86_64-linux-gnu.tar.xz
/tmp/x86_64-linux-gnu.tar.xz.sha256
- name: Build Raiden
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=- 'raiden' | 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
if-no-files-found: error
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.1.0-1
path: |
/tmp/x86_64-linux-gnu.tar.xz
/tmp/x86_64-linux-gnu.tar.xz.sha256
cross-build:
name: 'Cross build'
Expand All @@ -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',
Expand All @@ -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.1.0-1
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/raiden' '/tmp/raiden-toolchain'
- name: Build Raiden with OBGGCC
run: |
Expand All @@ -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
Expand Down
9 changes: 0 additions & 9 deletions aarch64-unknown-linux-musl.sh
Original file line number Diff line number Diff line change
@@ -1,18 +1,9 @@
#!/bin/bash

declare packages=(
'https://web.archive.org/web/0if_/https://alpha.de.repo.voidlinux.org/current/aarch64/musl-1.1.24_17.aarch64-musl.xbps'
'https://web.archive.org/web/0if_/https://alpha.de.repo.voidlinux.org/current/aarch64/musl-devel-1.1.24_17.aarch64-musl.xbps'
'https://web.archive.org/web/0if_/https://alpha.de.repo.voidlinux.org/current/aarch64/kernel-libc-headers-5.10.4_1.aarch64.xbps'
'https://web.archive.org/web/0if_/https://alpha.de.repo.voidlinux.org/current/aarch64/libexecinfo-devel-1.1_3.aarch64-musl.xbps'
)

declare extra_configure_flags=''

declare triplet='aarch64-unknown-linux-musl'

declare ld='ld-musl-aarch64.so.1'

declare sysroot='https://web.archive.org/web/0if_/https://repo-default.voidlinux.org/live/current/void-aarch64-musl-ROOTFS-20230628.tar.xz'

declare os='void'
9 changes: 0 additions & 9 deletions arm-unknown-linux-musleabihf.sh
Original file line number Diff line number Diff line change
@@ -1,18 +1,9 @@
#!/bin/bash

declare packages=(
'https://web.archive.org/web/0if_/https://alpha.de.repo.voidlinux.org/current/musl/musl-1.1.24_17.armv6l-musl.xbps'
'https://web.archive.org/web/0if_/https://alpha.de.repo.voidlinux.org/current/musl/musl-devel-1.1.24_17.armv6l-musl.xbps'
'https://web.archive.org/web/0if_/https://alpha.de.repo.voidlinux.org/current/kernel-libc-headers-5.10.4_1.armv6l.xbps'
'https://web.archive.org/web/0if_/https://alpha.de.repo.voidlinux.org/current/musl/libexecinfo-devel-1.1_3.armv6l-musl.xbps'
)

declare extra_configure_flags='--with-arch=armv6 --with-fpu=vfp --with-float=hard'

declare triplet='arm-unknown-linux-musleabihf'

declare ld='ld-musl-armhf.so.1'

declare sysroot='https://web.archive.org/web/0if_/https://repo-default.voidlinux.org/live/current/void-armv6l-musl-ROOTFS-20230628.tar.xz'

declare os='void'
9 changes: 0 additions & 9 deletions armv7l-unknown-linux-musleabihf.sh
Original file line number Diff line number Diff line change
@@ -1,18 +1,9 @@
#!/bin/bash

declare packages=(
'https://web.archive.org/web/0if_/https://alpha.de.repo.voidlinux.org/current/musl/musl-1.1.24_17.armv7l-musl.xbps'
'https://web.archive.org/web/0if_/https://alpha.de.repo.voidlinux.org/current/musl/musl-devel-1.1.24_17.armv7l-musl.xbps'
'https://web.archive.org/web/0if_/https://alpha.de.repo.voidlinux.org/current/kernel-libc-headers-5.10.4_1.armv7l.xbps'
'https://web.archive.org/web/0if_/https://alpha.de.repo.voidlinux.org/current/musl/libexecinfo-devel-1.1_3.armv7l-musl.xbps'
)

declare extra_configure_flags='--with-arch=armv7-a --with-fpu=vfpv3 --with-float=hard'

declare triplet='armv7l-unknown-linux-musleabihf'

declare ld='ld-musl-armhf.so.1'

declare sysroot='https://web.archive.org/web/0if_/https://repo-default.voidlinux.org/live/current/void-armv7l-musl-ROOTFS-20230628.tar.xz'

declare os='void'
145 changes: 68 additions & 77 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,63 @@

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/raiden'

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.40'
declare -r binutils_directory='/tmp/binutils-2.42'

declare -r gcc_tarball='/tmp/gcc.tar.gz'
declare -r gcc_directory='/tmp/gcc-13.2.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

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'

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"

sed --in-place 's/LDBL_MANT_DIG == 113/defined(__powerpc__) || defined(__powerpc64__) || defined(__s390x__)/g' "${gcc_directory}/libgcc/dfp-bit.h"
sed --in-place 's/soft-fp.h/this-does-not-exist.h/g' "${gcc_directory}/libquadmath/math/sqrtq.c"

}

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

Expand All @@ -51,32 +83,27 @@ 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.40.tar.xz' --output "${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}"

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}"
tar --directory="$(dirname "${gcc_directory}")" --extract --file="${gcc_tarball}"
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"

cd "${gmp_directory}/build"
Expand Down Expand Up @@ -120,84 +147,46 @@ cd "${mpc_directory}/build"
--enable-shared \
--enable-static \
${cross_compile_flags} \
CFLAGS="${optflags}" \
CFLAGS="${optflags} -fpermissive" \
CXXFLAGS="${optflags}" \
LDFLAGS="${linkflags}"

make all --jobs
make install

declare -ra targets=(
# 'powerpc-unknown-linux-musl'
's390x-unknown-linux-musl'
'powerpc64le-unknown-linux-musl'
# 'mips-unknown-linux-musl'
# 'mipsel-unknown-linux-musl'
'mips64-unknown-linux-musl'
'armv7l-unknown-linux-musleabihf'
'powerpc64le-unknown-linux-musl'
'x86_64-unknown-linux-musl'
'aarch64-unknown-linux-musl'
'arm-unknown-linux-musleabihf'
'riscv64-unknown-linux-musl'
's390x-unknown-linux-musl'
'i386-unknown-linux-musl'
)

for target in "${targets[@]}"; do
source "${current_source_directory}/${target}.sh"
source "${workdir}/${target}.sh"

cd "$(mktemp --directory)"

if [ "${os}" == 'void' ]; then
declare sysroot_filename="./sysroot.tar.xz"
else
declare sysroot_filename="./sysroot.tar.gz"
fi

curl --connect-timeout '10' --retry '15' --retry-all-errors --fail --silent --location --output "${sysroot_filename}" --url "${sysroot}"

tar --extract --file="${sysroot_filename}" || true
curl \
--url "https://github.com/AmanoTeam/musl-sysroot/releases/latest/download/${triplet}.tar.xz" \
--retry '30' \
--retry-all-errors \
--retry-delay '0' \
--retry-max-time '0' \
--location \
--continue-at '-' \
--output "${sysroot_tarball}"

if [ "${os}" == 'void' ]; then
declare package_filename="./package.tar.xst"
else
declare package_filename="./package.tar.gz"
fi

for package in "${packages[@]}"; do
curl --connect-timeout '10' --retry '15' --retry-all-errors --fail --silent --location --output "${package_filename}" --url "${package}"
tar --extract --file="${package_filename}"
done
tar --directory="${toolchain_directory}" --extract --file="${sysroot_tarball}"

[ -d "${toolchain_directory}/${triplet}" ] || mkdir --parent "${toolchain_directory}/${triplet}"

cp --recursive './usr/include' "${toolchain_directory}/${triplet}"
cp --recursive './usr/lib' "${toolchain_directory}/${triplet}"

if [ -d './lib' ]; then
cp --remove-destination --recursive './lib/'* "${toolchain_directory}/${triplet}/lib"
fi

pushd "${toolchain_directory}/${triplet}/lib"

if [ "${os}" == 'alpine' ]; then
find . -xtype l | xargs ls -l | grep '/lib/' | awk '{print "unlink "$9" && ln -s $(basename "$11") $(basename "$9")"}' | bash

unlink './libc.so'
mv "${ld}" './libc.so'

patchelf --set-soname 'libc.so' './libc.so'
fi

if [ -L "${ld}" ]; then
unlink "${ld}"
fi

ln --symbolic './libc.so' "${ld}"

while read filename; do
if [[ "${filename}" =~ ^lib(pthread|resolv|rt|c|m|util|xnet)\.(so|a)$ || "${filename}" =~ ^.*\.o$ || "${filename}" =~ ^ld\-.*\.so.*$ ]]; then
continue
fi

rm --recursive "${filename}"
done <<< "$(ls)"
unlink "${sysroot_tarball}"

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

Expand All @@ -218,9 +207,11 @@ for target in "${targets[@]}"; do
CXXFLAGS="${optflags}" \
LDFLAGS="${linkflags}"

make all --jobs="${max_jobs}"
make all --jobs
make install

setup_gcc_source "${triplet}"

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

cd "${gcc_directory}/build"
Expand All @@ -235,7 +226,7 @@ for target in "${targets[@]}"; do
--with-mpc="${toolchain_directory}" \
--with-mpfr="${toolchain_directory}" \
--with-bugurl='https://github.com/AmanoTeam/Raiden/issues' \
--with-pkgversion="Raiden v0.4-${revision}" \
--with-pkgversion="Raiden v0.5-${revision}" \
--with-sysroot="${toolchain_directory}/${triplet}" \
--with-gcc-major-version-only \
--with-native-system-header-dir='/include' \
Expand Down Expand Up @@ -285,7 +276,7 @@ for target in "${targets[@]}"; do

for name in *; do
rm "${name}"
ln -s "../../bin/${triplet}-${name}" "${name}"
ln --symbolic "../../bin/${triplet}-${name}" "${name}"
done

rm --recursive "${toolchain_directory}/share"
Expand Down
Loading

0 comments on commit c68b232

Please sign in to comment.