Skip to content

support riscv64 builds#214

Merged
WyattBlue merged 2 commits intoPyAV-Org:mainfrom
threexc:tgamblin/riscv64
Mar 16, 2026
Merged

support riscv64 builds#214
WyattBlue merged 2 commits intoPyAV-Org:mainfrom
threexc:tgamblin/riscv64

Conversation

@threexc
Copy link
Contributor

@threexc threexc commented Mar 9, 2026

This makes the changes necessary to support riscv64 builds in pyav-ffmpeg. The work here is being done with the goal of supporting video_reader-rs using pyav-ffmpeg in its CI, which in turn is of interest to the RISE Project.

Note that there's a patch labeled revertme which reduces the test matrix down to just riscv64 for testing purposes.

I started by testing this on my fork: threexc#1

What I found there is that the manylinux build succeeds once cuda and amf are also disabled for riscv64, but musllinux is a different story. I looked to see what version of musl the musllinux_1_2 image includes:

tgamblin@megalith ~ $ docker run --rm --platform linux/riscv64 quay.io/pypa/musllinux_1_2_riscv64:2026.03.01-1 sh -c "apk info musl"
WARNING: opening from cache https://dl-cdn.alpinelinux.org/alpine/v3.22/main: No such file or directory
WARNING: opening from cache https://dl-cdn.alpinelinux.org/alpine/v3.22/community: No such file or directory
musl-1.2.5-r10 description:
the musl c library (libc) implementation

musl-1.2.5-r10 webpage:
https://musl.libc.org/

musl-1.2.5-r10 installed size:
598 KiB

Seems that the missing header (stdbit.h) is a C23 addition

I guess we'd need to wait for musl to support it, and then for a new musllinux_1_2 image to be built?

Alternatively, it looks like there's a compatibility layer for it in ffmpeg, which we could try to use.

@WyattBlue
Copy link
Member

x265 and cmake patches should be in a separate PR since it benefits all builds.

@threexc
Copy link
Contributor Author

threexc commented Mar 13, 2026

Looks like the musllinux build failed on a bad hash for the x265 tarball, which also happened to me once when I was working on the cmake/x265 PR. A retrigger should be enough...

Disable cuda and amf for this mode (like arm64) since they don't seem to
support riscv64 yet.

Signed-off-by: Trevor Gamblin <tgamblin@baylibre.com>
@threexc
Copy link
Contributor Author

threexc commented Mar 16, 2026

It's just the riscv64 musllinux build that is failing. Let me see if I can figure that out.

The real issue with musl builds seems to be:

|  src/libavutil/riscv/cpu.c:43:24: error: use of undeclared identifier '__NR_riscv_hwprobe'; did you mean '__riscv_hwprobe'?
|     43 |         return syscall(__NR_riscv_hwprobe, pairs, pair_count, cpu_count, cpus,
|        |                        ^~~~~~~~~~~~~~~~~~
|        |                        __riscv_hwprobe
|  src/libavutil/riscv/cpu.c:39:12: note: '__riscv_hwprobe' declared here

but in the musllinux image, that's defined in unistd_32.h and/or
unistd_64.h:

|tgamblin@megalith ~/workspace/git/ffmpeg (master)$ docker run --rm --platform linux/riscv64 quay.io/pypa/musllinux_1_2_riscv64:2026.03.01-1 sh -c "grep -r 'riscv_hwprobe' /usr/include/"
|/usr/include/asm/hwprobe.h:struct riscv_hwprobe {
|/usr/include/asm/unistd_32.h:#define __NR_riscv_hwprobe 258
|/usr/include/asm/unistd_64.h:#define __NR_riscv_hwprobe 258

Tweak the existing ffmpeg.patch file to also include asm/unistd.h in
libavutil/riscv/cpu.c.

Signed-off-by: Trevor Gamblin <tgamblin@baylibre.com>
@threexc
Copy link
Contributor Author

threexc commented Mar 16, 2026

@WyattBlue what do you think?

@WyattBlue WyattBlue merged commit 50b84b4 into PyAV-Org:main Mar 16, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants