-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support riscv64gc-unknown-linux-gnu target #62117
Comments
I can try building it but I won't be able to test it on real hardware. EDIT: Failed with |
I added new target AFAK Debian has strict packaging policy and packages must use system libraries. |
This is already fixed in LLVM upstream master, but not released. At the moment I'm trying to grab some commits from master to fix this for |
Seems that Rust moved to LLVM 9.0.0 which has support for riscv64 (not experimental anymore). Thus targeting Linux should be possible now. |
Great progress! Does that mean it's possible to compile rust code for the hard-float (lp64d) ABI? Will the |
@sanxiyn Thanks! Yes, I only mentioned it in this context because the existing gcc Linux riscv64gc target uses hardfloat, at least on Fedora Linux RISC-V, so it seems it's a requirement. |
Matching what I mentioned in #65024, it is now at least possible to write a |
See #66661. In the meantime you can use https://github.com/msizanoen1/rust-riscv. |
Also the RISC-V backend in LLVM 9.0 is even stable enough to compile rustc. |
RISC-V support has landed in libc master, waiting on a new libc release. |
Compiling rustc for riscv64 also needs this: rust-lang/llvm-project#29 |
I have successfully compiled rustc using the combined patches:
Binaries for anyone wants to try on real hardware/emulator: https://github.com/msizanoen1/rust-binaries/releases/tag/riscv |
Testing this for Debian's rustc now. Thanks for all the work! List of PRs backported to 1.40.0:
|
One last thing, for cross-compiling support we need to add this to the cc crate:
otherwise the build fails with:
I will file a PR to the cc crate shortly. |
After also adding in additional to the patches above, I now have some Debian rustc riscv64 packages:
|
@msizanoen1 did you try cargo? It builds but then the tests fail for us, due to some rustc ICEs (
|
@msizanoen1 no worries, that one was on QEMU, we tried again on real riscv64 hardware and it worked OK including tests. Looks like everything works! |
Does this mean we get the official support starting 1.41.0 release? |
@davidlt definitely not sooner than 1.42. |
If you have Debian Unstable on riscv64 you should be able to |
These packages fail to build only on riscv64. They look fixable to someone familiar with how riscv64 should work. We also had segfaults in gtk-sys, proptest, and data-encoding-macro on actual riscv64 hardware, I've mentioned this to the Debian riscv64 people. Bear in mind this is riscv64 patches backported to rustc 1.40.0, so there is a small chance I might have missed something, but several hundred other rust crates built OK & some even ran their tests successfully. |
rust-nodrop-union seems to just require the unions_with_drop_fields feature (the compiler warns that it doesn't recognize the feature name, and then errors out saying that unions can't have drop fields). Was it added very recently? A few others also seem to just be version disagreements about what constants and such can be imported. |
I'm unaware if there are any specific instructions but you can add extra foreign architectures to the |
@msizanoen1 1.41 is failing in Debian because of
|
Never mind, this was just because we dropped rust-lang/cc-rs#460 by mistake when doing an update. |
What is blocking this issue? |
rustup support is pending a built risc-v toolchain: rust-lang/rustup#2296 (comment) |
@tommythorn platforms need tier 2 support for officially released binaries to be built for rustup. The rules or tier 2 support are such that there must be a team of developers willing to maintain that architecture. I volunteer for that role, but I'm no team on my own, and I'm lacking in expertise. Would anybody else be interested? |
Are there available reasonably priced RISC-V boards capable to run full Linux distro and Rust? |
Why would you need real hardware? Considering that most software development is run and tested with qemu and with the current state of affairs are far easier to use that the available (expensive) hardware solutions. Running Ubuntu 20.04 is this easy:
provided you have a sufficiently new QEMU installed. |
@tommythorn I've hard hard time testing specific app on AArch64 (this one was confirmed as QEMU bug) and RISC-V QEMU few months ago. Since then I usually prefer to work with real hardware. |
@mati865 we're currently working on designing a fully open-source SoC with OpenPower/RISC-V/GPU hybrid processors, once they come out there should be inexpensive raspberry pi-like boards available (guessing around $25), you should be able to do all the needed testing/development on them (except for supervisor mode -- that's Power-only though emulation should be possible). We're getting the first engineering sample chips in october! |
You want to test on QEMU and real physical hardware (e.g. SiFive HiFive Unleashed, https://www.crowdsupply.com/sifive/hifive-unleashed , sadly not more available). QEMU 4.2.0 had FP bug that caused issues in Linux (e.g. SSH wouldn't work properly) and FU540 SoC in Unleahed have TLB flush errata. TLB flush issue was fixed recently (few months ago?) in OpenSBI (one of firmware components). For example this TLB flush errata caused Golang bootstrap segfaults. I highly advice to test QEMU and physical hardware as bugs could exist in both. Most of distributions are built with QEMU VMs or/and a mix of VMs and Unleashed boards. I high end PC/workstation with high clocks would most likely outperform Unleashed board. You can go up to 8 cores on QEMU which helps. All major distributions (Fedora, Debian, SUSE and now even Ubuntu) have something available in one form or another. |
413: Add riscv64gc-unknown-linux-gnu support r=reitermarkus a=tblah rust support for riscv64gc-unknown-linux-gnu [is not yet advertised](https://forge.rust-lang.org/release/platform-support.html), but [is merged](rust-lang/rust#66661). There are [issues](rust-lang/rust#62117) with riscv64gc-unknown-linux-gnu but it works well enough to build many crates (including rustc). Co-authored-by: Tom Eccles <tom.eccles@codethink.co.uk>
In case anybody missed it, |
I have merged stable support for this platform in our CI. If everything goes well, 1.22 will quietly release with riscv support, though I'll need @tblah to test it during the prerelease sequence :D |
@kinnison what is 1.22? |
@tshepang The next |
Has anyone tried a native build, compiling rustc on riscv64 without cross-compiling? Our builds still consistently fail for various different reasons, but occasionally succeed on real hardware - rv-mullvad-*, rv-rr44-*, are HiFive; whereas rr-mit-* are QEMU. |
From https://www.codethink.co.uk/articles/2020/fixing-rusts-test-suite-on-risc-v (by @tblah):
And from the build logs for 1.43:
So a way to ensure that the test suite runs successfully is to upgrade rustc to a version that supports LLVM 10 and upgrade the LLVM version used in rustc in Debian to LLVM 10. |
For version 1.44 in experimental:
And:
|
@infinity0 Version 1.47 (current nightly) and later is guaranteed to build as RISC-V GNU/Linux 64-bit has been added to CI: #72973 |
@infinity0 From the logs above for |
@msizanoen1 Thanks for taking a look, I am in the process of updating to 1.45 with LLVM 10 in Debian. The crossbeam issue was caused by #74803 and appeared on all architectures, however an earlier error in that log that is riscv64-specific is for libcore:
exit-status 11 looks like maybe a segfault, I haven't been able to look into it in more detail yet. edit: most likely a segfault, #74832 makes it a bit obscure. |
@infinity0 sorry for taking so long to get back to you. I wanted to at least reproduce the issue and come back with something concrete but I am having some trouble.
Edit: I've reproduced the problem on rust a99ae95 (with minor alterations) with LLVM 10 and normal versions of all dependencies. Thanks for reporting the issue @infinity0 |
@tblah how did you reproduce it? It seems the upgrade to LLVM 10 made things work for us now, we have green builds (native riscv64->riscv64 build) for 1.45.0 and 1.46.0 beta. |
@infinity0
I will try 1.46.0 |
very surprised to have rust work in my riscv computer flawlessly, thank you |
It was recently pointed out that Rust is one of the main blockers for the Debian RISC-V port. I wanted to ask what is actually missing on the Rust side? Since there is already support for the equivalent bare metal targets, is it simply a matter of porting the standard library? How much work would that actually be?
The text was updated successfully, but these errors were encountered: