#mir #bindings #jit #compiler

sys mir-sys

FFI bindings to MIR Project (https://github.com/vnmakarov/mir)

1 unstable release

new 0.2.0 Mar 7, 2025
0.1.0+mir.0.1.1 Apr 6, 2022

#940 in Programming languages

24 downloads per month
Used in mir-rs

MIT license

1.5MB
34K SLoC

C 33K SLoC // 0.1% comments Rust 1K SLoC // 0.0% comments

MIR project bindings for Rust

This is the low-level binding that only exposes raw C types and functions, and handles compilation and linking of C code.

See mir-rs crate for high-level ergonomic APIs.

Source

The source code of mir C library is bundled in this package. Since upstream lacks some API/features that are necessary for Rust integration, we use a forked version of mir.

The fork can be seen at this repo, and the current revision is based on upstream version v1.0.0.

⚠️ The API/ABI is NOT compatible with upstream mir library.

Features

⚠️ Warning: Currently, due to lack of support of bindgen, extern functions may still be generated even with corresponding feature disabled. Be careful to avoid using them when disabling features, or you may encounter link errors.

  • default: Implies io, scan, interp, gen.

  • io: De/serialization of MIR memory representation into/from bytes. If disabled, C macro MIR_NO_IO is set for compilation.

    Guarded APIs:

    • MIR_write{,_module}{,_with_func}
    • MIR_read{,_with_func}
  • scan: Parsing of MIR textual representation. If disabled, C macro MIR_NO_SCAN is set for compilation.

    Guarded API:

    • MIR_scan_string
  • interp: Enables MIR interpreter. If disabled, C macro MIR_NO_INTERP is set for compilation.

    Guarded APIs:

    • MIR_interp*
  • gen: MIR native code generator. If disabled, mir-gen.c will not be compiled.

    Guarded APIs:

    • MIR_gen*
    • MIR_set_*_gen_interface
  • gen-debug: Debug logging in MIR native code generator. It implies gen. If disabled, C macro MIR_NO_GEN_DEBUG is set for compilation.

    Guarded APIs:

    • MIR_gen_set_debug_{file,level}
  • assert: Debug assertions. If disabled, C macro NDEBUG is set for compilation. It is implicitly enabled when debug_assertions is on (eg. in dev profile).

Dependencies