4 ms·
FWIW mrustc, the existing state of the art non-rust rust compiler, already doesn’t have a borrow checker. Removing the borrow checker doesn’t break any correct
by School-Cotton 2y ago
FWIW mrustc, the existing state of the art non-rust rust compiler, already doesn’t have a borrow checker.
Removing the borrow checker doesn’t break any correct programs — it just makes it so a huge amount of incorrect programs can be compiled. This is fine, since we mainly want to use mrustc to compile rustc, and we already know rustc can compile itself with no borrow checker errors.
- mikepurvis 2y agoAnd once you have yourself bootstrapped, you can presumably turn around and compile the compiler again, now with borrow-checking and optimizations. In the very special case of proto-rust bootstrapping, the cost of not having borrow-checking can be paid back basically right away.
- 1vuio0pswjnm7 2y ago"Removing the borrow checker doesn't break any correct programs - it just makes it so a huge amount of incorrect programs can be compiled." Not a user of Rust programs myself but am curious how users determine whether a Rust binary was compiled with mrustc or rustc.
- School-Cotton 2y agoYou can assume that unless you have some specific information to the contrary, any Rust binary you encounter in real life was built with rustc. mrustc is not used for any mainstream purpose other than in the bootstrap chain of rustc in distros like Guix that care about reproducibility, and even then, the build of rustc they distribute to users will be re-built from the bootstrapped rustc, it won’t be one compiled by mrustc directly.
- 1vuio0pswjnm7 2y agoHypothetical: A computer program is distributed in binary form with the description "written in Rust" or some similar indication it is a Rust binary. A computer user who neither compiles their own programs nor reads source code downloads and runs the program under the belief that because the program is "written in Rust" it offers memory safety. Unbeknownst to the computer user, the program has been compiled without memory safety.
- School-Cotton 2y agoThat belief would be erroneous regardless of what compiler you used, because rust unsafe lets you do anything, including cause memory unsafety and other UB, even when using rustc. Rust isn’t any kind of guarantee for end-users that some class of bugs doesn’t exist. It’s just a tool for programmers to make writing a certain class of bugs more difficult. If the programmer chooses to subvert the tool, they can. (Also, I think most reasonable people would feel you were lying if you referred to a program that can’t be compiled by rustc as “written in rust”. Maybe “written in a dialect of rust” would be more accurate. Rust isn’t like C where there is a standard that multiple competing implementations target; the definition of rust is "what rustc accepts".)
- kpcyrd 2y agoIf you want certainty you'd use Reproducible Builds and know for sure which compiler generates this binary from the given source code. This assumes the code is open source, you know which specific source code release was used and the author of the binary is making an effort to document the build environment that was used, e.g. through an attached SBOM.
- astrodust 2y agoIt's an interesting point of flex here: Your compiler doesn't have to be feature complete, it just has to be able to build a more feature complete binary.
- mcronce 2y agoIt is interesting. A subset of functionally (in this case) will build a superset of programs