Hacker GitHub

← All repos

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

Mentions per year 55 mentions · busiest year 2024 (11)
20082026
  1. …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
  2. …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
  3. Who knows what they did, but there are things which can be done: https://github.com/johnthagen/min-sized-rust
  4. …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
  5. 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)
  6. 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)
  7. 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…
  8. …[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] :…
  9. …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
  10. …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
  11. Did you try https://github.com/johnthagen/min-sized-rust ?
  12. …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
  13. …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
  14. 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,…
  15. …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
  16. …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
  17. …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
  18. …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
  19. …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
  20. …--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
  21. 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
  22. 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?
  23. …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?
  24. A useful reference: https://github.com/johnthagen/min-sized-rust
  25. 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)
  26. 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
  27. …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…
  28. …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?
  29. …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)
  30. …symbols, building in release mode, and more. The following does a good job going over the options: https://github.com/johnthagen/min-sized-rust
  31. https://github.com/johnthagen/min-sized-rust
    comment by styluss · 2022-09-18 · in GitUI: Terminal UI for Git
  32. …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
  33. 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
  34. …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
  35. Obligatory link to https://github.com/johnthagen/min-sized-rust
  36. 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
  37. …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?
  38. …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.
  39. …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
  40. 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…
  41. …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
  42. …and neither was LTO. This repository contains information on how to achieve small Rust binaries: https://github.com/johnthagen/min-sized-rust
  43. …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....
  44. …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
  45. …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
  46. …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
  47. …(like `strip`) to more advanced and unpractical builds (up to 8KiB hello world, removing... a lot). https://github.com/johnthagen/min-sized-rust
    comment by riquito · 2020-07-16 · in Rust 1.45
  48. …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/
  49. …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…
  50. …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