Celina G. Val

@celinaval

Joined on Mar 21, 2022

  • StableMIR is being developed to become the public interface of the Rust compiler to analysis tools that can be developed outside of the Rust main repository. It is intended to be more stable than the internal APIs, and to follow semantic versioning. For that, the goal is to start publishing a stable_mir crate on crates.io, which can be explicitly selected by tool developers. This document proposes what the first releases will look like, as well as how development will be done in the Rust compiler in between version releases. Context In our first development phase of StableMIR, we focused on adding enough coverage for static analyzers tools to use in order to interpret a Rust program. For that, we added two crates to the Rust compiler, stable_mir and rustc_smir, the first is a shallow shell that implements the public APIs while the second implements the interface between public APIs and the compiler internal APIs, including translation. Because of that, the rustc_smir crate depends on the stable_mir crate.
     Like  Bookmark
  • Note: The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in RFC 2119. Introduction Many static analysis tools rely on the internals of the rust compiler to be able to efficiently analyze programs that were written in Rust. Most tools analyze the mid-level IR (MIR) together with rustc's type system. The MIR is a much simpler language when compared to Rust, but much richer than LLVM's IR. In order to do that today, these tools use rustc's internal APIs to extend the compiler. These mechanisms only work for nightly toolchain distributions, and the API changes very often, which makes maintenance very costly. Another issue is that the semantics of the MIR is not well documented, which can potentially impact the result of these analysis. The goal of the Stable MIR project is to provide a stable interface to the Rust compiler that allow tool developers to develop sophisticated analysis with a reduced maintenance cost without compromising the compiler development speed.
     Like  Bookmark