Discussion:
[rust-dev] Rust compiler for Risc-v
Wink Saville
2014-09-22 16:46:33 UTC
Permalink
I'm interested in writing deeply embedded low level Rust code for risc-v (
http://riscv.org/) that thus don't expect to need a significant runtime
library. As such I expect to use #![no_std] and #![no_start].

Anyway, there is a risc-v "llvm compiler" (
http://riscv.org/download.html#tab_llvm) and it appears that rustc is an
"llvm compiler".

It seems with both being llvm I should be able to connect the Rust's llvm
"frontend" to the risc-v "backend" and thus be able to generate Rust code
for risc-v.

Would love to know if Rust compiler people would think this is reasonably
easy and if so what general guidance on how to do it.

-- Wink
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/rust-dev/attachments/20140922/1fe17a38/attachment.html>
Ilya Dmitrichenko
2014-09-22 18:31:46 UTC
Permalink
Hi Wink,

I would be interested to help with RISC-V port. In terms of slim runtime
and other non-OS aspects, have you looked at Zinc yet?

Cheers,
--
Ilya
Post by Wink Saville
I'm interested in writing deeply embedded low level Rust code for risc-v (
http://riscv.org/) that thus don't expect to need a significant runtime
library. As such I expect to use #![no_std] and #![no_start].
Anyway, there is a risc-v "llvm compiler" (
http://riscv.org/download.html#tab_llvm) and it appears that rustc is an
"llvm compiler".
It seems with both being llvm I should be able to connect the Rust's llvm
"frontend" to the risc-v "backend" and thus be able to generate Rust code
for risc-v.
Would love to know if Rust compiler people would think this is reasonably
easy and if so what general guidance on how to do it.
-- Wink
_______________________________________________
Rust-dev mailing list
Rust-dev at mozilla.org
https://mail.mozilla.org/listinfo/rust-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/rust-dev/attachments/20140922/a5c4ba10/attachment.html>
Wink Saville
2014-09-23 01:30:33 UTC
Permalink
Thanks for the heads up on Zinc <http://zink.rs>, looks to be originally
announced on this list here
<https://mail.mozilla.org/pipermail/rust-dev/2014-April/009618.html> and
its github page is here <https://github.com/hackndev/zinc>. So I happy to
see someone else is interested in rust on riscv. I know nothing about llvm
so I hope we'll see some advice from some knowledgable people to give us
some guidance.

But if nothing is forth coming, I suggest we start with the following tasks:

1. Get sources for both Rust and Risc-v compilers and build them locally
validating both "work".
2. Create one github project with both sources in two different source
trees and again validate both "work"
3. Learn how LLVM frontend/backends communicate
4. Work to combine the Rust Frontend with the Risc-v backend
5. Iterate over 3 and 4 until we have a working Rust compiler for Risc-V

A first question is where is the current compilers. On the main github rust
page <https://github.com/rust-lang>
there is a link to rust-lang/llvm <https://github.com/rust-lang/llvm>, but
that link seems to point to something that
was last updated in April 2014. Instead if you go to rust-lang/rust/src
<https://github.com/rust-lang/rust/tree/master/src> and then click
on the submodule "llvm @ e9d0374
<https://github.com/rust-lang/llvm/tree/e9d037419441d51ccb0f41aacbc64080b0c6e81b>"
you're at a commit that was 23 days ago.
So for Rust it looks like we should clone the rust-lang/rust
<https://github.com/rust-lang/rust>.

On the main githug riscv page <https://github.com/ucb-bar> there is a link
to riscv-llvm. <https://github.com/ucb-bar/riscv-llvm> with the last commit
from August 19, so that probably good.

We could start with one of us getting Rust working and the other getting
Risc-v,
which would you like to do or maybe you have a different suggestion on how
to proceed?

-- Wink
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/rust-dev/attachments/20140922/f6fcb5a1/attachment.html>
Wink Saville
2014-09-23 14:25:11 UTC
Permalink
So after some more research, maybe we can use "rustc --emit=ir" or
--emit=bc and then feed the output file to "llc" in the riscv compiler tool
chain.
Post by Wink Saville
Thanks for the heads up on Zinc <http://zink.rs>, looks to be originally
announced on this list here
<https://mail.mozilla.org/pipermail/rust-dev/2014-April/009618.html> and
its github page is here <https://github.com/hackndev/zinc>. So I happy
to see someone else is interested in rust on riscv. I know nothing about
llvm so I hope we'll see some advice from some knowledgable people to give
us some guidance.
1. Get sources for both Rust and Risc-v compilers and build them locally
validating both "work".
2. Create one github project with both sources in two different source
trees and again validate both "work"
3. Learn how LLVM frontend/backends communicate
4. Work to combine the Rust Frontend with the Risc-v backend
5. Iterate over 3 and 4 until we have a working Rust compiler for Risc-V
A first question is where is the current compilers. On the main github
rust page <https://github.com/rust-lang>
there is a link to rust-lang/llvm <https://github.com/rust-lang/llvm>, but
that link seems to point to something that
was last updated in April 2014. Instead if you go to rust-lang/rust/src
<https://github.com/rust-lang/rust/tree/master/src> and then click
<https://github.com/rust-lang/llvm/tree/e9d037419441d51ccb0f41aacbc64080b0c6e81b>"
you're at a commit that was 23 days ago.
So for Rust it looks like we should clone the rust-lang/rust
<https://github.com/rust-lang/rust>.
On the main githug riscv page <https://github.com/ucb-bar> there is a
link to riscv-llvm. <https://github.com/ucb-bar/riscv-llvm> with the last
commit
from August 19, so that probably good.
We could start with one of us getting Rust working and the other getting
Risc-v,
which would you like to do or maybe you have a different suggestion on how
to proceed?
-- Wink
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/rust-dev/attachments/20140923/ff2c66e2/attachment.html>
Loading...