From 54828f274ebf34f2ef3fa5d2916ec67c93d4d366 Mon Sep 17 00:00:00 2001 From: Kartatz <105828205+Kartatz@users.noreply.github.com> Date: Sat, 29 Jul 2023 13:58:20 -0300 Subject: [PATCH] Update to GCC 12.3 --- .github/workflows/build.yml | 77 +++++++++++++++++------- build.sh | 114 +++++++++++++++++++++--------------- submodules/obggcc | 2 +- 3 files changed, 122 insertions(+), 71 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 114998c..42bda58 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -6,33 +6,64 @@ on: - '**' jobs: - build: + native-build: + name: 'Native build' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@main + with: + submodules: true + - name: Build Atar + run: | + bash './build.sh' 'native' + - name: Generate tarball + run: | + declare tarball_filename='/tmp/x86_64-linux-gnu.tar.xz' + tar --directory='/tmp' --create --file=- 'atar' | 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 + + cross-build: + name: 'Cross build' + needs: native-build runs-on: ubuntu-latest 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: Install required dependencies + - name: Download artifact + uses: actions/download-artifact@main + with: + name: native-toolchain + - name: Setup toolchain run: | - sudo apt-get install --assume-yes libfl-dev + tar --directory='/tmp' --extract --file='./x86_64-linux-gnu.tar.xz' + mv '/tmp/atar' '/tmp/atar-toolchain' - name: Build Atar with OBGGCC run: | source './tools/setup_toolchain.sh' @@ -41,12 +72,14 @@ jobs: bash './build.sh' '${{ matrix.target }}' - name: Generate tarball run: | - declare tarball_filename='${{ matrix.target }}.tar.xz' - tar --directory='/tmp' --create --file=- 'atar' | 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=- 'atar' | 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 cc5db1c..1db1f2a 100644 --- a/build.sh +++ b/build.sh @@ -14,15 +14,37 @@ 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.xz' -declare -r gcc_directory='/tmp/gcc-12.2.0' +declare -r gcc_directory='/tmp/gcc-12.3.0' declare -r optflags='-Os' declare -r linkflags='-Wl,-s' -source "./submodules/obggcc/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 "./submodules/obggcc/toolchains/${build_type}.sh" + cross_compile_flags+="--host=${CROSS_COMPILE_TRIPLET}" +fi if ! [ -f "${gmp_tarball}" ]; then wget --no-verbose 'https://ftp.gnu.org/gnu/gmp/gmp-6.2.1.tar.xz' --output-document="${gmp_tarball}" @@ -40,12 +62,12 @@ if ! [ -f "${mpc_tarball}" ]; then fi if ! [ -f "${binutils_tarball}" ]; then - wget --no-verbose 'https://ftp.gnu.org/gnu/binutils/binutils-2.40.tar.xz' --output-document="${binutils_tarball}" + wget --no-verbose 'https://ftp.gnu.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://ftp.gnu.org/gnu/gcc/gcc-12.2.0/gcc-12.2.0.tar.xz' --output-document="${gcc_tarball}" + wget --no-verbose 'https://ftp.gnu.org/gnu/gcc/gcc-12.3.0/gcc-12.3.0.tar.xz' --output-document="${gcc_tarball}" tar --directory="$(dirname "${gcc_directory}")" --extract --file="${gcc_tarball}" fi @@ -59,15 +81,15 @@ 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}" -make all --jobs="$(($(nproc) * 8))" +make all --jobs make install [ -d "${mpfr_directory}/build" ] || mkdir "${mpfr_directory}/build" @@ -76,16 +98,16 @@ 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}" -make all --jobs="$(($(nproc) * 8))" +make all --jobs make install [ -d "${mpc_directory}/build" ] || mkdir "${mpc_directory}/build" @@ -94,16 +116,16 @@ 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}" -make all --jobs="$(($(nproc) * 8))" +make all --jobs make install sed -i 's/#include /#include \n#include /g' "${toolchain_directory}/include/mpc.h" @@ -111,51 +133,51 @@ sed -i 's/#include /#include \n#include /g' "${tool [ -d "${binutils_directory}/build" ] || mkdir "${binutils_directory}/build" declare -r targets=( - 'amd64' - 'i386' 'hppa' 'alpha' + 'amd64' + 'i386' ) for target in "${targets[@]}"; do case "${target}" in amd64) - declare triple='x86_64-unknown-openbsd';; + declare triplet='x86_64-unknown-openbsd';; i386) - declare triple='i386-unknown-openbsd';; + declare triplet='i386-unknown-openbsd';; hppa) - declare triple='hppa-unknown-openbsd';; + declare triplet='hppa-unknown-openbsd';; alpha) - declare triple='alpha-unknown-openbsd';; + declare triplet='alpha-unknown-openbsd';; esac - wget --no-verbose "https://ftp.openbsd.org/pub/OpenBSD/7.0/${target}/base70.tgz" --output-document='/tmp/base.tgz' - wget --no-verbose "https://ftp.openbsd.org/pub/OpenBSD/7.0/${target}/comp70.tgz" --output-document='/tmp/comp.tgz' + wget --no-verbose "https://mirrors.ucr.ac.cr/pub/OpenBSD/7.0/${target}/base70.tgz" --output-document='/tmp/base.tgz' + wget --no-verbose "https://mirrors.ucr.ac.cr/pub/OpenBSD/7.0/${target}/comp70.tgz" --output-document='/tmp/comp.tgz' cd "${binutils_directory}/build" 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}-" \ + --with-sysroot="${toolchain_directory}/${triplet}" \ + ${cross_compile_flags} \ CFLAGS="${optflags}" \ CXXFLAGS="${optflags}" \ LDFLAGS="${linkflags}" - make all --jobs="$(($(nproc) * 8))" + make all --jobs="${max_jobs}" make install - tar --directory="${toolchain_directory}/${triple}" --strip=2 --extract --file='/tmp/base.tgz' './usr/lib' './usr/include' - tar --directory="${toolchain_directory}/${triple}" --strip=2 --extract --file='/tmp/comp.tgz' './usr/lib' './usr/include' + tar --directory="${toolchain_directory}/${triplet}" --strip=2 --extract --file='/tmp/base.tgz' './usr/lib' './usr/include' + tar --directory="${toolchain_directory}/${triplet}" --strip=2 --extract --file='/tmp/comp.tgz' './usr/lib' './usr/include' - cd "${toolchain_directory}/${triple}/lib" + cd "${toolchain_directory}/${triplet}/lib" while read source; do IFS='.' read -ra parts <<< "${source}" @@ -177,14 +199,17 @@ for target in "${targets[@]}"; do fi ../configure \ - --host="${CROSS_COMPILE_TRIPLET}" \ - --target="${triple}" \ + --target="${triplet}" \ --prefix="${toolchain_directory}" \ --with-linker-hash-style='gnu' \ --with-gmp="${toolchain_directory}" \ --with-mpc="${toolchain_directory}" \ --with-mpfr="${toolchain_directory}" \ --with-bugurl='https://github.com/AmanoTeam/Atar/issues' \ + --with-gcc-major-version-only \ + --with-pkgversion="Atar v0.3-${revision}" \ + --with-sysroot="${toolchain_directory}/${triplet}" \ + --with-native-system-header-dir='/include' \ --enable-__cxa_atexit \ --enable-cet='auto' \ --enable-checking='release' \ @@ -195,24 +220,21 @@ for target in "${targets[@]}"; do --enable-link-serialization='1' \ --enable-linker-build-id \ --enable-lto \ - --disable-multilib \ --enable-plugin \ --enable-shared \ --enable-threads='posix' \ --enable-libssp \ + --enable-languages='c,c++' \ + --enable-ld \ + --enable-gold \ + --disable-multilib \ --disable-libstdcxx-pch \ --disable-werror \ - --enable-languages='c,c++' \ --disable-bootstrap \ --disable-libatomic \ - --without-headers \ - --enable-ld \ - --enable-gold \ - --with-gcc-major-version-only \ - --with-pkgversion="Atar v0.2-${revision}" \ - --with-sysroot="${toolchain_directory}/${triple}" \ - --with-native-system-header-dir='/include' \ --disable-nls \ + --without-headers \ + ${cross_compile_flags} \ ${extra_configure_flags} \ CFLAGS="${optflags}" \ CXXFLAGS="${optflags}" \ @@ -221,24 +243,20 @@ for target in "${targets[@]}"; do LD_LIBRARY_PATH="${toolchain_directory}/lib" PATH="${PATH}:${toolchain_directory}/bin" make \ CFLAGS_FOR_TARGET="${optflags} ${linkflags}" \ CXXFLAGS_FOR_TARGET="${optflags} ${linkflags}" \ - all --jobs="$(($(nproc) * 8))" + all --jobs="${max_jobs}" 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" - rm --recursive "${toolchain_directory}/lib/gcc/${triple}/12/include-fixed" - - if [ "${CROSS_COMPILE_TRIPLET}" == "${triple}" ]; then - rm "${toolchain_directory}/bin/${triple}-${triple}"* - fi + rm --recursive "${toolchain_directory}/lib/gcc/${triplet}/"*"/include-fixed" - patchelf --add-rpath '$ORIGIN/../../../../lib' "${toolchain_directory}/libexec/gcc/${triple}/12/cc1" - patchelf --add-rpath '$ORIGIN/../../../../lib' "${toolchain_directory}/libexec/gcc/${triple}/12/cc1plus" - patchelf --add-rpath '$ORIGIN/../../../../lib' "${toolchain_directory}/libexec/gcc/${triple}/12/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 diff --git a/submodules/obggcc b/submodules/obggcc index 34f49c8..0820ee6 160000 --- a/submodules/obggcc +++ b/submodules/obggcc @@ -1 +1 @@ -Subproject commit 34f49c89cbf829aa1829d78f9d218d98b05f1f7f +Subproject commit 0820ee6a030d2d5b0d16dfc87eff7ad4b3310cfa