@@ -65,10 +65,10 @@ which optimizes the binary for **speed**. To instruct Cargo to optimize for mini
6565opt-level = " z" # Optimize for size.
6666```
6767
68- Note that in some cases the ` "s" ` level may result in a smaller binary than ` "z" ` , as explained in
69- the
70- [ ` opt-level ` documentation] ( https://doc.rust-lang.org/cargo/reference/profiles.html#opt-level ) :
71-
68+ > [ !NOTE ]
69+ > In some cases the ` "s" ` level may result in a smaller binary than ` "z" ` , as explained in the
70+ > [ ` opt-level ` documentation] ( https://doc.rust-lang.org/cargo/reference/profiles.html#opt-level ) :
71+ >
7272> It is recommended to experiment with different levels to find the right balance for your project.
7373> There may be surprising results, such as ... the ` "s" ` and ` "z" ` levels not being necessarily
7474> smaller.
@@ -129,7 +129,8 @@ codegen-units = 1
129129
130130![ Minimum Rust: 1.10] ( https://img.shields.io/badge/Minimum%20Rust%20Version-1.10-brightgreen.svg )
131131
132- > ** Note** : Up to this point, the features discussed to reduce binary size did not have an
132+ > [ !IMPORTANT]
133+ > Up to this point, the features discussed to reduce binary size did not have an
133134> impact on the behaviour of the program (only its execution speed). This feature does
134135> have an impact on behavior.
135136
@@ -165,9 +166,11 @@ $ RUSTFLAGS="-Zlocation-detail=none" cargo +nightly build --release
165166
166167![ Minimum Rust: Nightly] ( https://img.shields.io/badge/Minimum%20Rust%20Version-nightly-orange.svg )
167168
168- > ** Note** : See also [ Xargo] ( https://github.com/japaric/xargo ) , the predecessor to ` build-std ` .
169+ > [ !NOTE]
170+ > See also [ Xargo] ( https://github.com/japaric/xargo ) , the predecessor to ` build-std ` .
169171[ Xargo is currently in maintenance status] ( https://github.com/japaric/xargo/issues/193 ) .
170172
173+ > [ !NOTE]
171174> Example project is located in the [ ` build_std ` ] ( build_std ) folder.
172175
173176Rust ships pre-built copies of the standard library (` libstd ` ) with its toolchains. This means
@@ -239,6 +242,7 @@ On macOS, the final stripped binary size is reduced to 30KB.
239242
240243![ Minimum Rust: Nightly] ( https://img.shields.io/badge/Minimum%20Rust%20Version-nightly-orange.svg )
241244
245+ > [ !NOTE]
242246> Example projects are located in the [ ` no_main ` ] ( no_main ) folder.
243247
244248Up until this point, we haven't restricted what utilities we used from ` libstd ` . In this section
@@ -271,6 +275,7 @@ On macOS, the final stripped binary is reduced to 8KB.
271275
272276![ Minimum Rust: 1.30] ( https://img.shields.io/badge/Minimum%20Rust%20Version-1.30-brightgreen.svg )
273277
278+ > [ !NOTE]
274279> Example projects are located in the [ ` no_std ` ] ( no_std ) folder.
275280
276281Up until this point, our application was using the Rust standard library, ` libstd ` . ` libstd `
@@ -307,8 +312,9 @@ fn my_panic(_info: &core::panic::PanicInfo) -> ! {
307312
308313# Compress the binary
309314
310- Up until this point, all size-reducing techniques were Rust-specific. This section describes
311- a language-agnostic binary packing tool that is an option to reduce binary size further.
315+ > [ !NOTE]
316+ > Up until this point, all size-reducing techniques were Rust-specific. This section describes
317+ > a language-agnostic binary packing tool that is an option to reduce binary size further.
312318
313319[ UPX] ( https://github.com/upx/upx ) is a powerful tool for creating a self-contained, compressed
314320binary with no addition runtime requirements. It claims to typically reduce binary size by 50-70%,
@@ -318,8 +324,9 @@ but the actual result depends on your executable.
318324$ upx --best --lzma target/release/min-sized-rust
319325```
320326
321- It should be noted that there have been times that UPX-packed binaries have flagged
322- heuristic-based anti-virus software because malware often uses UPX.
327+ > [ !WARNING]
328+ > There have been times that UPX-packed binaries have flagged heuristic-based antivirus software
329+ > because malware often uses UPX.
323330
324331# Tools
325332
0 commit comments