Live data from Hacker News

Rust compiler walk-through – Introduction

gchp.ie

11–15 of 15 posts

Re: Rust compiler walk-through – Introduction

#12
post #2

Does any one know if there is a plan for a GCC Rust Frontend?

There are two nascent alternative Rust compiler projects that I know of. One is https://github.com/thepowersgang/mrustc , which does not aim to be a GCC or LLVM front-end, and seems aimed at bootstrapping rust on platforms with only C/C++ support. The author of this alt compiler says they're able to parse and typecheck libcore (the small OS independent part of the standard library). They are working on codegen so the…

I mean, I'm guessing here, but wouldn't simplest way be starting mid-way in the existing Rust compiler to port an intermediate language to GCC? Straight-up compile it to GCC C or whatever GCC does internally. That way, you get the parsing, analysis, etc for free plus any improvements they make. Lots of other languages used this approach.

Re: Rust compiler walk-through – Introduction

#13

Wow, that's a lot of passes in the compiler. Seems to do most pretty fast. I look forward to reading this series. Especially, how they handle safety stuff worth porting to other languages.

Yeah! I was surprised by the amount. When I read things now about compiler speed, I'm looking through a different lens now that I have an idea of the sheer amount of work it's doing. Pretty impressive.

Re: Rust compiler walk-through – Introduction

#14

Earlier quoted context omitted.

There are two nascent alternative Rust compiler projects that I know of. One is https://github.com/thepowersgang/mrustc , which does not aim to be a GCC or LLVM front-end, and seems aimed at bootstrapping rust on platforms with only C/C++ support. The author of this alt compiler says they're able to parse and typecheck libcore (the small OS independent part of the standard library). They are working on codegen so the…

I mean, I'm guessing here, but wouldn't simplest way be starting mid-way in the existing Rust compiler to port an intermediate language to GCC? Straight-up compile it to GCC C or whatever GCC does internally. That way, you get the parsing, analysis, etc for free plus any improvements they make. Lots of other languages used this approach.

I'm pretty sure mrustc isn't targeting GCC as a backend, but I'm not sure.

I don't know what approach is being taken by the person working on a GCC backend, but it's entirely possible what you've described is what they're doing.

Re: Rust compiler walk-through – Introduction

#15

Earlier quoted context omitted.

I mean, I'm guessing here, but wouldn't simplest way be starting mid-way in the existing Rust compiler to port an intermediate language to GCC? Straight-up compile it to GCC C or whatever GCC does internally. That way, you get the parsing, analysis, etc for free plus any improvements they make. Lots of other languages used this approach.

I'm pretty sure mrustc isn't targeting GCC as a backend, but I'm not sure. I don't know what approach is being taken by the person working on a GCC backend, but it's entirely possible what you've described is what they're doing.

> I'm pretty sure mrustc isn't targeting GCC as a backend, but I'm not sure.

I'm pretty sure your statement is somewhat paradoxical :)

Post reply on HN