Skip to content

Conversation

@ffgan
Copy link

@ffgan ffgan commented Dec 18, 2025

Hi there.

Recently, riscv64 (rv64) has gained widespread adoption, and I'm very interested in rv64 as well. Recently, I am trying to add rv64 support to zstd-prebuilt, and found that hermetic_cc_toolchain needs to add rv64 support first, which led to this PR.

Adding rv64 support to the current repository is not an easy task. As mentioned in the README, I'm also quite confused about configuring toolchains in Bazel. However, overall, I successfully completed adding rv64 support to zstd-prebuilt. Below is a detailed introduction.

1. Zig's support for rv64

In version 0.12.0, zig does have support for rv64, but only for musl. For glibc, there's an issue in cross-compilation environments that's basically consistent with what's reported in this issue. Upgrading to zig 0.14.0 would solve this problem, but the 0.12.0 -> 0.14.0 transition involves some breaking changes that would require too many modifications. Taking everything into consideration, this PR will not upgrade zig for now.

2. Only adding support for riscv64_with_musl

zstd-prebuilt uses @zig_sdk//libc_aware/toolchain:linux_arm64_musl for arm64 builds. To replicate the existing logic as much as possible, my goal is to also add musl support for rv64. Overall, adding support for riscv64_with_musl went quite smoothly. The environment used by zstd-prebuilt is precisely a cross-compilation environment.

I understand that for hermetic_cc_toolchain, adding support for riscv64_with_glibc would also be very meaningful. I attempted this, but the results were not satisfactory. As mentioned above, zig 0.12.0 has issues with riscv64_with_glibc under cross-compilation.

3. Current state of riscv64 testing

For zstd-prebuilt, I can successfully use riscv64_with_musl to complete the build. The CI shows everything went smoothly - see details In My Fork for zstd-prebuilt. This means that hermetic_cc_toolchain can provide good support for riscv64_with_musl.

As for running hermetic_cc_toolchain on rv64 (non-cross-compilation), since support for riscv64_with_glibc cannot be added, builds and tests that use glibc cannot run. However, for //test/glibc_hacks/..., I tested it and it can execute smoothly.

4. Summary

In fact, I'm still confused about configuring related toolchains in Bazel to this day. So if you're equally confused about the above content, please feel free to @ me. I'll do my best to answer 😭😭


Other Info
Co-authored by: [email protected];

Co-authored by: [email protected];

Signed-off-by: ffgan <[email protected]>
@CLAassistant
Copy link

CLAassistant commented Dec 18, 2025

CLA assistant check
All committers have signed the CLA.

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