HeadlinesBriefing HeadlinesBriefing.com

Eurydice Compiles Rust to Readable C

Hacker News •
×

A few years ago, the only way to compile Rust code was using the rustc compiler with LLVM as a backend. Since then, several projects, including mrustc, GCC's Rust support (gccrs), rust_codegen_gcc, and Cranelift have diversified Rust's compiler implementations. The most recent project, Eurydice, aims to convert Rust code to clean C code, useful in high-assurance software where verification tools expect C.

Eurydice, started in 2023, is part of the Aeneas project, which develops tools for applying formal verification to Rust code. Maintained by researchers from Inria and Microsoft, Eurydice follows a standard compiler structure: parse Rust, convert to IR, apply passes, and output C.

Unlike other compilers, Eurydice preserves code structure while removing Rust-only constructs. For example, it compiles least common multiple functions to readable C with temporary variables to maintain evaluation order. While not all Rust programs translate faithfully due to generics and iterators, Eurydice offers a smoother transition for environments with C compilers but no Rust support.

The project includes code under MIT and Apache-2.0 licenses and accepts outside contributions.

Source: Hacker News · Summarized by HeadlinesBriefing