I wished there was a Linux distro that allowed me to simply install the Rust versions over the unsafe ones.
Much easier to see what breaks in practice, instead of trying to chase 100% bug compatibility.
This looks like a cool tool, but I would hesitate to call any llvm based jit “safe” in the rust sense of the word.
author here, I just want to echo this sentiment, but point out some subtleties.
There’s some unsafe code in the runtime, and then all of the JIT code (particularly LLVM) should really be considered unsafe.
By default, however, frawk is using Cranelift to JIT the code. Cranelift is a pure-rust project, so I’d expect it to be safer to use than LLVM. Still, JITs like the one in frawk are going to be inherently unsafe. Even Cranelift is providing you with a low-level builder API that doesn’t check the generated code is memory-safe, so running that generated code is still unsafe (both in the Rust sense, but also in the colloquial sense I’d say).
Even if it’s just compiling in a single back end for LLVM, there is vastly more unsafe C++ code in the ‘safe’ Rust version than in a typical C++ implementation of awk.
Eh, how much unsafe c++ code do you think there is in llvm?
Around 10MLoC. Nothing in LLVM uses the .at (bounds checked) accessors instead of operator (not bounds checked) for example. Nothing in LLVM is safe in the Rust sense of the word. Most of the unsafe things are hidden in classes like SmallIntPtrPair, which hides an integer in the low bits of a pointer (would require unsafe in Rust), but there are a lot of abstractions in LLVM that are built on things that would not be permitted in safe Rust.
Did you see this recent story? https://lobste.rs/s/jdqu4m/debian_running_on_rust_coreutils
In NixOS you can do this. Technically, on any Linux distro “enriched” with Nix you could do it.