Describe the problem you are trying to solve
rustup is wonderful, so it's sad it doesn't support RISC-V, I get "rustup: unknown CPU type: riscv64" which run on Ubuntu 20.04 (which has rustc, cargo, etc).
Describe the solution you'd like
I'd like it to install the latest Rust
Notes
I used the Ubuntu image from https://github.com/carlosedp/riscv-bringup to issue the commands. I assume this is actually blocked on something on rust side, but I didn't see any issues tracking this.
One could investigate and add risv cpu type to https://github.com/rust-lang/rustup/blob/c022b922b1653e069fe9c19a224b4dfbec65fa60/rustup-init.sh#L228-L296
Hmm, tried the obvious
--- rustup.sh.org 2020-04-01 17:52:18.571954138 +0000
+++ rustup.sh 2020-04-01 17:34:57.396790022 +0000
@@ -226,6 +226,9 @@
esac
case "$_cputype" in
+ riscv64)
+ _cputype=riscv64
+ ;;
i386 | i486 | i686 | i786 | x86)
_cputype=i686
but assuming this follows the convention, the failure is
rustup: command failed: downloader https://static.rust-lang.org/rustup/dist/riscv64-unknown-linux-gnu/rustup-init /tmp/tmp.jnFi5770CM/rustup-init
What is the full target triple of riscv?
Does riscv has std? rustup depends on std.
Acording to https://forge.rust-lang.org/release/platform-support.html, riscv is bare metal
only.
tommy@Ubuntu-riscv64:~$ rustc --print target-list|grep riscv
riscv32i-unknown-none-elf
riscv32imac-unknown-none-elf
riscv32imc-unknown-none-elf
riscv64gc-unknown-linux-gnu
riscv64gc-unknown-none-elf
riscv64imac-unknown-none-elf
Changing the _cputype=riscv64gc I get
info: downloading installer
curl: (22) The requested URL returned error: 404
rustup: command failed: downloader https://static.rust-lang.org/rustup/dist/riscv64gc-unknown-linux-gnu/rustup-init /tmp/tmp.PxoInJ2fwo/rustup-init
There are multiple things at play here.
rustup-init.sh needs to know about riscvrustup itself needs to be taught because otherwise it can't recognise it for toolchains (targets are a different matter)rust-lang/rust needs to publish dockers for building targetting riscvrust-lang/rust needs to publish a riscv toolchain, not just a stdrustup including riscv linuxIf people are serious about assisting with this, then perhaps we might put together a checklist and get it underway; though without support from the main rust-lang/rust repo for the docker and the compiler releases, there's not a lot we can do beyond preparing for the possiblity in the future.
Thanks, it was exactly a list like this I was hoping to see. Without a published toolchain there's not much point to the rest. IIUC, this is tracked by https://github.com/rust-lang/rust/issues/62117 which I updated to point back here.
I have a WIP PR for this https://github.com/rust-lang/rustup/pull/2313
It isn't useful yet because there aren't official toolchains for a riscv host. However cross-compilation toolchains can be downloaded for a riscv target today (tested using rustup 1.21.1): see https://github.com/rust-embedded/cross/pull/413
The completed riscvgc support was released today. I'd be interested to know if it works for you or not.
Thanks! The script seems to progress on my (fully up-to-date) Ubuntu RISC-V VM. However, it looks like we aren't there yet:
Current installation options:
default host triple: riscv64gc-unknown-linux-gnu
default toolchain: stable (default)
profile: default
modify PATH variable: yes
1) Proceed with installation (default)
2) Customize installation
3) Cancel installation
>1
info: profile set to 'default'
info: default host triple is riscv64gc-unknown-linux-gnu
info: syncing channel updates for 'stable-riscv64gc-unknown-linux-gnu'
info: latest update on 2020-06-18, rust version 1.44.1 (c7087fe00 2020-06-17)
error: target 'riscv64gc-unknown-linux-gnu' not found in channel. Perhaps check https://forge.rust-lang.org/release/platform-support.html for available targets
riscv64gc-unknown-linux-gnu is listed under Tier 2 (does that imply not-stable?).
Taking option 2 and picking nightly didn't help:
Current installation options:
default host triple: riscv64gc-unknown-linux-gnu
default toolchain: nightly
profile: default
modify PATH variable: no
1) Proceed with installation (default)
2) Customize installation
3) Cancel installation
>1
info: profile set to 'default'
info: setting default host triple to riscv64gc-unknown-linux-gnu
info: syncing channel updates for 'nightly-riscv64gc-unknown-linux-gnu'
info: latest update on 2020-07-06, rust version 1.46.0-nightly (2753fab7c 2020-07-05)
error: target 'riscv64gc-unknown-linux-gnu' not found in channel. Perhaps check https://forge.rust-lang.org/release/platform-support.html for available targets
Okay so we're closer but still no cigar. @tblah Is this what you'd expect for now?
Rustup for RISC-V won't work until https://github.com/rust-lang/rust/pull/72973 is merged.
Thanks for that @mati865
@tommythorn currently RISC-V is Tier 2 only for cross compilation. But as @mati865 said that may soon change to full support.
https://github.com/rust-lang/rust/pull/72973 is waiting for https://github.com/rust-lang/compiler-team/issues/312 to be approved. If there are no objections that could happen about 2 days from now.
After that rustup may need changing to point at the CI pipeline introduced in https://github.com/rust-lang/rust/pull/72973
@tblah By 'need changing' do you mean for the CI, or a point release being needed to use it?
@kinnison just CI if I understand correctly.
rust-lang/rust#72973 moves the RISC-V build to a new docker image so rustup needs to use that image too here
I'll make sure to be subscribed to that PR then, though I hope one of the contributors here might get to PRing our CI before me :D
I'm afraid I lost track of where this is at.
I can see that rust-lang/rust#72973 was merged, https://github.com/rust-lang/compiler-team/issues/312 was closed, and riscv64gc-unknown-linux-gnu is AFAICT listed as a supported platform in Tier 2 "riscv64gc-unknown-linux-gnu | ✓ | ✓ | RISC-V Linux (kernel 4.20, glibc 2.29) -- | -- | -- | --"
Launching rustup.sh (from https://sh.rustup.rs) in a Fedora RISC-V QEMU image leads to
...
info: profile set to 'default'
info: default host triple is riscv64gc-unknown-linux-gnu
info: syncing channel updates for 'stable-riscv64gc-unknown-linux-gnu'
info: latest update on 2020-08-27, rust version 1.46.0 (04488afe3 2020-08-24)
error: target 'riscv64gc-unknown-linux-gnu' not found in channel. Perhaps check https://forge.rust-lang.org/release/platform-support.html for available targets
I wasn't immediately able to find out where rustup-init was reading (the manifest? from whence?) and not finding it.
If it is host toolchain, we have to have riscv build for rustup, then wait until next rustup release.
I apologize for my ignorance. I poked around some more and discovered that there are indeed nightly builds for RISC-V and lo and behold rustup.sh --default-toolchain nightly worked, thus as far as I'm concerned this issue can be closed. Thank you!
Ok, no objections. Closing.
Most helpful comment
I apologize for my ignorance. I poked around some more and discovered that there are indeed nightly builds for RISC-V and lo and behold
rustup.sh --default-toolchain nightlyworked, thus as far as I'm concerned this issue can be closed. Thank you!