Is Rust-Lang depending on LLVM?

Hello,
Is below sentence true?
Before Rust can replace C or C++ it would, itself need to be fairly rewritten to get away from a dependency on LLVM which is entirely written in C and C++.

Thank you.

I don't know if I'd use the word "rewritten" but it's true that LLVM is currently the most commonly used code generator for the Rust compiler. There are however already experimental alternative code generators such as cranelift.

2 Likes

There's an ongoing effort within the compiler team to integrate cranelift into the rustc.

The cranelift is a code generator originally developed to translate wasm into machine code. It's a lot faster than LLVM to generate machine code, though produced code usually is less performant. The plan is to enable cranelift for the debug build for faster iteration during development.

9 Likes

That sentence assumes "replace C" means completely exterminating it from the planet, which isn't a realistic goal. C doesn't need to be totally eradicated for Rust to succeed.

In practice Rust is a viable replacement for C right now, and offers tangible benefits despite using C in its implementation itself.

You can use Rust for new programs, you don't have to rewrite all old programs first for it to count.

33 Likes

Before C or C++ can replace Fortran it would, itself need to be fairly rewritten to get away from a dependency on libm which is written in Fortran.

15 Likes

Yes. And No. Depends on what one means by "replace".

Pretty much all of the big name, most popular, languages today, from Java to Visual Basic with many in between, have arguably "replaced" C/C++ for the crafting of code in many application domains. But they depend on C/C++ for their very existence. Their compilers are written in C/CC++, their run times are written in C/C++, a lot of the libraries they use are written in C/C++.

Why would one expect more from Rust?

On the other hand, code generated from Rust source can totally replace that generated by C/C++ in imbedded systems. Or even in creating new operating systems, like Redox.

I don't think of Rust vs C/C++ in terms of one replacing the other. Why not think of a symbiosis between Rust and C/C++ rather than one species try to exterminate another? A far more productive approach. And C/C++ is not going away in any imaginable future time span.

Having said that I would love to see a self hosted Rust compiler and tool chain. All the way down to the operating system. I would love to see a Rust front end for GCC. But that is all idle dreaming I can do little to contribute to, apart from using it and reporting bugs if it ever happens.

All in all the quote we are asked to comment on is a bit daft.

libm which is written in Fortran

To be fair, a lot of libms are written in C. I don't disagree with your point that this is largely irrelevant though.

1 Like

You'd probably be interested in this, then:

That is a backend, not a frontend

(a rustc backend using GCC to generate code, that is)

1 Like

If GCC was the backend, then Rust would be the frontend right? Which would make "a Rust fron end for GCC", which is what @ZiCog said, right?

Normally that means implementing a Rust frontend in GCC

Ah, I guess that could be different.

Creating an independent rust front-end for gcc is certainly planned as well: