min-sized-rust
gccrs
Our great sponsors
min-sized-rust | gccrs | |
---|---|---|
101 | 102 | |
7,301 | 2,246 | |
- | 2.7% | |
6.2 | 9.9 | |
11 days ago | 3 days ago | |
Rust | ||
MIT License | GNU General Public License v3.0 only |
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.
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.
gccrs
-
Why do lifetimes need to be leaky?
That's why gccrs doesn't even consider lifetime checking a part of the language (they plan to use Polonius, too).
-
How hard would it be to port the Rust toolchain to a new non-POSIX OS written in Rust and get it to host its own development? What would that process entail?
There's ongoing work on a Rust front-end for GCC (https://github.com/Rust-GCC/gccrs). Bit barebones right now -- ie, even core doesn't compile -- but there's funding, demand, and regular progress, so it'll only get better from there. Once gccrs can compile core, it should be ready to compile most of Rust, and thus if you've taught the calling conventions for C to GCC, you're golden.
-
Rust contributions for Linux 6.4 are finally merged upstream!
Do you mean this project https://rust-gcc.github.io/ ?
That is what theyre refering to, yes. The GitHub is named https://github.com/Rust-GCC/gccrs
Unsure currently, but there is project to get gcc to compile rust directly https://rust-gcc.github.io/ that is working to get changes upstreamed.
-
GCC 13 and the State of Gccrs
- But this misses so much extra context information
3. Macro invocations there are really subtle rules on how you treat macro invocations such as this which is not documented at all https://github.com/Rust-GCC/gccrs/blob/master/gcc/rust/expan...
Some day I personally want to write a blog post about how complicated and under spec'd Rust is, then write one about the stuff i do like it such as iterators being part of libcore so i don't need reactive extensions.
-
Any alternate Rust compilers?
Another upcoming implementation is Rust-GCC. This may help with wider adoption of Rust programs, but it probably won't see much use or support by Rust users. Furthermore, it will probably take some time to be implemented, since writing a compiler frontend is a difficult task.
In the future: gccrs (https://github.com/Rust-GCC/gccrs) is making progress, but is not useful now. It will be the first alternative compiler for Rust if/when complete (it probably will be completed because of the whole Rust for Linux effort)
(Speaking of which, Rust-GCC (or gcc-rs or gccrs or whichever other of their names they decide is the primary one) isn't even going to be a complete C++ implementation. Their plan is to implement enough to compile Polonius (the NLL 2.0 borrow checker being developed in Rust for rustc) and then share that since borrow-checking isn't necessary for codegen... only to identify and reject invalid programs... making the C++ portion of it not that different in scope from mrustc.)
-
why GNU grep is fast
If it were proposed, it may end up being a political issue. GNU wants things under their umbrella to be GNU GPL licensed, and the rust compiler is not. There is work to get a Rust compiler built into gcc, but it's not nearly ready yet.
What are some alternatives?
gcc-rust - a (WIP) Rust frontend for gcc / a gcc backend for rustc
rustc_codegen_gcc - libgccjit AOT codegen for rustc
rustc_codegen_gcc - libgccjit AOT codegen for rustc
mold - Mold: A Modern Linker ðŸ¦
rust - Empowering everyone to build reliable and efficient software.
smartstring - Compact inlined strings for Rust.
Rust-for-Linux - Adding support for the Rust language to the Linux kernel.
polonius - Defines the Rust borrow checker.
mrustc - Alternative rust compiler (re-implementation)
zig - General-purpose programming language and toolchain for maintaining robust, optimal, and reusable software.
c2rust - Migrate C code to Rust