From 1fe9e251d4023dddbecabd33f3a7cae21b3f2505 Mon Sep 17 00:00:00 2001 From: Kartatz <105828205+Kartatz@users.noreply.github.com> Date: Mon, 21 Aug 2023 17:53:01 -0300 Subject: [PATCH] Update to GCC 13.2 --- .github/workflows/build.yml | 89 ++++++++++++++++++++++++++++--------- build.sh | 40 +++++++++++++---- 2 files changed, 100 insertions(+), 29 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index fb611e2..7b6a7d3 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -6,30 +6,77 @@ on: - '**' jobs: - build: + native-build: + name: 'Native build' runs-on: ubuntu-latest + steps: + - uses: actions/checkout@main + with: + submodules: true + - name: Build Raiden + run: | + bash './build.sh' 'native' + - name: Generate tarball + run: | + declare tarball_filename='/tmp/x86_64-linux-gnu.tar.xz' + tar --directory='/tmp' --create --file=- 'obggcc' | xz --threads='0' --compress -9 > "${tarball_filename}" + sha256sum "${tarball_filename}" | sed 's|/tmp/||' > "${tarball_filename}.sha256" + - name: Upload artifact + 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 + 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: [ - alpha-unknown-linux-gnu, - x86_64-unknown-linux-gnu, - i386-unknown-linux-gnu, - arm-unknown-linux-gnueabi, - arm-unknown-linux-gnueabihf, - hppa-unknown-linux-gnu, - aarch64-unknown-linux-gnu, - mips-unknown-linux-gnu, - mipsel-unknown-linux-gnu, - powerpc-unknown-linux-gnu, - s390-unknown-linux-gnu, - s390x-unknown-linux-gnu, - sparc-unknown-linux-gnu, - powerpc64le-unknown-linux-gnu + 'alpha-unknown-linux-gnu', + 'x86_64-unknown-linux-gnu', + 'i386-unknown-linux-gnu', + 'arm-unknown-linux-gnueabi', + 'arm-unknown-linux-gnueabihf', + 'hppa-unknown-linux-gnu', + 'aarch64-unknown-linux-gnu', + 'mips-unknown-linux-gnu', + 'mipsel-unknown-linux-gnu', + 'powerpc-unknown-linux-gnu', + 's390-unknown-linux-gnu', + 's390x-unknown-linux-gnu', + 'sparc-unknown-linux-gnu', + 'powerpc64le-unknown-linux-gnu' ] steps: - uses: actions/checkout@main with: submodules: true + - name: Restore artifact + 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='./x86_64-linux-gnu.tar.xz' + mv '/tmp/obggcc' '/tmp/obggcc-toolchain' - name: Build OBGGCC with OBGGCC run: | source './tools/setup_toolchain.sh' @@ -37,12 +84,14 @@ jobs: bash './build.sh' '${{ matrix.target }}' - name: Generate tarball run: | - declare tarball_filename='${{ matrix.target }}.tar.xz' - tar --directory='/tmp' --create --file=- 'obggcc' | xz --threads=0 --compress -9 > "${tarball_filename}" - sha256sum "${tarball_filename}" > "${tarball_filename}.sha256" + declare tarball_filename='/tmp/${{ matrix.target }}.tar.xz' + tar --directory='/tmp' --create --file=- 'obggcc' | xz --threads='0' --compress -9 > "${tarball_filename}" + sha256sum "${tarball_filename}" | sed 's|/tmp/||' > "${tarball_filename}.sha256" - name: Upload artifact uses: actions/upload-artifact@main with: + name: cross-toolchain + if-no-files-found: error path: | - ${{ matrix.target }}.tar.xz - ${{ matrix.target }}.tar.xz.sha256 + /tmp/${{ matrix.target }}.tar.xz + /tmp/${{ matrix.target }}.tar.xz.sha256 diff --git a/build.sh b/build.sh index 0bdf288..4a0bd4e 100644 --- a/build.sh +++ b/build.sh @@ -7,7 +7,6 @@ declare -r obggcc_revision="$(git rev-parse --short HEAD)" declare -r current_source_directory="${PWD}" declare -r toolchain_directory='/tmp/obggcc' -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' @@ -22,12 +21,34 @@ declare -r binutils_tarball='/tmp/binutils.tar.xz' declare -r binutils_directory='/tmp/binutils-2.40' 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 "./toolchains/${1}.sh" +declare -r max_jobs="$(($(nproc) * 8))" + +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 "./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}" @@ -50,7 +71,7 @@ if ! [ -f "${binutils_tarball}" ]; then 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 @@ -198,6 +219,7 @@ for target in "${targets[@]}"; do --disable-gprofng \ --with-static-standard-libraries \ --program-prefix="${triple}-" \ + --with-sysroot="${toolchain_directory}/${triple}" \ CFLAGS="${optflags}" \ CXXFLAGS="${optflags}" \ LDFLAGS="${linkflags}" @@ -220,6 +242,10 @@ for target in "${targets[@]}"; do --with-mpfr="${toolchain_directory}" \ --with-static-standard-libraries \ --with-bugurl='https://github.com/AmanoTeam/obggcc/issues' \ + --with-gcc-major-version-only \ + --with-pkgversion="OBGGCC v0.5-${obggcc_revision}" \ + --with-sysroot="${toolchain_directory}/${triple}" \ + --with-native-system-header-dir='/include' \ --enable-__cxa_atexit \ --enable-cet='auto' \ --enable-checking='release' \ @@ -243,12 +269,8 @@ for target in "${targets[@]}"; do --disable-werror \ --disable-multilib \ --disable-plugin \ - --without-headers \ - --with-gcc-major-version-only \ - --with-pkgversion="OBGGCC v0.4-${obggcc_revision}" \ - --with-sysroot="${toolchain_directory}/${triple}" \ - --with-native-system-header-dir='/include' \ --disable-nls \ + --without-headers \ ${extra_configure_flags} \ CFLAGS="${optflags}" \ CXXFLAGS="${optflags}" \