File tree Expand file tree Collapse file tree 1 file changed +16
-11
lines changed Expand file tree Collapse file tree 1 file changed +16
-11
lines changed Original file line number Diff line number Diff line change @@ -49,17 +49,6 @@ Available starting `1.45.0-nightly (2020-05-28)`,
49
49
$ cargo +nightly build -Z strip=symbols
50
50
```
51
51
52
- # Compress the binary
53
-
54
- [ ` uxp ` ] ( https://github.com/upx/upx ) is a powerful tool for creating a self contained, compressed binary with no addition
55
- runtime requirements. It claims to typically reduce file size by 50-70% but the actual result depends on your
56
- executable. For our example we see a respectable 23% reduction.
57
-
58
- ``` bash
59
- $ uxp --best --lzma target/release/min-sized-rust
60
- ```
61
-
62
-
63
52
# Optimize For Size
64
53
65
54
![ Minimum Rust: 1.28] ( https://img.shields.io/badge/Minimum%20Rust%20Version-1.28-brightgreen.svg )
@@ -301,6 +290,22 @@ fn my_panic(_info: &core::panic::PanicInfo) -> ! {
301
290
}
302
291
```
303
292
293
+ # Compress the binary
294
+
295
+ Up until this point, all size-reducing techniques were Rust-specific. This section describes
296
+ a language-agnostic binary packing tool that is an option to reduce binary size further.
297
+
298
+ [ UPX] ( https://github.com/upx/upx ) is a powerful tool for creating a self contained, compressed
299
+ binary with no addition runtime requirements. It claims to typically reduce binary size by 50-70%,
300
+ but the actual result depends on your executable.
301
+
302
+ ``` bash
303
+ $ upx --best --lzma target/release/min-sized-rust
304
+ ```
305
+
306
+ It should be noted that there have been times that UPX-packed binaries have flagged
307
+ heuristic-based anti-virus software because malware often uses UPX.
308
+
304
309
# Tools
305
310
306
311
- [ ` cargo-bloat ` ] ( https://github.com/RazrFalcon/cargo-bloat ) - Find out what takes most of the
You can’t perform that action at this time.
0 commit comments