Live data from Hacker News

GCC Rust: GCC Front-End for Rust

github.com

21–30 of 179 posts

Re: GCC Rust: GCC Front-End for Rust

#21
post #7

Earlier quoted context omitted.

As far as I can tell, this is written in C++ like the rest of GCC, so they don't need a rust compiler to bootstrap.

I see, so it’s written in C++. Would it remain that way, though? AFAIK the LLVM Rust is, itself, written in Rust, right? I imagine that it would be a goal to do the same for gcc.

[deleted]

Re: GCC Rust: GCC Front-End for Rust

#22

Earlier quoted context omitted.

I see, so it’s written in C++. Would it remain that way, though? AFAIK the LLVM Rust is, itself, written in Rust, right? I imagine that it would be a goal to do the same for gcc.

There is absolutely no reason why the GCC front-end needs to be written in Rust. The reason the LLVM front-end was written in Rust initially was so they could immediately test and use new features in what was at the time also the largest program in Rust. Re-writing the GCC front-end in Rust would just prolong an already rather unfortunate bootstrap problem with the language and it should be strongly discouraged. As i…

> There is absolutely no reason why the GCC front-end needs to be written in Rust.

How about memory safety and fearless concurrency?

Re: GCC Rust: GCC Front-End for Rust

#23

Is a great deal of actual Rust behavior not fairly intimately tied to LLVM ? As far as I know it leaks various LLVM details and much of the documentation about various functions documents them as being little more than a thin wrapper to various LLVM internals.

I'd find that very surprising and interesting - I can't imagine which semantics could leak from LLVM into a language specification. Can you give some examples?

Re: GCC Rust: GCC Front-End for Rust

#24

Is a great deal of actual Rust behavior not fairly intimately tied to LLVM ? As far as I know it leaks various LLVM details and much of the documentation about various functions documents them as being little more than a thin wrapper to various LLVM internals.

I don't think much of the stable functionality exposes llvm internals. Part of stabilizing is removing the llvm leaks into the language.

Re: GCC Rust: GCC Front-End for Rust

#25

What I really hope is that the Rust community doesn’t go out of its way to make this easier. Communicate and let value come back but there’s an significant amount of value in keeping a single backend relies on. CPython has done the Python community a lot of good by keeping one official compiler/tool chain (despite the great work done by projects like JPython/PyPy). The only way to do this properly, if desirable, is t…

>> The only way to do this properly, if desirable, is to make GCC an official backend of the main frontend. That will defocus some progress that happens with LLVM (every feature has to be implemented on both backends) and can make dev lives hard (eg “oh this problem comes up with GCC so use the LLVM backend “)

No. The correct way is to create a Rust language specification that describes what the correct behavior is.

Then whether LLVM, GCC, or something else is used does not matter. There won't be one implementation with defacto behavior, there will be multiple implementations that follow the spec.

This is the way mature languages work.

Re: GCC Rust: GCC Front-End for Rust

#26

Earlier quoted context omitted.

There is absolutely no reason why the GCC front-end needs to be written in Rust. The reason the LLVM front-end was written in Rust initially was so they could immediately test and use new features in what was at the time also the largest program in Rust. Re-writing the GCC front-end in Rust would just prolong an already rather unfortunate bootstrap problem with the language and it should be strongly discouraged. As i…

> There is absolutely no reason why the GCC front-end needs to be written in Rust. How about memory safety and fearless concurrency?

Not a requirement for a GCC front-end and certainly not worth sacrificing a potentially faster path to bootstrapping the official compiler implementation. You should be worried about the ease by which various systems can bootstrap and adopt the language, which is a mostly solved problem for C/C++ but not a given for Rust itself. Some maintainers will absolutely refuse bootstrapping off of binary artifacts compiled from other systems, others won't even accept 'compiled to C' artifacts.

Keeping a viable C++ implementation as part of GCC would be the smartest decision.

Re: GCC Rust: GCC Front-End for Rust

#28
post #15

This is excellent; there's embedded targets that LLVM doesn't officially support and GCC does.

GCC is straight up faster in quite a few benchmarks (it's basically neck and neck in most benchmarks, and you should try both if it matters).

GCC is also roughly even in compilation speed now https://www.phoronix.com/scan.php?page=news_item&px=GCC-Fast...

LLVM is much easier to work with internally but GCC is a seriously good compiler even now.

Re: GCC Rust: GCC Front-End for Rust

#29

Is a great deal of actual Rust behavior not fairly intimately tied to LLVM ? As far as I know it leaks various LLVM details and much of the documentation about various functions documents them as being little more than a thin wrapper to various LLVM internals.

I'd find that very surprising and interesting - I can't imagine which semantics could leak from LLVM into a language specification. Can you give some examples?

For instance `std::ptr::offset` which is apparently a trivial wrapper around some LLVM internal: https://llvm.org/docs/LangRef.html#getelementptr-instruction

I'm not sure as to what capacity GCC has a similar instruction but I heard that LLVM's using of signed integers here is apparently nonstandard and what lead to Rust's decisions for vectors to be limited to a certain size: https://doc.rust-lang.org/nomicon/vec-alloc.html

Re: GCC Rust: GCC Front-End for Rust

#30

What I really hope is that the Rust community doesn’t go out of its way to make this easier. Communicate and let value come back but there’s an significant amount of value in keeping a single backend relies on. CPython has done the Python community a lot of good by keeping one official compiler/tool chain (despite the great work done by projects like JPython/PyPy). The only way to do this properly, if desirable, is t…

Strongly disagree. It will only benefit the language to have more than one quality implementation. C++ has benefited hugely by the competition between g++ and clang; both compilers have gotten much, much better. To be fair, it will take a while before the GCC Rust front end is competitive, but for some purposes it doesn't have to be, like bootstrapping.

If "progress" means "rapidly add more and more new features in each release", multiple implementations will slow things down. But that problem can be addressed with editions: at some point, if the project is a success, the gcc front end will be a feature-complete version of some Rust edition, plus enough extra features to build an older version of the Rust compiler. At that point, you have a better solution to the bootstrapping problem (how to get a Rust compiler when you only have a C compiler and you want to build everything from source and not trust some binary you download from somewhere).

Post reply on HN