@@ -238,3 +238,58 @@ requirements. More specifically, check:
238238If either point is not met, we should follow the [ Patching a
239239Project] ( #patching-a-project ) process for patching our build, and submit an
240240issue and/or PR upstream to help them comply with license requirements as well.
241+
242+ ### Adding Builds for Rust Packages
243+
244+ Modules which are cross-compiled from Rust to Python typically use
245+ [ maturin] ( https://www.maturin.rs/ ) . This greatly simplifies building binary
246+ wheels for riscv64, but there is a pitfall here to watch out for - many projects
247+ use a matrix definition looking like:
248+
249+ ```
250+ matrix:
251+ platform:
252+ - runner: ubuntu-22.04
253+ target: x86_64
254+ - runner: ubuntu-22.04
255+ target: x86
256+ - runner: ubuntu-22.04
257+ target: aarch64
258+ - runner: ubuntu-22.04
259+ target: armv7
260+ - runner: ubuntu-22.04
261+ target: ppc64le
262+ ```
263+
264+ For riscv64 and some other architectures, the ` rustc ` toolchain target name does
265+ not follow this simple pattern (i.e. the ` arch ` part of the triple is not exact):
266+
267+ ```
268+ tgamblin@alchemist ~/workspace/baylibre/rise/python-wheels (tgamblin/dev-guide)$ rustup target list | grep riscv64
269+ riscv64a23-unknown-linux-gnu
270+ riscv64gc-unknown-linux-gnu
271+ riscv64gc-unknown-linux-musl
272+ riscv64gc-unknown-none-elf
273+ riscv64imac-unknown-none-elf
274+ ```
275+
276+ Simply adding a new line with ` target: riscv64 ` will lead to build failures. The
277+ recommended approach here is to make the matrix more explicit, then add riscv64,
278+ so that each entry looks like:
279+
280+ ```
281+ - runner: ubuntu-24.04-riscv
282+ target: riscv64gc-unknown-linux-gnu
283+ arch: riscv64
284+ ```
285+
286+ Note that doing so typically requires a tweak to an ` Upload wheels ` step or
287+ similar, so that it uses the ` arch ` field:
288+
289+ ```
290+ - name: Upload wheels
291+ uses: actions/upload-artifact@v4
292+ with:
293+ name: wheels-linux-${{ matrix.platform.arch }}
294+ path: dist
295+ ```
0 commit comments