johnthagen/min-sized-rust
View on GitHub ↗ ★ 9,871 Rust
🦀 How to minimize Rust binary size 📦 https://github.com/johnthagen/min-sized-rust
55 mentions on Hacker News by 48 people: 3 stories, 52 comments · first 2019-04-26 · latest 2026-10-21
20082026
-
…all, and nuttier stuff. [0]: https://github.com/zion-sati/NetWasm/blob/main/docs/size-and... [1]: https://github.com/johnthagen/min-sized-rust
comment by drhagen · 2026-10-21 · in C# now beats Rust on WASM size -
…runtime. Some parts of it are irreplaceable. And the Rust optimizations to shrink binary size (see https://github.com/johnthagen/min-sized-rust ) are commonly done in production when it matters, not just in WASM but also in embedded.
comment by afdbcreid · 2026-10-21 · in C# now beats Rust on WASM size -
Who knows what they did, but there are things which can be done: https://github.com/johnthagen/min-sized-rust
comment by jsheard · 2026-01-28 · in Rust at Scale: An Added Layer of Security for WhatsApp -
…a developer wants to optimize for binary size instead, Rust provides mechanisms to accomplish this. https://github.com/johnthagen/min-sized-rust?tab=readme-ov-f...
comment by berkes · 2025-10-27 · in Rust cross-platform GPUI components -
A good article on minifying Rust binaries: https://github.com/johnthagen/min-sized-rust
comment by Sharlin · 2025-10-18 · in IDEs we had 30 years ago and lost (2023) -
https://github.com/johnthagen/min-sized-rust explains some of it and https://kobzol.github.io/rust/cargo/2024/01/23/making-rust-b...
comment by throawayonthe · 2025-10-18 · in IDEs we had 30 years ago and lost (2023) -
You can get Rust binaries pretty small: https://github.com/johnthagen/min-sized-rust But in practice it's more like there's an overhead for "hello world" but it's a fixed overhead. So it's really only a problem where you have lots of…
comment by IshKebab · 2025-10-16 · in Garbage collection for Rust: The finalizer frontier -
…[3] : java : https://www.graalvm.org/latest/reference-manual/native-image... [4] minimizing rust : https://github.com/johnthagen/min-sized-rust [5] : https://tetzank.github.io/posts/removing-unused-code/ [6] :…
comment by sargstuff · 2025-07-12 · in Ask HN: What are some non-standard ways to reduce the size of executable files? -
…and dead code removal is already a thing in modern compilers and linkers, and rust can do it too: https://github.com/johnthagen/min-sized-rust
comment by bilbo-b-baggins · 2025-05-10 · in Rust’s dependencies are starting to worry me -
…in at 343K. And for people who want even smaller binaries, they can follow the instructions at https://github.com/johnthagen/min-sized-rust . Older Rust versions used to include more debug symbols in the build, but they're now stripped out…
comment by nindalf · 2025-02-21 · in Users don't care about your tech stack -
Did you try https://github.com/johnthagen/min-sized-rust ?
comment by zozbot234 · 2024-11-29 · in Goodbye, Rust. I wish you success but I'm back to C++ (sorry, it is a rant) -
…cost of the code you add. With a little care, you can get the same code size as you'd get in C. https://github.com/johnthagen/min-sized-rust
comment by pornel · 2024-09-07 · in Deploying Rust in existing firmware codebases -
…binay. I think with all the optimisations, at the end, it was around 8kb for the hello world. [1]: https://github.com/johnthagen/min-sized-rust
comment by clemiclemen · 2024-04-09 · in Hello World -
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,…
comment by bluejekyll · 2024-02-18 · in The Linux Kernel Prepares for Rust 1.77 Upgrade -
…comes from stdlib that the kernel does not use, so I guess that's two different problems. (1) https://github.com/johnthagen/min-sized-rust
comment by makapuf · 2024-02-18 · in The Linux Kernel Prepares for Rust 1.77 Upgrade -
…will link you to this older comment of mine: https://news.ycombinator.com/item?id=29408906 See also https://github.com/johnthagen/min-sized-rust
comment by steveklabnik · 2024-02-09 · in Rust wont save us, but its ideas will -
…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 the feature still hadn't "landed in Rust nightly" until recently?…
comment by sestep · 2024-01-24 · in Making Rust binaries smaller by default -
…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…
comment by pdimitar · 2024-01-24 · in Making Rust binaries smaller by default -
…the years (google "shrink rust binary size"). The `strip` was added to rust nightly in 2020. 1: https://github.com/johnthagen/min-sized-rust 2: https://kerkour.com/optimize-rust-binary-size 3: https://rustrepo.com/repo/johnthagen-min-sized-…
comment by shzhdbi09gv8ioi · 2024-01-24 · in Making Rust binaries smaller by default -
…--target x86_64-unknown-linux-gnu --release As mentioned in another thread, I've simply followed https://github.com/johnthagen/min-sized-rust
comment by riquito · 2024-01-24 · in Making Rust binaries smaller by default -
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
comment by riquito · 2024-01-24 · in Making Rust binaries smaller by default -
Also see min-sized-rust repo[1], which also has this blog post at the bottom (along with others) [1] https://github.com/johnthagen/min-sized-rust
comment by qweqwe14 · 2023-11-09 · in Why Rust in Production? -
…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…
comment by afdbcreid · 2023-10-26 · in Was Rust Worth It? -
A useful reference: https://github.com/johnthagen/min-sized-rust
comment by zozbot234 · 2023-10-09 · in Compiling Rust binaries for Windows 98 SE and more: a journey (2020) -
That must be without stripping. Also there are ways to reduce binary size. See e.g. [min-sized-rust]( https://github.com/johnthagen/min-sized-rust ). I've gotten stripped binaries of small cli utils less than 400KiB without doing anything…
comment by joseluis · 2023-06-16 · in Tiny Binaries (2021) -
You can check out a number of strategies for reducing rust binary size here: https://github.com/johnthagen/min-sized-rust I don't think he mentions it, and I doubt it's relevant in your Hello World example, but if you have a lot of generic…
comment by jamincan · 2023-02-27 · in Write a First Person Game in 2KB with Rust -
…to React I assume that is minified and compressed. That's quite bloat. I wonder if they try https://github.com/johnthagen/min-sized-rust ? Also I feel like the BytecodeAlliance too much focus on their cloud runtime use case while seamless…
comment by Existenceblinks · 2023-02-24 · in Dioxus 0.3 – Templates, Hot Reloading, LiveView, and More -
…the smallest binary and then Zig. Rust produces bloat binary by default but can be small by https://github.com/johnthagen/min-sized-rust for hello word type of app. I have no idea if the gc proposal could make those langs produce smaller…
comment by Existenceblinks · 2023-02-11 · in Ask HN: What Happened to Elm? -
…times a lot longer. [0]: https://lifthrasiir.github.io/rustlog/why-is-a-rust-executab... [1]: https://github.com/johnthagen/min-sized-rust
comment by catfishx · 2023-01-27 · in The Python Paradox (2004) -
…symbols, building in release mode, and more. The following does a good job going over the options: https://github.com/johnthagen/min-sized-rust
comment by Communitivity · 2022-12-29 · in More use of Rust is inevitable in open source software -
https://github.com/johnthagen/min-sized-rust
comment by styluss · 2022-09-18 · in GitUI: Terminal UI for Git -
…and more. There's a giant pile of things you can do here to try and reduce Rust's binary size: https://github.com/johnthagen/min-sized-rust ... but as you can see, it's a lot of work. Rust gets great press and HN is flooded with "let's do…
comment by mike_hearn · 2022-08-18 · in The Jank Language: LLVM Hosted Clojure -
6MB is quite large. Makes me question if you were even building in release mode. You may want to see https://github.com/johnthagen/min-sized-rust It's not difficult to get binaries down into the 50KB range. And for embedded applications,…
comment by pitaj · 2022-07-15 · in How I went about learning Rust -
…imagine further size reductions can be found by following the, by now, "standard", list of steps at https://github.com/johnthagen/min-sized-rust but for a pre-pre-alpha personal project I imagine doing so is not a high priority. Also FWIW…
comment by follower · 2022-03-18 · in Lapce – Fast open-source code editor -
Obligatory link to https://github.com/johnthagen/min-sized-rust
comment by zozbot234 · 2022-02-23 · in “Sustainability with Rust” post misleading about Go -
Here are a couple of options if anyone is curious: https://github.com/johnthagen/min-sized-rust
comment by bogeholm · 2022-02-12 · in Show HN: Jless, a command-line JSON viewer -
…It's sometimes surprising what code takes up all the space. There are some general tips here: https://github.com/johnthagen/min-sized-rust
comment by singron · 2022-01-22 · in Ask HN: What web apps use WASM today? -
…the two) that produces very large binaries. If you just follow the first two bits of advice from: https://github.com/johnthagen/min-sized-rust you’ll reduce your binary sizes to near C++ levels.
comment by dijit · 2021-09-18 · in Alpine Linux: Proposal to move Rust to main -
…of dynamic linking libstd. See: https://users.rust-lang.org/t/link-the-rust-standard-library... and https://github.com/johnthagen/min-sized-rust I'd be interested in any up-to-date trick to do better than this.
comment by Aissen · 2021-03-13 · in Speed of Rust vs. C -
It's possible to make very small Rust binaries: https://github.com/johnthagen/min-sized-rust 8kB for that Rust example, compared to 16kB for my optimized C hello world compiled with GCC. (Not that I think it makes a difference to…
comment by pcwalton · 2021-03-11 · in Zig, parser combinators, and why they're awesome -
…Note that no size optimization that been done and there is a lot ways to do it in Rust https://github.com/johnthagen/min-sized-rust In term of performance, well, it depends on the binary. For example for cp, most of the time is spending…
comment by sylvestre · 2021-03-09 · in Debian Running on Rust Coreutils -
…and neither was LTO. This repository contains information on how to achieve small Rust binaries: https://github.com/johnthagen/min-sized-rust
comment by dthul · 2021-02-17 · in Inline and Sideline Approaches for Low-Cost Memory Safety in C -
…small with tuning[1][2][3]. [1] https://www.codeslow.com/2019/12/tiny-windows-executable-in-... [2] https://github.com/johnthagen/min-sized-rust [3] https://rust-embedded.github.io/book/unsorted/speed-vs-size....
comment by qw3rty01 · 2021-02-17 · in Inline and Sideline Approaches for Low-Cost Memory Safety in C -
…fruit [1] reduces the binary size on my test machine to 27K. This is still not small, granted. [1] https://github.com/johnthagen/min-sized-rust
comment by eatingCake · 2020-11-05 · in Anatomy of a Binary Executable -
…system, avoid proc macros, leverage cfg conditional compilation), but they are work arounds. [1]: https://github.com/johnthagen/min-sized-rust
comment by estebank · 2020-10-20 · in Assorted Thoughts on Zig and Rust -
…in Rust that generates code at the callsite), etc. Most, if not all, of these can be resolved. See https://github.com/johnthagen/min-sized-rust for aiming for small binary size. This article shows a 93% size reduction, 2.7m -> 200kb, with…
comment by PudgePacket · 2020-08-20 · in Porting a Golang and Rust CLI tool to D -
…library [1], you can get something with a fully featured web server in a few hundred kb [2]. [1] https://github.com/johnthagen/min-sized-rust [2] https://jamesmunns.com/blog/tinyrocket/
comment by gpm · 2020-06-13 · in Microsoft: Rust Is the Industry’s ‘Best Chance’ at Safe Systems Programming -
…pretty tiny rust binaries if you don’t link the std library though. Check this out for some tricks: https://github.com/johnthagen/min-sized-rust That blog post explains the vga buffer quite nicely so you should also be able to use the same…
comment by davidhyde · 2020-05-31 · in Bootable minesweeper game in a 512-byte boot sector -
…for size by default, there's a lot of easy ways to shrink binaries (like stripping symbols). https://github.com/johnthagen/min-sized-rust
comment by maccam94 · 2020-04-29 · in How we use Rust in our mobile SDK