Skip to content

[gcc] build aarch64 cross -Wno-error #13

[gcc] build aarch64 cross -Wno-error

[gcc] build aarch64 cross -Wno-error #13

name: Build gcc from source for multiple arch
on:
workflow_dispatch:
push:
branches:
- dev_gcc_build
jobs:
build:
name: Build
continue-on-error: false
strategy:
matrix:
target:
- id: 'linux-amd64'
os: 'ubuntu-latest'
tar_extra_args: ''
host: 'x86_64-pc-linux-gnu'
- id: 'linux-amd64-mips'
os: 'ubuntu-latest'
tar_extra_args: ''
host: 'mipsel-unknown-linux-gnu'
- id: 'linux-amd64-aarch64'
os: 'ubuntu-latest'
tar_extra_args: ''
host: 'aarch64-linux-gnu'
# - id: 'linux-aarch64'
# os: "ubuntu-latest"
# os: ['self-hosted', 'linux', 'ARM64']
# - id: 'linux-riscv64'
# os: "ubuntu-latest"
# os: ['self-hosted', 'linux', 'RISCV64']
## https://github.blog/changelog/2024-01-30-github-actions-introducing-the-new-m1-macos-runner-available-to-open-source/
# - id: 'darwin-amd64'
# os: 'macos-14'
# tar_extra_args: ''
# - id: 'windows-amd64'
# os: 'windows-2019'
# When unpacking an archive on Windows, the symlinks can't be
# created unless the target path already exists. This causes
# problems when the linked file is ordered after the link
# inside the archive. Dereferencing the files when packing them
# adds an additional copy per link, but it reliably works and
# the additional size is not too large on Windows.
# tar_extra_args: '--dereference'
# llvm_version: ['16.x']
# llvm_repo_url: ['https://github.com/llvm/llvm-project.git']
fail-fast: true
runs-on: ${{ matrix.target.os }}
steps:
- name: Check out the code
uses: actions/checkout@v4
with:
fetch-depth: 2
- name: Install `ninja` on Ubuntu
if: startsWith(matrix.target.id, 'linux-')
shell: bash
run: |
sudo apt install ninja-build build-essential clang coreutils gcc-multilib g++-multilib texinfo -y
echo "cpu core num is "
nproc
# - name: Install `ninja llvm cmake ` on macOS
# if: startsWith(matrix.target.id, 'darwin-')
# shell: bash
# run: |
# brew install ninja llvm cmake
# clang --version
# echo "BREW_INSTALL_PREFIX=$(brew --prefix llvm)" >> $GITHUB_ENV
# echo "${BREW_INSTALL_PREFIX}/bin"
# echo "/opt/homebrew/opt/llvm/bin" >> $GITHUB_PATH
# clang --version
# echo "llvm"
# /opt/homebrew/opt/llvm/bin/clang --version
# - name: Check out llvm source code
# uses: actions/checkout@v4
# with:
# repository: ''
# ref: ${{ matrix.llvm_version }}
- name: prepare source from tarball
if: startsWith(matrix.target.id, 'linux-')
shell: bash
run: |
ls -alSh
mkdir -p build
tar xvf assets/gcc-13.2.0.tar.xz -C build
mv build/gcc-13.2.0 gcc13source
ls -alSh gcc13source
tar xvf assets/binutils-2.42.tar.gz -C build
mv build/binutils-2.42 binutils-2.42
ls -alSh binutils-2.42
- name: Build for x86_64-pc-linux-gnu host
if: matrix.target.host == 'x86_64-pc-linux-gnu'
shell: bash
run: |
ls -alSh
chmod +x ./scripts/build_gcc.sh
./scripts/build_gcc.sh ${{ matrix.target.host }}
- name: Build for mipsel-unknown-linux-gnu host
if: matrix.target.host == 'mipsel-unknown-linux-gnu'
shell: bash
run: |
ls -alSh
chmod +x ./scripts/build_gcc_cross.sh
./scripts/build_gcc_cross.sh ${{ matrix.target.host }}
- name: Build gcc cross
if: matrix.target.host == 'aarch64-linux-gnu'
shell: bash
run: |
ls -alSh
chmod +x ./scripts/build_cross_gcc.sh
./scripts/build_cross_gcc.sh
# - name: Build (darwin-amd64)
# if: startsWith(matrix.target.id, 'darwin-')
# shell: bash
# run: |
# ./scripts/build_llvm_mac.sh ${{ matrix.llvm_version }} ${{ matrix.llvm_repo_url }}
# - name: Build (Windows)
# if: matrix.target.id == 'windows-amd64'
# shell: |
# powershell -Command "& '{0}'"
# run: |
# ./scripts/build_llvm.ps1 ${{ matrix.llvm_version }} ${{ matrix.llvm_repo_url }}
- name: Inspect gcc version
if: matrix.target.host != 'aarch64-linux-gnu'
shell: bash
run: |
PATH=gcc-13-build/bin:$PATH gcc --version
PATH=gcc-13-build/bin:PATH g++ --version
- name: Zip
shell: bash
run: |
mkdir -p dist
ls -alSh
if [ ${{ matrix.target.host }} == 'aarch64-linux-gnu' ]; then
tar --directory /opt/cross --create --xz --verbose ${{ matrix.target.tar_extra_args }} --file dist/gcc_cross.tar.xz .
elif [ ${{ matrix.target.host }} == 'x86_64-pc-linux-gnu' || ${{ matrix.target.host }} == 'mipsel-unknown-linux-gnu' ]; then
tar --directory gcc-13-build --create --xz --verbose ${{ matrix.target.tar_extra_args }} --file dist/gcc.tar.xz .
else
echo "unknown host"
fi
ls -lh dist/gcc.tar.xz
- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.target.id }}-${{ matrix.target.os }}-${{ matrix.target.host }}
path: dist
if-no-files-found: error
retention-days: 7