Skip to content

Commit cd7bb59

Browse files
luhenryriseproject-dev[bot]
authored andcommitted
pyroscope-io: add the riscv64 py-spy patches for 1.3.0 and 1.4.0
Each version pins a different py-spy revision (ad722cc, 44736d9) and has no [features] section left in rust/Cargo.toml, so the Cargo patch is rebased per version; the py-spy patch applies unchanged at both.
1 parent 7c46cc9 commit cd7bb59

4 files changed

Lines changed: 176 additions & 0 deletions
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2+
From: Ludovic Henry <git@ludovic.dev>
3+
Date: Sat, 10 Oct 2026 07:57:26 +0000
4+
Subject: [PATCH] cargo: build py-spy from a locally patched checkout
5+
6+
py-spy does not compile for riscv64: pyruntime::get_tstate_current_offset
7+
is defined once per architecture and riscv64 matches none of the arms, so
8+
the build fails with
9+
10+
error[E0425]: cannot find function `get_tstate_current_offset` in module `pyruntime`
11+
12+
py-spy is pulled in as a git dependency pinned to a revision, so the fix
13+
cannot be applied in place. Redirect the git source to a checkout of that
14+
same revision carrying the one-line riscv64 addition, see
15+
0002-python_bindings-return-no-tstate_current-offset-on-riscv64.patch.
16+
17+
Only the source line of the py-spy entry changes in Cargo.lock, so every
18+
other dependency stays pinned exactly as upstream released it and the
19+
build keeps running with --locked.
20+
21+
Upstream-Status: Inappropriate [redirects a pinned dependency to a local checkout; the fix itself belongs in py-spy]
22+
23+
Signed-off-by: Ludovic Henry <git@ludovic.dev>
24+
---
25+
rust/Cargo.lock | 1 -
26+
rust/Cargo.toml | 3 +++
27+
2 files changed, 3 insertions(+), 1 deletion(-)
28+
29+
diff --git a/rust/Cargo.lock b/rust/Cargo.lock
30+
index 111e9f2..6ac561f 100644
31+
--- a/rust/Cargo.lock
32+
+++ b/rust/Cargo.lock
33+
@@ -1180,7 +1180,6 @@ dependencies = [
34+
[[package]]
35+
name = "py-spy"
36+
version = "0.4.2"
37+
-source = "git+https://github.com/grafana/pyroscope-py-spy?rev=ad722cc#ad722cce3599f3ee8072be59b2661974170b8721"
38+
dependencies = [
39+
"anyhow",
40+
"chrono",
41+
diff --git a/rust/Cargo.toml b/rust/Cargo.toml
42+
index 883de47..a23032e 100644
43+
--- a/rust/Cargo.toml
44+
+++ b/rust/Cargo.toml
45+
@@ -28,3 +28,6 @@ pyo3 = { version = "0.29.0", features = ["extension-module"] }
46+
47+
[build-dependencies]
48+
cmake = "0.1"
49+
+
50+
+[patch."https://github.com/grafana/pyroscope-py-spy"]
51+
+py-spy = { path = "../py-spy" }
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2+
From: Ludovic Henry <git@ludovic.dev>
3+
Date: Thu, 27 Aug 2026 00:00:00 +0000
4+
Subject: [PATCH] python_bindings: return no tstate_current offset on riscv64
5+
6+
Applied to the py-spy checkout that pyroscope-python pins as a git
7+
dependency.
8+
9+
pyruntime::get_tstate_current_offset has one definition per architecture
10+
and riscv64 matches none of them, so any riscv64 build of py-spy fails to
11+
compile:
12+
13+
error[E0425]: cannot find function `get_tstate_current_offset` in module `pyruntime`
14+
15+
Add riscv64 to the arm that returns None, the same answer powerpc, powerpc64
16+
and mips give. The offset is only consulted for CPython 3.7 to 3.11, where
17+
the caller already handles None by reporting an unknown offset; 3.12 and
18+
later read the GIL through a struct offset instead.
19+
20+
Upstream-Status: To upstream [targets the py-spy dependency rather than pyroscope-python; not yet submitted to benfred/py-spy]
21+
22+
Signed-off-by: Ludovic Henry <git@ludovic.dev>
23+
---
24+
diff --git a/src/python_bindings/mod.rs b/src/python_bindings/mod.rs
25+
index 772e4de..df9e4cb 100644
26+
--- a/src/python_bindings/mod.rs
27+
+++ b/src/python_bindings/mod.rs
28+
@@ -195,7 +195,8 @@ pub mod pyruntime {
29+
any(
30+
target_arch = "powerpc64",
31+
target_arch = "powerpc",
32+
- target_arch = "mips"
33+
+ target_arch = "mips",
34+
+ target_arch = "riscv64"
35+
)
36+
))]
37+
pub fn get_tstate_current_offset(version: &Version) -> Option<usize> {
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2+
From: Ludovic Henry <git@ludovic.dev>
3+
Date: Sat, 10 Oct 2026 07:57:26 +0000
4+
Subject: [PATCH] cargo: build py-spy from a locally patched checkout
5+
6+
py-spy does not compile for riscv64: pyruntime::get_tstate_current_offset
7+
is defined once per architecture and riscv64 matches none of the arms, so
8+
the build fails with
9+
10+
error[E0425]: cannot find function `get_tstate_current_offset` in module `pyruntime`
11+
12+
py-spy is pulled in as a git dependency pinned to a revision, so the fix
13+
cannot be applied in place. Redirect the git source to a checkout of that
14+
same revision carrying the one-line riscv64 addition, see
15+
0002-python_bindings-return-no-tstate_current-offset-on-riscv64.patch.
16+
17+
Only the source line of the py-spy entry changes in Cargo.lock, so every
18+
other dependency stays pinned exactly as upstream released it and the
19+
build keeps running with --locked.
20+
21+
Upstream-Status: Inappropriate [redirects a pinned dependency to a local checkout; the fix itself belongs in py-spy]
22+
23+
Signed-off-by: Ludovic Henry <git@ludovic.dev>
24+
---
25+
rust/Cargo.lock | 1 -
26+
rust/Cargo.toml | 3 +++
27+
2 files changed, 3 insertions(+), 1 deletion(-)
28+
29+
diff --git a/rust/Cargo.lock b/rust/Cargo.lock
30+
index 10c2d0b..3f6a646 100644
31+
--- a/rust/Cargo.lock
32+
+++ b/rust/Cargo.lock
33+
@@ -1182,7 +1182,6 @@ dependencies = [
34+
[[package]]
35+
name = "py-spy"
36+
version = "0.4.2"
37+
-source = "git+https://github.com/grafana/pyroscope-py-spy?rev=44736d9#44736d9a6fa69f29cd067790e11637018952de61"
38+
dependencies = [
39+
"anyhow",
40+
"chrono",
41+
diff --git a/rust/Cargo.toml b/rust/Cargo.toml
42+
index d7ca23b..4f61bef 100644
43+
--- a/rust/Cargo.toml
44+
+++ b/rust/Cargo.toml
45+
@@ -28,3 +28,6 @@ pyo3 = { version = "0.30.1", features = ["extension-module"] }
46+
47+
[build-dependencies]
48+
cmake = "0.1"
49+
+
50+
+[patch."https://github.com/grafana/pyroscope-py-spy"]
51+
+py-spy = { path = "../py-spy" }
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2+
From: Ludovic Henry <git@ludovic.dev>
3+
Date: Thu, 27 Aug 2026 00:00:00 +0000
4+
Subject: [PATCH] python_bindings: return no tstate_current offset on riscv64
5+
6+
Applied to the py-spy checkout that pyroscope-python pins as a git
7+
dependency.
8+
9+
pyruntime::get_tstate_current_offset has one definition per architecture
10+
and riscv64 matches none of them, so any riscv64 build of py-spy fails to
11+
compile:
12+
13+
error[E0425]: cannot find function `get_tstate_current_offset` in module `pyruntime`
14+
15+
Add riscv64 to the arm that returns None, the same answer powerpc, powerpc64
16+
and mips give. The offset is only consulted for CPython 3.7 to 3.11, where
17+
the caller already handles None by reporting an unknown offset; 3.12 and
18+
later read the GIL through a struct offset instead.
19+
20+
Upstream-Status: To upstream [targets the py-spy dependency rather than pyroscope-python; not yet submitted to benfred/py-spy]
21+
22+
Signed-off-by: Ludovic Henry <git@ludovic.dev>
23+
---
24+
diff --git a/src/python_bindings/mod.rs b/src/python_bindings/mod.rs
25+
index 772e4de..df9e4cb 100644
26+
--- a/src/python_bindings/mod.rs
27+
+++ b/src/python_bindings/mod.rs
28+
@@ -195,7 +195,8 @@ pub mod pyruntime {
29+
any(
30+
target_arch = "powerpc64",
31+
target_arch = "powerpc",
32+
- target_arch = "mips"
33+
+ target_arch = "mips",
34+
+ target_arch = "riscv64"
35+
)
36+
))]
37+
pub fn get_tstate_current_offset(version: &Version) -> Option<usize> {

0 commit comments

Comments
 (0)