c2rust
min-sized-rust
Our great sponsors
c2rust | min-sized-rust | |
---|---|---|
46 | 101 | |
3,631 | 7,301 | |
2.5% | - | |
9.5 | 6.2 | |
10 days ago | 11 days ago | |
Rust | Rust | |
GNU General Public License v3.0 or later | MIT License |
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.
c2rust
-
Converting the Kernel to C++
A recent practical example of the former: the fish shell re-wrote incrementally from C++ to Rust, and is almost finished https://github.com/fish-shell/fish-shell/discussions/10123
An example of the latter: c2rust, which is a work in progress but is very impressive https://github.com/immunant/c2rust
It currently translates into unsafe Rust, but the strategy is to separate the "compile C to unsafe Rust" steps and the "compile unsafe Rust to safe Rust" steps. As I see it, as it makes the overall task simpler, allows for more user freedom, and makes the latter potentially useful even for non-transpiled code. https://immunant.com/blog/2023/03/lifting/
-
Emitting Safer Rust with C2Rust
> The date at the bottom of the article is 2022-06-13. Has there been further progress?
The article links to their github repo:
https://github.com/immunant/c2rust
There's commits in the last hour, so at least some signal of life.
-
Writing an OS in Rust to run on RISC-V
This is arguably already the state of things.
Rust might get compiled down through MIR, down through LLVM IR, down to assembly or wasm... which then might be JIT or AOT (re)compiled into other bytecodes... which might perhaps be decompiled back up to C... and C might be retranslated back to horrific unsafe-spamming Rust by the likes of https://c2rust.com/. We've come full circle!
The main issue is that retranslating high level languages into other high level languages isn't something that there's actually a lot of demand for, especially commercially, especially given the N x M translation matrix going on. So a lot of the projects "stabilize" (get abandoned). And automatically translating between the idioms of those languages gets even nastier in terms of matrix bloat.
Well, you've got stuff like MSIL and JVM bytecodes which are higher level, and preserve more type information, and can be compiled to / decompiled from while still preserving more structure, but they still form competing incompatible ecosystems.
-
Will Carbon Replace C++?
That's the wrong direction. What's needed are intelligent converters which convert less-strict languages to more-strict ones.
Non-intelligent converters just make a mess. Here's c2rust.[1]
Classic C++ to modern C++, plus a compiler flag to lock out all the old unsafe stuff, would be an achievement.
- What would you rewrite in Rust?
-
Red Black Tree in Rust
Well, technically, it's not hard to build such data structures. If you are willing to liberally use raw pointers, UnsafeCell, MaybeUninit and ManuallyDrop, then you can more-or-less write C-equivalent code in unsafe Rust. (there are even transpilers from C to Rust)
-
C2Rust Transpiler
In the chart at [1], this step is represented by a magic wand.
(I wanted to give some examples, but https://c2rust.com/ seems to not be translating today.)
-
Pitchfork: Rack HTTP server for shared-nothing architecture
There are some tools specific to some transformations at least:
-
“Rust is safe” is not some kind of absolute guarantee of code safety
I expect that is because you're not particularly familiar with either LLVM or Rust, considering C can literally be transpiled to Rust.
min-sized-rust
-
The Linux Kernel Prepares for Rust 1.77 Upgrade
This is a good guide on building small Rust binaries: https://github.com/johnthagen/min-sized-rust
This talks about going to extreme lengths on making the smallest Rust binary possible, 400 bytes when it was written, https://darkcoding.net/software/a-very-small-rust-binary-ind...
The thing is, you lose a lot of nice features when you do this, like panic unwinding, debug symbols, stdlib… for kernel and some embedded development it’s definitely important, but for most use cases, does it matter?
-
Making Rust binaries smaller by default
Are you sure? If so then this is awesome news, but I'm a bit confused; the commit in that min-sized-rust repo adding `build-std` to the README was merged in August 2021: https://github.com/johnthagen/min-sized-rust/pull/30
Are you saying that at that point the feature still hadn't "landed in Rust nightly" until recently? If so then what's the difference between a feature just being available in Rust nightly, vs having "landed"?
It's really a shame that Rust includes the stdlib piecemeal in binary form, debug symbols and all, in every resulting binary.
I do love Rust but binary sizes have always annoyed me greatly and I always had this nagging feeling that part of all programmers don't rake Rust seriously because of that. And I actually have witnessed, several times in the last 2-ish years, older-school programmers berate and ignore Rust on that basis alone (so the author is quite right to call this out as a factor).
Looking at the https://github.com/johnthagen/min-sized-rust repo, final binary size of 51 KB when compilation / linking / stripping takes stdlib into account (and not just blindly copy-pasting the 4MB binary blob) is acceptable and much more reasonable. I wouldn't care for further micro-optimizations e.g. going to 20KB or even 5KB (further down the README file).
I also don't use nightly in my Rust work so I guess I'll have to wait several more years. :(
My go to reference when I want to reduce rust binary size is the excellent https://github.com/johnthagen/min-sized-rust, a set of guidelines on how to reduce size with explanations of the consequences
-
Was Rust Worth It?
Rust binaries are by default nowhere close to 500MB. If they are not small enough for you, you can try https://github.com/johnthagen/min-sized-rust. By avoiding the formatting machinery and using `panic_immediate_abort` you can get about the size of C binaries.
- Error on flashing embedded code to stm32f103
-
Shared libraries
This is not quite what you're asking, but it does also address the underlying concern: https://github.com/johnthagen/min-sized-rust
-
Announcing lavagna v2, a collaborative blackboard made with bevy and WebRTC
And what about the binary size? Applying some cheats found in the Unofficial Bevy Cheat Book and in the Minimizing Rust Binary Size article I’ve achieved to fit the whole wasm binary in less than 10M, which become 2.8M when gzip compressed.
-
Which GUI toolkit for Rust today.. few questions...
Rust binaries are so huge because the default settings turn off most size optimizations to reduce compile times. Read through this page.
What are some alternatives?
smartstring - Compact inlined strings for Rust.
rustc_codegen_gcc - libgccjit AOT codegen for rustc
Cargo - The Rust package manager
embedded-graphics - A no_std graphics library for embedded applications
subsurface - This is the official upstream of the Subsurface divelog program
regex - An implementation of regular expressions for Rust. This implementation uses finite automata and guarantees linear time matching on all inputs.
tiny-rust-executable - Using Rust to make a 137-byte static AMD64 Linux executable
librope - UTF-8 rope library for C
checkedc - Checked C is an extension to C that lets programmers write C code that is guaranteed by the compiler to be type-safe. The goal is to let people easily make their existing C code type-safe and eliminate entire classes of errors. Checked C does not address use-after-free errors. This repo has a wiki for Checked C, sample code, the specification, and test code.
zz - 🍺🐙 ZetZ a zymbolic verifier and tranzpiler to bare metal C [Moved to: https://github.com/zetzit/zz]
openQA - openQA web-frontend, scheduler and tools.
coreutils - Cross-platform Rust rewrite of the GNU coreutils