From d894f609dbacd6d66aaff0402cab60a59901f73e Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Tue, 24 Jan 2017 21:43:53 -0500 Subject: oxidation: Add implementation of bupsplit in Rust This is an initial drop of "oxidation", or adding implementation of components in Rust. The bupsplit code is a good target - no dependencies, just computation. Translation into Rust had a few twists - - The C code relies a lot on overflowing unsigned ints, and also on the C promotion rules for e.g. `uint8_t -> int32_t` - There were some odd loops that I introduced bugs in while translating...in particular, the function always returns `len`, but I mistakenly translated to `len+1`, resulting in an OOB read on the C side, which was hard to debug. On the plus side, an off-by-one array indexing in the Rust code paniced nicely. In practice, we'll need a lot more build infrastructure to make this work, such as using `cargo vendor` when producing build artifacts for example. Also, Cargo is yet another thing we need to cache. Where do we go with this? Well, I think we should merge this, it's not a lot of code. We can just have it be an alternative CI target. Should we do a lot more right now? Probably not immediately, but I find the medium/long term prospects pretty exciting! Closes: #656 Approved by: jlebon --- rust/Cargo.toml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 rust/Cargo.toml (limited to 'rust/Cargo.toml') diff --git a/rust/Cargo.toml b/rust/Cargo.toml new file mode 100644 index 00000000..4da5ac32 --- /dev/null +++ b/rust/Cargo.toml @@ -0,0 +1,16 @@ +[package] +name = "bupsplit" +version = "0.0.1" +authors = ["Colin Walters "] + +[dependencies] +libc = "0.2" + +[lib] +name = "bupsplit_rs" +path = "src/bupsplit.rs" +crate-type = ["staticlib"] + +[profile.release] +panic = "abort" +lto = true -- cgit v1.2.1