Skip to content

Build on riscv64#160

Closed
samuelmarinsoto wants to merge 12 commits intooasislinux:masterfrom
samuelmarinsoto:riscv64
Closed

Build on riscv64#160
samuelmarinsoto wants to merge 12 commits intooasislinux:masterfrom
samuelmarinsoto:riscv64

Conversation

@samuelmarinsoto
Copy link
Copy Markdown
Contributor

@samuelmarinsoto samuelmarinsoto commented May 3, 2026

Built the system using riscv64-linux-musl_rocket-15.2.0 toolchain from skarnet.org, on alpine linux x86_64. all sets build without errors, except ffmpeg which I believe will require more work than I know to do, and mpv which depends on ffmpeg. Originally strace and wpa_supplicant also gave errors, but the recent fixes in master removed them. wpa_supplicant seems to be ok, but strace has an emtpy tree.fspec and root.index for some reason. I have not tested much else yet, I just know it builds.

Edit config.h to disable x86 defs and add a conditional to use edited config.h on riscv64 builds, use regular config.h otherwise.
copy riscv64 headers to include outdir when building for riscv64, and use archdir files for libffi.a
add riscv64 to arches and generated riscv.lua, just like with aarch64 and x86_64. unistd is empty because riscv doesn't have a syscall.tbl, apparantly it doesn't need it.
riscv64 doesn't use assembly files for crti and crtn, so use the c files in the build. generate riscv64.lua as with other arches.
JIT is unsupported in riscv64, disable it in config.h, by using a different config.h on riscv64
Copy link
Copy Markdown
Collaborator

@michaelforney michaelforney left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on this! I pushed the libffi commit, and have just a few comments on the others.

Fun fact, oasis was probably the first musl distribution to run on riscv. Someone reached out to me years ago about running oasis on riscv32sf, so I tried it and ran into a bunch of bugs in the riscv port (hadn't been upstreamed yet). I fixed all those I found, and got it working in temu/jslinux. Looks like it still works:
https://bellard.org/jslinux/vm.html?cpu=riscv64&url=https://mforney.org/virt/oasis-riscv64/temu.cfg

(the root password is oasis)

Comment thread pkg/linux-headers/riscv.lua Outdated
Comment thread pkg/linux-headers/riscv.lua Outdated
Comment thread pkg/dav1d/riscv/config.h Outdated
Comment thread pkg/musl/riscv64.lua Outdated
Comment thread pkg/musl/gen.lua Outdated
Comment thread pkg/pcre/riscv/config.h Outdated
@samuelmarinsoto
Copy link
Copy Markdown
Contributor Author

Thanks so much for the help! I applied the suggestions, and its all building fine :D

add cflags and syscalls to riscv64 build
@samuelmarinsoto
Copy link
Copy Markdown
Contributor Author

samuelmarinsoto commented May 8, 2026

Also I figured out why strace wasn't building, it needed some syscalls and had to enable the build with the cflags and ioctls. No idea why it didn't fail before and instead just continued without building.

@michaelforney
Copy link
Copy Markdown
Collaborator

Applied, thanks!

@samuelmarinsoto samuelmarinsoto deleted the riscv64 branch May 8, 2026 23:39
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