News for hackers. Stuff that matters.
Re:GCC Rust Approved by GCC Steering Committee by pca006132 on Monday July 11, 2022 @11:30AM (#32057434)
Indeed, but I think they should first create a standard?
Re:GCC Rust Approved by GCC Steering Committee by rob74 on Monday July 11, 2022 @11:43AM (#32057648)
If not a standard, then at least a specification. This discussion is from 2020, so I'm not sure if it's still up to date:

https://users.rust-lang.org/t/where-is-the-rust-language-spe...

"For the most part though, rustc itself is the spec" - so, for implementing the GCC frontend, read the current LLVM frontend really carefully and do everything the same way? And try to keep up with all the changes which will inevitably happen in the LLVM frontend while you are implementing the GCC frontend?

Re:GCC Rust Approved by GCC Steering Committee by steveklabnik on Monday July 11, 2022 @01:16PM (#32058878)
> so, for implementing the GCC frontend, read the current LLVM frontend really carefully and do everything the same way?

At a high level, this is correct: https://github.com/Rust-GCC/gccrs/wiki/Frequently-Asked-Ques...

> If gccrs interprets a program differently from rustc, this is considered a bug.

I don't believe they are only reading the frontend, but using the reference first, then looking to the implementation second, and asking a lot of questions along the way.

Re:GCC Rust Approved by GCC Steering Committee by b3morales on Monday July 11, 2022 @12:00PM (#32057894)
Integration-style tests are a good tool here. Given a set of programs in the target language with certain expected behavior on the reference compiler, you check that compiling and running with the second compiler produces the same behavior.
Re:GCC Rust Approved by GCC Steering Committee by pornel on Monday July 11, 2022 @11:46AM (#32057681)
There are various reference documents for Rust, but how do you know if they're complete and accurate without creating a working interoperable implementation?

ISO will stamp any fantasy like OOXML, but that doesn't mean the standard is useful.

Re:GCC Rust Approved by GCC Steering Committee by int_19h on Monday July 11, 2022 @02:20PM (#32059727)
Having another implementation first actually helps create a good standard, by highlighting things that are implementation-specific assumptions.
Re:GCC Rust Approved by GCC Steering Committee by Alghranokk on Monday July 11, 2022 @11:45AM (#32057669)
Rust already has stable standards. There's Rust editions 2015 (1.0), 2018 (1.31.0), and 2021 (1.56.0).
Re:GCC Rust Approved by GCC Steering Committee by wging on Monday July 11, 2022 @12:41PM (#32058469)
Unfortunately that's not quite the same thing as a standard in the sense that is meant here. A 'standard' is a written document that explains how the language should work. A standard that just says "the compiler is correct if it compiles code the way that rustc 1.xy does" is technically unambiguous in that it provides a procedure by which a compiler author can check their work, but leaves quite a bit on the table and is probably the wrong goal to aim at in the long term, even if it enables forward progress for now. (For example, we know rustc contains bugs; do we want gcc-rust to include all the bugs, or should it differ from rustc in that respect? Which behaviors are bugs, which are undesired but accepted quirks of the language, and which are intentional? For that matter, it's unreasonable to expect gcc-rust to produce binaries that are byte-for-byte identical, so what other mechanism should be used to determine equivalence?)

(btw, there's also https://doc.rust-lang.org/reference/)

Re:GCC Rust Approved by GCC Steering Committee by thesuperbigfrog on Monday July 11, 2022 @02:23PM (#32059761)
Correct.

With an ideal standard document that describes the language, someone could build a compiler for the language from scratch and it should behave correctly. See https://en.wikipedia.org/wiki/Programming_language_specifica...

Some example standards:

C: https://www.open-std.org/jtc1/sc22/wg14/

ECMAScript (Javascript): https://tc39.es/ecma262/

C++: https://isocpp.org/std/the-standard

Scheme: https://schemers.org/Documents/Standards/

Ada: http://www.ada-auth.org/standards/ada12_w_tc1.html

For Rust, Ferrous Systems is working on the Ferrocene Language Specification to formally document the Rust subset that Ferrocene will use.

https://ferrous-systems.com/blog/ferrocene-language-specific...

https://ferrous-systems.com/ferrocene/