1. 6

    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.

    1. 10

      This looks like a cool tool, but I would hesitate to call any llvm based jit “safe” in the rust sense of the word.

      1. 7

        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).

        1. 4

          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.

          1. 2

            Eh, how much unsafe c++ code do you think there is in llvm?

            1. 3

              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.

        2. 2
          1. 1

            In NixOS you can do this. Technically, on any Linux distro “enriched” with Nix you could do it.