Skip to content
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

RISC-V support? #2296

Closed
tommythorn opened this issue Apr 24, 2020 · 23 comments
Closed

RISC-V support? #2296

tommythorn opened this issue Apr 24, 2020 · 23 comments

Comments

@tommythorn
Copy link

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.

@tesuji
Copy link
Contributor

tesuji commented Apr 25, 2020

One could investigate and add risv cpu type to

rustup/rustup-init.sh

Lines 228 to 296 in c022b92

case "$_cputype" in
i386 | i486 | i686 | i786 | x86)
_cputype=i686
;;
xscale | arm)
_cputype=arm
if [ "$_ostype" = "linux-android" ]; then
_ostype=linux-androideabi
fi
;;
armv6l)
_cputype=arm
if [ "$_ostype" = "linux-android" ]; then
_ostype=linux-androideabi
else
_ostype="${_ostype}eabihf"
fi
;;
armv7l | armv8l)
_cputype=armv7
if [ "$_ostype" = "linux-android" ]; then
_ostype=linux-androideabi
else
_ostype="${_ostype}eabihf"
fi
;;
aarch64)
_cputype=aarch64
;;
x86_64 | x86-64 | x64 | amd64)
_cputype=x86_64
;;
mips)
_cputype=$(get_endianness mips '' el)
;;
mips64)
if [ "$_bitness" -eq 64 ]; then
# only n64 ABI is supported for now
_ostype="${_ostype}abi64"
_cputype=$(get_endianness mips64 '' el)
fi
;;
ppc)
_cputype=powerpc
;;
ppc64)
_cputype=powerpc64
;;
ppc64le)
_cputype=powerpc64le
;;
s390x)
_cputype=s390x
;;
*)
err "unknown CPU type: $_cputype"

@tommythorn
Copy link
Author

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

@tesuji
Copy link
Contributor

tesuji commented Apr 25, 2020

What is the full target triple of riscv?

@tesuji
Copy link
Contributor

tesuji commented Apr 25, 2020

Does riscv has std? rustup depends on std.
Acording to https://forge.rust-lang.org/release/platform-support.html, riscv is bare metal
only.

@tommythorn
Copy link
Author

  1. I don't know what the convention calls for but poking around I found:
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
  1. I don't know how Canonical got their riscv rust binaries.

@tommythorn
Copy link
Author

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

@kinnison
Copy link
Contributor

There are multiple things at play here.

  1. rustup-init.sh needs to know about riscv
  2. rustup itself needs to be taught because otherwise it can't recognise it for toolchains (targets are a different matter)
  3. rust-lang/rust needs to publish dockers for building targetting riscv
  4. our CI needs updating to include riscv as a target
  5. rust-lang/rust needs to publish a riscv toolchain, not just a std
  6. and finally we can do a release of rustup including riscv linux

If 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.

@tommythorn
Copy link
Author

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 rust-lang/rust#62117 which I updated to point back here.

@tblah
Copy link
Contributor

tblah commented Apr 28, 2020

I have a WIP PR for this #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 cross-rs/cross#413

@rust-lang rust-lang deleted a comment Jun 1, 2020
@rust-lang rust-lang deleted a comment from tesuji Jun 1, 2020
@kinnison
Copy link
Contributor

kinnison commented Jul 6, 2020

The completed riscvgc support was released today. I'd be interested to know if it works for you or not.

@tommythorn
Copy link
Author

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?).

@tommythorn
Copy link
Author

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

@kinnison
Copy link
Contributor

kinnison commented Jul 6, 2020

Okay so we're closer but still no cigar. @tblah Is this what you'd expect for now?

@mati865
Copy link
Contributor

mati865 commented Jul 6, 2020

Rustup for RISC-V won't work until rust-lang/rust#72973 is merged.

@kinnison
Copy link
Contributor

kinnison commented Jul 6, 2020

Thanks for that @mati865

@tblah
Copy link
Contributor

tblah commented Jul 7, 2020

@tommythorn currently RISC-V is Tier 2 only for cross compilation. But as @mati865 said that may soon change to full support.

rust-lang/rust#72973 is waiting for rust-lang/compiler-team#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 rust-lang/rust#72973

@kinnison
Copy link
Contributor

kinnison commented Jul 7, 2020

@tblah By 'need changing' do you mean for the CI, or a point release being needed to use it?

@tblah
Copy link
Contributor

tblah commented Jul 7, 2020

@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

@kinnison
Copy link
Contributor

kinnison commented Jul 7, 2020

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

@tommythorn
Copy link
Author

I'm afraid I lost track of where this is at.

I can see that rust-lang/rust#72973 was merged, rust-lang/compiler-team#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.

@tesuji
Copy link
Contributor

tesuji commented Sep 30, 2020

If it is host toolchain, we have to have riscv build for rustup, then wait until next rustup release.

@tommythorn
Copy link
Author

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!

@tommythorn
Copy link
Author

Ok, no objections. Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants