Re: [TECH TOPIC] Rust for Linux

Arnd Bergmann
2021-07-07T14:10:49Z

On Tue, Jul 6, 2021 at 8:36 PM Miguel Ojeda
<miguel.ojeda.sandonis@gmail.com> wrote:
>
> On Tue, Jul 6, 2021 at 8:00 PM Linus Walleij <linus.walleij@linaro.org> wrote:
> >
> > I brought this up for discussion with Miguel et al and it turns out
> > the project to develop a GCC front-end for Rust is now well under
> > way and there is already a frankencompiler using LLVM first
> > and then feeding that into GCC IIUC.
>
> By the latter, I think you are referring to `rustc_codegen_gcc` -- in
> that case, a quick note: it does not involve LLVM. `rustc` has its own
> set of IRs which then gets translated into LLVM IR (in the most common
> backend), but in the case of `rustc_codegen_gcc` it gets translated
> into something libgccjit can consume. There is also a third backend in
> the works, called cranelift, for different use cases.
>
> So `rustc_codegen_gcc` is basically a very quick way of supporting the
> entirety of the Rust language (exactly as `rustc` supports it) but
> having a GCC codegen path.

I suppose using this for building kernels is actually easier than doing
an architecture port for user space, because it does not have to
wrap the syscall interface, right?

I've had a quick look at what it would take to integrate this into the prebuilt
toolchains on kernel.org to give developers the chance to try their rust
code across architectures. I've managed to cross-build the patched
gcc sources for rustc_codegen_gcc, but haven't actually figured out how
to build rustc_codegen_gcc itself.

Before I look at this further, can you clarify what the version dependencies
are? I.e. if I want to build this for five gcc versions, 27 target
architectures,
and seven versions of rustc as shipped by the most common distros, can
I do this with a single rustc_codegen_gcc binary, or do I need to build
5*27*7=945 versions of the binary, or something inbetween?

Arnd