name: LoongArch64 CI (GCC 14.2)

on:
  push:
    branches:
      - master
  pull_request:
    branches:
      - master

jobs:
  loongarch64:
    runs-on: ubuntu-24.04
    steps:
      - uses: actions/checkout@v6
      - name: Install build requirements
        run: |
          sudo apt-get update -q -y
          sudo apt-get install -y cmake curl ninja-build \
                                g++-14-loongarch64-linux-gnu \
                                gcc-14-loongarch64-linux-gnu-base \
                                gcc-14-loongarch64-linux-gnu
      - name: Download LoongArch64 qemu-10.0.2  # need qemu > 9.2
        run: |
          sudo curl -L https://github.com/loongson/build-tools/releases/download/2025.06.06/qemu-loongarch64 --output /usr/local/bin/qemu-loongarch64
          sudo chmod +x /usr/local/bin/qemu-loongarch64
      - name: Build
        run: |
          export QEMU_LD_PREFIX="/usr/loongarch64-linux-gnu"
          export QEMU_CPU="la464"
          cmake -DCMAKE_TOOLCHAIN_FILE=cmake/toolchains-dev/loongarch64.cmake -B build -DSIMDUTF_FAST_TESTS=On
          cmake --build build -j$(nproc)
      - name: Test
        run: |
          export PATH=/usr/local/bin:$PATH
          export QEMU_LD_PREFIX="/usr/loongarch64-linux-gnu"
          export QEMU_CPU="la464"
          ctest --output-on-failure --test-dir build -j $(nproc)
        
