Running VLC on RISC-V

The previous article laid the ground for (cross-)building VLC on RISC-V in general and Linux in particular, without needing any actual hardware. The logical next step would be testing in an emulator or simulator.

That being said, VLC only really a C run-time environment. Unlike a boot-loader, a kernel or the run-time linker, VLC can nominally run with (Linux) OS-specific but without any architecture-dependent code. Indeed the bulk of platform-specific code in VLC and dependent libraries such as FFmpeg consists of SIMD optimisations, which are not essential (until you need their performance benefits).

There are of course some architectural dependencies still, but at the C language level, RISC-V is mostly like ARM: they are both RISC instruction sets with little-endian LP64 (or LPI32) types, and no unaligned memory accesses (or rather slow ones). Thus I naively thought that I could skip the emulation and wait for hardware. With the benefits of hindsight, I was of course (surprise surprise) wrong.


Not really but sort of advertising

Open-source multimedia RISC-V development, code review and maintenance in the FFmpeg multimedia framework and the VLC media player are currently almost at a standstill as funding dried up. I cannot realistically keep up entirely in my free time.

To put it bluntly, I need an RISC-V Vector expert to help with FFmpeg code reviews and/or a new sponsor to resume FFmpeg RISC-V work.


Signedness of char

See the problem is, VLC has a test suite (with sadly very poor coverage), which is being run as part of Continuous Integration. But it is only actually checked on Linux x86-64. And there is one not so subtle difference between RISC-V (also ARM) and x86 when it comes to C programming:

So anyway, it turns out that the test suite was broken on RISC-V, and also on ARM, and nobody had noticed. I would only find that out once I ran the test suite on real hardware though.

It works!

Fortunately all is well that ends well still. I got real working hardware:

$ cat /proc/cpuinfo
processor       : 0
hart            : 0
isa             : rv64imafdc
mmu             : sv39
uarch           : sifive,u74-mc

processor       : 1
hart            : 1
isa             : rv64imafdc
mmu             : sv39
uarch           : sifive,u74-mc

...and the problem was fixed within a day, only few weeks later than it otherwise could have been. The VLC test suite now runs succesfully on Linux RISC-V, and more importantly and interestingly, so does VLC itself!