diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 7dbb4fdd..d9b3e326 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -145,8 +145,27 @@ jobs: - name: Perform CodeQL Analysis uses: github/codeql-action/analyze@v3 - manylinux: + riscv64: + runs-on: ubuntu-latest + name: RiscV 64 + steps: + - name: checkout + uses: actions/checkout@v4 + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: "3.13" + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + with: + platforms: all + - name: Build and test greenlet + env: + DOCKER_IMAGE: riscv64/ubuntu:latest + run: bash ./ubuntu-test + + manylinux: runs-on: ubuntu-latest # We use a regular Python matrix entry to share as much code as possible. strategy: diff --git a/MANIFEST.in b/MANIFEST.in index f9b94e87..3c0c8ccf 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -50,6 +50,7 @@ include LICENSE.PSF include MANIFEST.in include make-manylinux +include ubuntu-test global-exclude *.pyc global-exclude *.pyd diff --git a/src/greenlet/platform/switch_riscv_unix.h b/src/greenlet/platform/switch_riscv_unix.h index 32ca78c8..87611222 100644 --- a/src/greenlet/platform/switch_riscv_unix.h +++ b/src/greenlet/platform/switch_riscv_unix.h @@ -12,13 +12,9 @@ static int slp_switch(void) { int ret; -#if __riscv_xlen == 32 long fp; long *stackref, stsizediff; -#else - int fp; - int *stackref, stsizediff; -#endif + __asm__ volatile ("" : : : REGS_TO_SAVE); __asm__ volatile ("mv %0, fp" : "=r" (fp) : ); __asm__ volatile ("mv %0, sp" : "=r" (stackref) : ); diff --git a/ubuntu-test b/ubuntu-test new file mode 100755 index 00000000..93854348 --- /dev/null +++ b/ubuntu-test @@ -0,0 +1,47 @@ +#!/bin/bash + +# This needs to be run from the root of the project. + +set -e +export PYTHONUNBUFFERED=1 +export PYTHONDONTWRITEBYTECODE=1 +# Use a fixed hash seed for reproducibility +export PYTHONHASHSEED=8675309 +export CI=1 +export TRAVIS=true +export PIP_NO_WARN_SCRIPT_LOCATION=1 + + +if [ -d /greenlet ]; then + # Running inside docker + export GREENLET_MANYLINUX=1 + # Our setup.py overrides this with -Os; be sure it does. + export CFLAGS="-O3 -DNDEBUG -Wall" + + apt-get update + apt-get install -y python3.12 python3.12-dev python3.12-venv gcc git g++ + update-alternatives --install /usr/bin/python python /usr/bin/python3.12 1 + + # Build in an isolated directory + mkdir /tmp/build + cd /tmp/build + git config --global --add safe.directory /greenlet/.git + git clone /greenlet greenlet + cd greenlet + + python -m venv /tmp/venv + . /tmp/venv/bin/activate + echo "Python" + python --version + + python -mpip install -U pip + python -mpip install -U setuptools wheel + python -mpip wheel -v --wheel-dir ./dist . + python -mpip install -U .[test] + python -m unittest discover -v greenlet.tests + + exit 0 +fi + +# Mount the current directory as /greenlet +docker run --rm --platform linux/riscv64 -v "$(pwd):/greenlet" ${DOCKER_IMAGE:-riscv64/ubuntu:latest} /greenlet/$(basename $0)