Skip to content

Add RiscV-64 tests; fix the crash #444

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Apr 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ include LICENSE.PSF
include MANIFEST.in

include make-manylinux
include ubuntu-test

global-exclude *.pyc
global-exclude *.pyd
Expand Down
6 changes: 1 addition & 5 deletions src/greenlet/platform/switch_riscv_unix.h
Original file line number Diff line number Diff line change
Expand Up @@ -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) : );
Expand Down
47 changes: 47 additions & 0 deletions ubuntu-test
Original file line number Diff line number Diff line change
@@ -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)