<story><title>Progress toward a GCC-based Rust compiler</title><url>https://lwn.net/SubscriberLink/954787/41470c731eda02a4/</url></story><parent_chain><item><author>ndiddy</author><text>Having another Rust implementation allows for an &amp;quot;audit&amp;quot; to help validate the Rust spec and get rid of any unspecified behavior. It would also give users options. If I hit a compiler bug in MSVC, I can file a report, switch to GCC and keep working on my project until the bug is fixed. With Rust, that&amp;#x27;s not currently possible.</text></item><item><author>vlovich123</author><text>The claims in the article feel kinda weak as to the motivation.&lt;p&gt;&amp;gt; Cohen&amp;#x27;s EuroRust talk highlighted that one of the major reasons gccrs is being developed is to be able to take advantage of GCC&amp;#x27;s security plugins. There is a wide range of existing GCC plugins that can aid in debugging, static analysis, or hardening; these work on the GCC intermediate representation&lt;p&gt;&amp;gt; One more reason for gccrs to exist is Rust for Linux, the initiative to add Rust support to the Linux kernel. Cohen said the Linux kernel is a key motivator for the project because there are a lot of kernel people who would prefer the kernel to be compiled only by the GNU toolchain.&lt;p&gt;That explains why you’d want GCC as the backend but not why you need a duplicate front end. I think it’s a bad idea to have multiple front ends and Rust should learn from the mistakes of C++ which even with a standards body has to deal with a mess of switches, differing levels of language support for each compiler making cross-platform development harder, platform-specific language bugs etc etc.&lt;p&gt;&amp;gt; A lot of care is being put into gccrs not becoming a &amp;quot;superset&amp;quot; of Rust, as Cohen put it. The project wants to make sure that it does not create a special &amp;quot;GNU Rust&amp;quot; language, but is trying instead to replicate the output of rustc — bugs, quirks, and all. Both the Rust and GCC test suites are being used to accomplish this.&lt;p&gt;In other words, I’d love gccrs folks to explain why their approach is a better one than rustc_codegen_gcc considering the latter is able to achieve this with far less effort and risk.</text></item></parent_chain><comment><author>nindalf</author><text>Your sentiment is a commonly expressed one, but not usually by people who have adopted Rust. It’s usually Clang&amp;#x2F;MSVC&amp;#x2F;GCC users who have decided this is the optimal flow and want to replicate it in all future codebases they work in, regardless of language.&lt;p&gt;In reality if you hit a compiler bug in Rust or Go (or any other language with one main impl like Python, Ruby…) you would file a report and do one of two things - downgrade the compiler (if it’s an option) or write the code a different way. Compiler bugs in these languages are rare enough that this approach works well.&lt;p&gt;That said, for people who are really keen on a spec, there is one being worked on (&lt;a href=&quot;https:&amp;#x2F;&amp;#x2F;blog.rust-lang.org&amp;#x2F;inside-rust&amp;#x2F;2023&amp;#x2F;11&amp;#x2F;15&amp;#x2F;spec-vision.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;https:&amp;#x2F;&amp;#x2F;blog.rust-lang.org&amp;#x2F;inside-rust&amp;#x2F;2023&amp;#x2F;11&amp;#x2F;15&amp;#x2F;spec-visio...&lt;/a&gt;).&lt;p&gt;But this GCCRS effort doesn’t get you any closer to your ideal C&amp;#x2F;C++ style workflow because they are committing to matching the semantics of the main compiler exactly. Bugs and all. And that’s the way it should be.&lt;p&gt;The Rust ecosystem becomes worse if I have to install a different toolchain and learn a different build system with a different compiler for every new project I interact with. And after all that extra effort it turns out there are subtle differences between implementations. My developer experience is just worse at that point. If I wanted to code like this, I would code in C++ but I don’t.</text></comment>
<story><title>Progress toward a GCC-based Rust compiler</title><url>https://lwn.net/SubscriberLink/954787/41470c731eda02a4/</url></story><parent_chain><item><author>ndiddy</author><text>Having another Rust implementation allows for an &amp;quot;audit&amp;quot; to help validate the Rust spec and get rid of any unspecified behavior. It would also give users options. If I hit a compiler bug in MSVC, I can file a report, switch to GCC and keep working on my project until the bug is fixed. With Rust, that&amp;#x27;s not currently possible.</text></item><item><author>vlovich123</author><text>The claims in the article feel kinda weak as to the motivation.&lt;p&gt;&amp;gt; Cohen&amp;#x27;s EuroRust talk highlighted that one of the major reasons gccrs is being developed is to be able to take advantage of GCC&amp;#x27;s security plugins. There is a wide range of existing GCC plugins that can aid in debugging, static analysis, or hardening; these work on the GCC intermediate representation&lt;p&gt;&amp;gt; One more reason for gccrs to exist is Rust for Linux, the initiative to add Rust support to the Linux kernel. Cohen said the Linux kernel is a key motivator for the project because there are a lot of kernel people who would prefer the kernel to be compiled only by the GNU toolchain.&lt;p&gt;That explains why you’d want GCC as the backend but not why you need a duplicate front end. I think it’s a bad idea to have multiple front ends and Rust should learn from the mistakes of C++ which even with a standards body has to deal with a mess of switches, differing levels of language support for each compiler making cross-platform development harder, platform-specific language bugs etc etc.&lt;p&gt;&amp;gt; A lot of care is being put into gccrs not becoming a &amp;quot;superset&amp;quot; of Rust, as Cohen put it. The project wants to make sure that it does not create a special &amp;quot;GNU Rust&amp;quot; language, but is trying instead to replicate the output of rustc — bugs, quirks, and all. Both the Rust and GCC test suites are being used to accomplish this.&lt;p&gt;In other words, I’d love gccrs folks to explain why their approach is a better one than rustc_codegen_gcc considering the latter is able to achieve this with far less effort and risk.</text></item></parent_chain><comment><author>VBprogrammer</author><text>I don&amp;#x27;t have a lot of experience in C or C++ but I wonder if this ever works in practice for a non-trivial codebase? I&amp;#x27;d be really surprised if, without diligently committing to maintaining compatibility with the two compilers, it was easy to up sticks and move between them.</text></comment>