Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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_toolchainneeds 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-prebuiltuses@zig_sdk//libc_aware/toolchain:linux_arm64_muslfor arm64 builds. To replicate the existing logic as much as possible, my goal is to also add musl support for rv64. Overall, adding support forriscv64_with_muslwent quite smoothly. The environment used byzstd-prebuiltis precisely a cross-compilation environment.I understand that for
hermetic_cc_toolchain, adding support forriscv64_with_glibcwould also be very meaningful. I attempted this, but the results were not satisfactory. As mentioned above, zig 0.12.0 has issues withriscv64_with_glibcunder cross-compilation.3. Current state of riscv64 testing
For
zstd-prebuilt, I can successfully useriscv64_with_muslto complete the build. The CI shows everything went smoothly - see details In My Fork for zstd-prebuilt. This means thathermetic_cc_toolchaincan provide good support forriscv64_with_musl.As for running
hermetic_cc_toolchainon rv64 (non-cross-compilation), since support forriscv64_with_glibccannot 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];