Hacker News new | ask | show | jobs
by dtolnay 1333 days ago
I used it with great success for transpiring libyaml from C to Rust. I even set up Miri to run the upstream library's entire transpiled test suite, and the fact it passes is validation of absence of UB in the original C code.

The transpiled library now serves as the YAML backend for the widely used serde_yaml crate. Having serde_yaml be pure-Rust code instead of linking C is advantageous for painless cross-compilation as well as making downstream projects runnable in Miri.

https://github.com/dtolnay/unsafe-libyaml

2 comments

A few questions, if I may:

Is the intent that this continues to evolve by newer libyaml code getting transpiled, or that it's effectively a fork and might gradually become more idiomatic Rust which does the same job as the C but won't track any changes? Or is this basically "done" and only small changes (to both this code and the C libyaml) are anticipated anyway?

The c2rust documentation cautions that any platform independence isn't preserved, so if libyaml has types which are different on platform A versus platform B, the c2rust transpilation on platform A just gives you Rust types for platform A, losing that independence, was this an issue for libyaml ?

Very cool. Miri is seriously awesome.