Skip to content

Commit

Permalink
Update to GCC 13.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Kartatz committed Sep 23, 2023
1 parent a40011d commit 12b5741
Show file tree
Hide file tree
Showing 27 changed files with 131 additions and 52 deletions.
61 changes: 60 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,55 @@ on:
- '**'

jobs:
build:
native-build:
name: 'Native build'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@main
with:
submodules: true
- name: Check for cache
id: check-cache
uses: actions/cache@main
with:
key: gcc-13.2.0
lookup-only: true
path: |
/tmp/x86_64-linux-gnu.tar.xz
/tmp/x86_64-linux-gnu.tar.xz.sha256
- name: Build Sphynx
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=- 'sphynx' | 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-13.2.0
path: |
/tmp/x86_64-linux-gnu.tar.xz
/tmp/x86_64-linux-gnu.tar.xz.sha256
cross-build:
name: 'Cross build'
needs: native-build
runs-on: ubuntu-latest
continue-on-error: true
strategy:
matrix:
target: [
Expand All @@ -30,6 +77,18 @@ jobs:
- uses: actions/checkout@main
with:
submodules: true
- name: Restore from cache
uses: actions/cache@main
with:
key: gcc-13.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='/tmp/x86_64-linux-gnu.tar.xz'
mv '/tmp/sphynx' '/tmp/sphynx-toolchain'
- name: Build Sphynx with OBGGCC
run: |
source './submodules/obggcc/tools/setup_toolchain.sh'
Expand Down
2 changes: 1 addition & 1 deletion aarch64-linux-gnu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ declare packages=(

declare extra_configure_flags='--enable-fix-cortex-a53-843419'

declare triple='aarch64-unknown-linux-gnu'
declare triplet='aarch64-unknown-linux-gnu'
2 changes: 1 addition & 1 deletion alpha-linux-gnu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ declare packages=(

declare extra_configure_flags=''

declare triple='alpha-unknown-linux-gnu'
declare triplet='alpha-unknown-linux-gnu'
2 changes: 1 addition & 1 deletion arm-linux-gnueabi.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ declare packages=(

declare extra_configure_flags='--with-arch=armv5te --with-float=soft'

declare triple='arm-unknown-linux-gnueabi'
declare triplet='arm-unknown-linux-gnueabi'
2 changes: 1 addition & 1 deletion arm-linux-gnueabihf.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ declare packages=(

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

declare triple='arm-unknown-linux-gnueabihf'
declare triplet='arm-unknown-linux-gnueabihf'
72 changes: 46 additions & 26 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ declare -r revision="$(git rev-parse --short HEAD)"
declare -r current_source_directory="${PWD}"

declare -r toolchain_directory='/tmp/sphynx'
declare -r toolchain_tarball="${current_source_directory}/linux-cross.tar.xz"

declare -r gmp_tarball='/tmp/gmp.tar.xz'
declare -r gmp_directory='/tmp/gmp-6.2.1'
Expand All @@ -19,15 +18,35 @@ 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.41'

declare -r gcc_tarball='/tmp/gcc.tar.gz'
declare -r gcc_directory='/tmp/gcc-master'
declare -r gcc_directory='/tmp/gcc-13.2.0'

declare -r optflags='-Os'
declare -r linkflags='-Wl,-s'

source "./submodules/obggcc/toolchains/${1}.sh"
declare build_type="${1}"

if [ -z "${build_type}" ]; then
build_type='native'
fi

declare is_native='0'

if [ "${build_type}" == 'native' ]; then
is_native='1'
fi

declare OBGGCC_TOOLCHAIN='/tmp/obggcc-toolchain'
declare CROSS_COMPILE_TRIPLET=''

declare cross_compile_flags=''

if ! (( is_native )); then
source "./submodules/obggcc/toolchains/${build_type}.sh"
cross_compile_flags+="--host=${CROSS_COMPILE_TRIPLET}"
fi

if ! [ -f "${gmp_tarball}" ]; then
wget --no-verbose 'https://mirrors.kernel.org/gnu/gmp/gmp-6.2.1.tar.xz' --output-document="${gmp_tarball}"
Expand All @@ -45,12 +64,12 @@ if ! [ -f "${mpc_tarball}" ]; then
fi

if ! [ -f "${binutils_tarball}" ]; then
wget --no-verbose 'https://mirrors.kernel.org/gnu/binutils/binutils-2.40.tar.xz' --output-document="${binutils_tarball}"
wget --no-verbose 'https://mirrors.kernel.org/gnu/binutils/binutils-2.41.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://codeload.github.com/gcc-mirror/gcc/tar.gz/refs/heads/master' --output-document="${gcc_tarball}"
wget --no-verbose 'https://mirrors.kernel.org/gnu/gcc/gcc-13.2.0/gcc-13.2.0.tar.xz' --output-document="${gcc_tarball}"
tar --directory="$(dirname "${gcc_directory}")" --extract --file="${gcc_tarball}"
fi

Expand All @@ -60,10 +79,10 @@ cd "${gmp_directory}/build"
rm --force --recursive ./*

../configure \
--host="${CROSS_COMPILE_TRIPLET}" \
--prefix="${toolchain_directory}" \
--enable-shared \
--enable-static \
${cross_compile_flags} \
CFLAGS="${optflags}" \
CXXFLAGS="${optflags}" \
LDFLAGS="${linkflags}"
Expand All @@ -77,11 +96,11 @@ cd "${mpfr_directory}/build"
rm --force --recursive ./*

../configure \
--host="${CROSS_COMPILE_TRIPLET}" \
--prefix="${toolchain_directory}" \
--with-gmp="${toolchain_directory}" \
--enable-shared \
--enable-static \
${cross_compile_flags} \
CFLAGS="${optflags}" \
CXXFLAGS="${optflags}" \
LDFLAGS="${linkflags}"
Expand All @@ -95,11 +114,11 @@ cd "${mpc_directory}/build"
rm --force --recursive ./*

../configure \
--host="${CROSS_COMPILE_TRIPLET}" \
--prefix="${toolchain_directory}" \
--with-gmp="${toolchain_directory}" \
--enable-shared \
--enable-static \
${cross_compile_flags} \
CFLAGS="${optflags}" \
CXXFLAGS="${optflags}" \
LDFLAGS="${linkflags}"
Expand Down Expand Up @@ -169,9 +188,9 @@ for target in "${targets[@]}"; do

[ -d "${toolchain_directory}" ] || mkdir "${toolchain_directory}"

mv "./usr/${target}" "${toolchain_directory}/${triple}"
mv "./usr/${target}" "${toolchain_directory}/${triplet}"

cd "${toolchain_directory}/${triple}/lib"
cd "${toolchain_directory}/${triplet}/lib"

if ! [ -h './libc.so' ]; then
if [ -d "../lib64" ]; then
Expand All @@ -195,15 +214,16 @@ for target in "${targets[@]}"; do
rm --force --recursive ./*

../configure \
--host="${CROSS_COMPILE_TRIPLET}" \
--target="${triple}" \
--target="${triplet}" \
--prefix="${toolchain_directory}" \
--enable-gold \
--enable-ld \
--enable-lto \
--disable-gprofng \
--with-static-standard-libraries \
--program-prefix="${triple}-" \
--program-prefix="${triplet}-" \
--with-sysroot="${toolchain_directory}/${triplet}" \
${cross_compile_flags} \
CFLAGS="${optflags}" \
CXXFLAGS="${optflags}" \
LDFLAGS="${linkflags}"
Expand All @@ -217,8 +237,7 @@ for target in "${targets[@]}"; do
rm --force --recursive ./*

../configure \
--host="${CROSS_COMPILE_TRIPLET}" \
--target="${triple}" \
--target="${triplet}" \
--prefix="${toolchain_directory}" \
--with-linker-hash-style='gnu' \
--with-gmp="${toolchain_directory}" \
Expand Down Expand Up @@ -251,12 +270,13 @@ for target in "${targets[@]}"; do
--enable-ld \
--enable-gold \
--with-gcc-major-version-only \
--with-pkgversion="Sphynx v0.2-${revision}" \
--with-sysroot="${toolchain_directory}/${triple}" \
--with-pkgversion="Sphynx v0.3-${revision}" \
--with-sysroot="${toolchain_directory}/${triplet}" \
--with-native-system-header-dir='/include' \
--disable-nls \
--disable-libsanitizer \
--program-prefix="${triple}-" \
--program-prefix="${triplet}-" \
${cross_compile_flags} \
${extra_configure_flags} \
CFLAGS="${optflags}" \
CXXFLAGS="${optflags}" \
Expand All @@ -270,20 +290,20 @@ for target in "${targets[@]}"; do
--jobs="$(($(nproc) * 12))"
make install

cd "${toolchain_directory}/${triple}/bin"
cd "${toolchain_directory}/${triplet}/bin"

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

rm --recursive "${toolchain_directory}/share"

if [ "${CROSS_COMPILE_TRIPLET}" == "${triple}" ]; then
rm "${toolchain_directory}/bin/${triple}-${triple}"*
if [ "${CROSS_COMPILE_TRIPLET}" == "${triplet}" ]; then
rm "${toolchain_directory}/bin/${triplet}-${triplet}"*
fi

patchelf --add-rpath '$ORIGIN/../../../../lib' "${toolchain_directory}/libexec/gcc/${triple}/"*'/cc1'
patchelf --add-rpath '$ORIGIN/../../../../lib' "${toolchain_directory}/libexec/gcc/${triple}/"*'/cc1plus'
patchelf --add-rpath '$ORIGIN/../../../../lib' "${toolchain_directory}/libexec/gcc/${triple}/"*'/lto1'
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'
done
2 changes: 1 addition & 1 deletion hppa-linux-gnu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ declare packages=(

declare extra_configure_flags=''

declare triple='hppa-unknown-linux-gnu'
declare triplet='hppa-unknown-linux-gnu'
2 changes: 1 addition & 1 deletion i686-linux-gnu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ declare packages=(

declare extra_configure_flags='--with-arch-32=i686 --with-tune=generic'

declare triple='i686-unknown-linux-gnu'
declare triplet='i686-unknown-linux-gnu'
2 changes: 1 addition & 1 deletion m68k-linux-gnu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ declare packages=(

declare extra_configure_flags=''

declare triple='m68k-unknown-linux-gnu'
declare triplet='m68k-unknown-linux-gnu'
2 changes: 1 addition & 1 deletion mips-linux-gnu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ declare packages=(

declare extra_configure_flags='--with-arch-32=mips32r2 --with-fp-32=xx --with-lxc1-sxc1=no'

declare triple='mips-unknown-linux-gnu'
declare triplet='mips-unknown-linux-gnu'
2 changes: 1 addition & 1 deletion mips64-linux-gnuabi64.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ declare packages=(

declare extra_configure_flags='--with-mips-plt --with-arch-64=mips64r2'

declare triple='mips64-unknown-linux-gnuabi64'
declare triplet='mips64-unknown-linux-gnuabi64'
2 changes: 1 addition & 1 deletion mips64el-linux-gnuabi64.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ declare packages=(

declare extra_configure_flags='--with-mips-plt --with-arch-64=mips64r2 --with-madd4=no --with-arch-32=mips32r2 --with-fp-32=xx --disable-libsanitizer'

declare triple='mips64el-unknown-linux-gnuabi64'
declare triplet='mips64el-unknown-linux-gnuabi64'
2 changes: 1 addition & 1 deletion mipsel-linux-gnu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ declare packages=(

declare extra_configure_flags='--with-arch-32=mips32r2 --with-fp-32=xx --with-madd4=no --with-lxc1-sxc1=no --disable-libsanitizer'

declare triple='mipsel-unknown-linux-gnu'
declare triplet='mipsel-unknown-linux-gnu'
2 changes: 1 addition & 1 deletion mipsisa32r6-linux-gnu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ declare packages=(

declare extra_configure_flags='--with-arch-32=mips32r6 --with-tune-32=mips32r6 --with-arch-64=mips64r6 --with-tune-64=mips64r6'

declare triple='mipsisa32r6-unknown-linux-gnu'
declare triplet='mipsisa32r6-unknown-linux-gnu'
2 changes: 1 addition & 1 deletion mipsisa32r6el-linux-gnu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ declare packages=(

declare extra_configure_flags='--with-arch-32=mips32r6 --with-tune-32=mips32r6 --with-arch-64=mips64r6 --with-tune-64=mips64r6'

declare triple='mipsisa32r6el-unknown-linux-gnu'
declare triplet='mipsisa32r6el-unknown-linux-gnu'
2 changes: 1 addition & 1 deletion mipsisa64r6-linux-gnuabi64.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ declare packages=(

declare extra_configure_flags='--with-mips-plt --with-arch-64=mips64r6 --with-tune-64=mips64r6 --with-arch-32=mips32r6 --with-tune-32=mips32r6'

declare triple='mipsisa64r6-unknown-linux-gnuabi64'
declare triplet='mipsisa64r6-unknown-linux-gnuabi64'
2 changes: 1 addition & 1 deletion mipsisa64r6el-linux-gnuabi64.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ declare packages=(

declare extra_configure_flags='--with-mips-plt --with-arch-64=mips64r6 --with-tune-64=mips64r6 --with-arch-32=mips32r6 --with-tune-32=mips32r6'

declare triple='mipsisa64r6el-unknown-linux-gnuabi64'
declare triplet='mipsisa64r6el-unknown-linux-gnuabi64'
2 changes: 1 addition & 1 deletion powerpc-linux-gnu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ declare packages=(

declare extra_configure_flags=''

declare triple='powerpc-unknown-linux-gnu'
declare triplet='powerpc-unknown-linux-gnu'
2 changes: 1 addition & 1 deletion powerpc64-linux-gnu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ declare packages=(

declare extra_configure_flags=''

declare triple='powerpc64-unknown-linux-gnu'
declare triplet='powerpc64-unknown-linux-gnu'
2 changes: 1 addition & 1 deletion powerpc64le-linux-gnu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ declare packages=(

declare extra_configure_flags='--enable-secureplt --with-cpu=power8 --with-long-double-128'

declare triple='powerpc64le-unknown-linux-gnu'
declare triplet='powerpc64le-unknown-linux-gnu'
2 changes: 1 addition & 1 deletion riscv64-linux-gnu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ declare packages=(

declare extra_configure_flags='--with-arch=rv64imafdc --with-abi=lp64d'

declare triple='riscv64-unknown-linux-gnu'
declare triplet='riscv64-unknown-linux-gnu'
2 changes: 1 addition & 1 deletion s390x-linux-gnu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ declare packages=(

declare extra_configure_flags='--with-arch=z196 --with-long-double-128'

declare triple='s390x-unknown-linux-gnu'
declare triplet='s390x-unknown-linux-gnu'
2 changes: 1 addition & 1 deletion sh4-linux-gnu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ declare packages=(

declare extra_configure_flags=''

declare triple='sh4-unknown-linux-gnu'
declare triplet='sh4-unknown-linux-gnu'
2 changes: 1 addition & 1 deletion sparc64-linux-gnu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ declare packages=(

declare extra_configure_flags=''

declare triple='sparc64-unknown-linux-gnu'
declare triplet='sparc64-unknown-linux-gnu'
Loading

0 comments on commit 12b5741

Please sign in to comment.