Skip to content

Commit e6237db

Browse files
authored
Merge pull request #444 from python-greenlet/testing-riscv
Add RiscV-64 tests; fix the crash
2 parents b9e93f1 + d9eba21 commit e6237db

File tree

4 files changed

+69
-6
lines changed

4 files changed

+69
-6
lines changed

.github/workflows/tests.yml

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,27 @@ jobs:
145145
- name: Perform CodeQL Analysis
146146
uses: github/codeql-action/analyze@v3
147147

148-
manylinux:
148+
riscv64:
149+
runs-on: ubuntu-latest
150+
name: RiscV 64
151+
steps:
152+
- name: checkout
153+
uses: actions/checkout@v4
154+
- name: Set up Python
155+
uses: actions/setup-python@v5
156+
with:
157+
python-version: "3.13"
158+
- name: Set up QEMU
159+
uses: docker/setup-qemu-action@v3
160+
with:
161+
platforms: all
162+
- name: Build and test greenlet
163+
env:
164+
DOCKER_IMAGE: riscv64/ubuntu:latest
165+
run: bash ./ubuntu-test
149166

167+
168+
manylinux:
150169
runs-on: ubuntu-latest
151170
# We use a regular Python matrix entry to share as much code as possible.
152171
strategy:

MANIFEST.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ include LICENSE.PSF
5050
include MANIFEST.in
5151

5252
include make-manylinux
53+
include ubuntu-test
5354

5455
global-exclude *.pyc
5556
global-exclude *.pyd

src/greenlet/platform/switch_riscv_unix.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,9 @@ static int
1212
slp_switch(void)
1313
{
1414
int ret;
15-
#if __riscv_xlen == 32
1615
long fp;
1716
long *stackref, stsizediff;
18-
#else
19-
int fp;
20-
int *stackref, stsizediff;
21-
#endif
17+
2218
__asm__ volatile ("" : : : REGS_TO_SAVE);
2319
__asm__ volatile ("mv %0, fp" : "=r" (fp) : );
2420
__asm__ volatile ("mv %0, sp" : "=r" (stackref) : );

ubuntu-test

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#!/bin/bash
2+
3+
# This needs to be run from the root of the project.
4+
5+
set -e
6+
export PYTHONUNBUFFERED=1
7+
export PYTHONDONTWRITEBYTECODE=1
8+
# Use a fixed hash seed for reproducibility
9+
export PYTHONHASHSEED=8675309
10+
export CI=1
11+
export TRAVIS=true
12+
export PIP_NO_WARN_SCRIPT_LOCATION=1
13+
14+
15+
if [ -d /greenlet ]; then
16+
# Running inside docker
17+
export GREENLET_MANYLINUX=1
18+
# Our setup.py overrides this with -Os; be sure it does.
19+
export CFLAGS="-O3 -DNDEBUG -Wall"
20+
21+
apt-get update
22+
apt-get install -y python3.12 python3.12-dev python3.12-venv gcc git g++
23+
update-alternatives --install /usr/bin/python python /usr/bin/python3.12 1
24+
25+
# Build in an isolated directory
26+
mkdir /tmp/build
27+
cd /tmp/build
28+
git config --global --add safe.directory /greenlet/.git
29+
git clone /greenlet greenlet
30+
cd greenlet
31+
32+
python -m venv /tmp/venv
33+
. /tmp/venv/bin/activate
34+
echo "Python"
35+
python --version
36+
37+
python -mpip install -U pip
38+
python -mpip install -U setuptools wheel
39+
python -mpip wheel -v --wheel-dir ./dist .
40+
python -mpip install -U .[test]
41+
python -m unittest discover -v greenlet.tests
42+
43+
exit 0
44+
fi
45+
46+
# Mount the current directory as /greenlet
47+
docker run --rm --platform linux/riscv64 -v "$(pwd):/greenlet" ${DOCKER_IMAGE:-riscv64/ubuntu:latest} /greenlet/$(basename $0)

0 commit comments

Comments
 (0)