Skip to content

RISC-V support? #2296

Closed
Closed

Description

@tommythorn

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.

Activity

  1. tesuji commented on Apr 25, 2020

    @tesuji
    Contributor

    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"

  2. tommythorn commented on Apr 25, 2020

    @tommythorn
    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
    
  3. tesuji commented on Apr 25, 2020

    @tesuji
    Contributor

    What is the full target triple of riscv?

  4. tesuji commented on Apr 25, 2020

    @tesuji
    Contributor

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

  5. tommythorn commented on Apr 25, 2020

    @tommythorn
    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.
  6. tommythorn commented on Apr 25, 2020

    @tommythorn
    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
    
  7. kinnison commented on Apr 26, 2020

    @kinnison
    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.

  8. tommythorn commented on Apr 27, 2020

    @tommythorn
    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.

  9. tblah commented on Apr 28, 2020

    @tblah
    Contributor

    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

  10. deleted a comment from on Jun 1, 2020
  11. deleted a comment from tesuji on Jun 1, 2020
  12. kinnison commented on Jul 6, 2020

    @kinnison
    Contributor

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

  13. tommythorn commented on Jul 6, 2020

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

  14. tommythorn commented on Jul 6, 2020

    @tommythorn
    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
    
  15. kinnison commented on Jul 6, 2020

    @kinnison
    Contributor

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

  16. mati865 commented on Jul 6, 2020

    @mati865
    Member

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

  17. kinnison commented on Jul 6, 2020

    @kinnison
    Contributor

    Thanks for that @mati865

  18. tblah commented on Jul 7, 2020

    @tblah
    Contributor

    @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

  19. kinnison commented on Jul 7, 2020

    @kinnison
    Contributor

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

  20. tblah commented on Jul 7, 2020

    @tblah
    Contributor

    @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

  21. kinnison commented on Jul 7, 2020

    @kinnison
    Contributor

    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

  22. tommythorn commented on Sep 29, 2020

    @tommythorn
    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.

  23. tesuji commented on Sep 30, 2020

    @tesuji
    Contributor

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

  24. tommythorn commented on Sep 30, 2020

    @tommythorn
    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!

  25. tommythorn commented on Sep 30, 2020

    @tommythorn
    Author

    Ok, no objections. Closing.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions