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

riscv32ima support #1905

Closed
DieracDelta opened this issue Jun 20, 2019 · 6 comments
Closed

riscv32ima support #1905

DieracDelta opened this issue Jun 20, 2019 · 6 comments

Comments

@DieracDelta
Copy link

I'm trying to compile some rust to an elf with riscv32ima. This target isn't available in rustup, currently. Is there any easy way to add this as a target with rustup? Or generate c or asm that I could compile using gcc?

@tesuji
Copy link
Contributor

tesuji commented Jun 21, 2019

According to https://forge.rust-lang.org/platform-support.html, the riscv32imac-unknown-none-elf
target is in tier 2. It is bare-metal microcontrollers target that only has access to the core library, not std.
Rustup depends on std so I don't think we could run rustup on that target.

@kinnison
Copy link
Contributor

While we cannot provide rustup for that target right now, I think @DieracDelta is asking about installing the target so that they can compile Rust code for it. Unfortunately if the target is not being published into the channels there's nothing rustup can do to assist you in installing it. You would do best to try and talk to the compilers team and ask them what needs to be done to improve the target enough that it'd be regularly available on the stable channel.

In the meantime, have you tried a nightly toolchain to see if that has the target in it? I think it might.

$ rustup toolchain install nightly
$ rustup target add --toolchain nightly riscv32imac-unknown-none-elf
$ cargo build --target=riscv32imac-unknown-none-elf
...

@DieracDelta
Copy link
Author

DieracDelta commented Jun 21, 2019

Yes, I've been using the riscv32imac-unknown-none-elf target for a while now, and it's been fantastic. I just want to disable the compressed extension (c in imac), and was hoping either there was an easy way to do this with rustup, or that it was a feature that already existed but just needed to be integrated in.

@kinnison By compilers team, do you mean I should bring this up with rustc, or llvm?

@kinnison
Copy link
Contributor

I'd suggest rust-lang/rust since the targets built into Rust come from them. I hadn't realised the difference between ima and imac :D

@DieracDelta
Copy link
Author

DieracDelta commented Jun 23, 2019

It turns out this is relatively straightforward to do (a testament to how nice rust tooling is). For future reference: it was as simple as copying over the json generated from running rustc +nightly -Z unstable-options --print target-spec-json --target riscv32ima-unknown-none-elf, removing "+c" from the features list, storing this in the root directory as riscv32ima-unknown-none-elf, with the Cargo.toml, and building with xargo (and specifying the absolute file path to the json as the target).

@kinnison
Copy link
Contributor

Okay thank you for the information in case someone else comes across this. Good luck.

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

3 participants