min-sized-rust
rustc_codegen_gcc
Our great sponsors
min-sized-rust | rustc_codegen_gcc | |
---|---|---|
101 | 33 | |
7,301 | 9 | |
- | - | |
6.2 | 9.7 | |
11 days ago | 3 days ago | |
Rust | Rust | |
MIT License | Apache License 2.0 |
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.
rustc_codegen_gcc
- Rust Support in the Linux Kernel
-
GCC Rust Monthly Report #9 August 2021
It's true that if this project succeeds, that would be an outcome, but it's probably worth noting that you'd really only have to add support for the GCC backend to do that, and not reimplement the frontend as well (parsing, type checking, lifetime checking, etc.). There's an unrelated project working to do that: https://github.com/antoyo/rustc_codegen_gcc that would likely yield those same benefits for less effort.
-
Recursive fib is faster in C++?
Here's the gcc backend for rustc here https://github.com/antoyo/rustc_codegen_gcc Since this just swaps the optimizer/codegen module and reuses all the other stuff from rustc it needs less work and can already compile many valid rust programs.
-
Anyone used the gcc backend before?
I'd like to use the rustc_codegen_gcc backend to compile some Rust programs, but I'm confused about how to install and use the patched libgccjit dependency. I've downloaded the fork provided but don't know where to go from there.
-
The Tor Project announces Arti, a Tor implementation written in Rust from scratch
I was being a little sloppy and mixing together "actual embedded hardware" with "extensions for applications written in other languages" in my head. I think your point about LLVM is still accurate, though I hear peeps about different projects working on GCC support from time to time.
-
Rust GCC back end was officially accepted into the compiler
This doesn't have anything to do with using GCC to compile rust, but instead using rustc to compile Rust using the GCC backend. You can do that today by using the linked project, rustc_codegen_gcc, which is intended to be integrated into rustc at some point in the (hopefully near) future.
-
This is the patch series to add support for Rust as a second language to the Linux kernel.
Rather than mrustc you should probably look at rustc_codegen_gcc which uses gcc as a backend to rustc (WIP) or GCC Rust which tries to implement a rust frontend for gcc (also WIP). I think rustc_codegen_gcc looks the most promising at the moment
-
Hacker News top posts: Jul 6, 2021
Libgccjit AOT Codegen for Rustc\ (2 comments)
- Libgccjit AOT Codegen for Rustc
-
GCC Rust Monthly Report #6 May 2021
It is impressive work but I still think that using libgccjit as a backend is the right way forward since once it has been integrated it should be much less work to maintain.
What are some alternatives?
gccrs - GCC Front-End for Rust
smartstring - Compact inlined strings for Rust.
c2rust - Migrate C code to Rust
rustc_codegen_gcc - libgccjit AOT codegen for rustc
Cargo - The Rust package manager
regex - An implementation of regular expressions for Rust. This implementation uses finite automata and guarantees linear time matching on all inputs.
embedded-graphics - A no_std graphics library for embedded applications
tiny-rust-executable - Using Rust to make a 137-byte static AMD64 Linux executable
polonius - Defines the Rust borrow checker.
avr-hal - embedded-hal abstractions for AVR microcontrollers
openQA - openQA web-frontend, scheduler and tools.
coreutils - Cross-platform Rust rewrite of the GNU coreutils