Skip to content

Commit

Permalink
Use GitHub Markdown alerts in README (#67)
Browse files Browse the repository at this point in the history
  • Loading branch information
johnthagen authored Jun 25, 2024
1 parent 2f7d968 commit af259fc
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ which optimizes the binary for **speed**. To instruct Cargo to optimize for mini
opt-level = "z" # Optimize for size.
```

Note that in some cases the `"s"` level may result in a smaller binary than `"z"`, as explained in
the
[`opt-level` documentation](https://doc.rust-lang.org/cargo/reference/profiles.html#opt-level):

> [!NOTE]
> In some cases the `"s"` level may result in a smaller binary than `"z"`, as explained in the
> [`opt-level` documentation](https://doc.rust-lang.org/cargo/reference/profiles.html#opt-level):
>
> It is recommended to experiment with different levels to find the right balance for your project.
> There may be surprising results, such as ... the `"s"` and `"z"` levels not being necessarily
> smaller.
Expand Down Expand Up @@ -129,7 +129,8 @@ codegen-units = 1

![Minimum Rust: 1.10](https://img.shields.io/badge/Minimum%20Rust%20Version-1.10-brightgreen.svg)

> **Note**: Up to this point, the features discussed to reduce binary size did not have an
> [!IMPORTANT]
> Up to this point, the features discussed to reduce binary size did not have an
> impact on the behaviour of the program (only its execution speed). This feature does
> have an impact on behavior.
Expand Down Expand Up @@ -165,9 +166,11 @@ $ RUSTFLAGS="-Zlocation-detail=none" cargo +nightly build --release

![Minimum Rust: Nightly](https://img.shields.io/badge/Minimum%20Rust%20Version-nightly-orange.svg)

> **Note**: See also [Xargo](https://github.com/japaric/xargo), the predecessor to `build-std`.
> [!NOTE]
> See also [Xargo](https://github.com/japaric/xargo), the predecessor to `build-std`.
[Xargo is currently in maintenance status](https://github.com/japaric/xargo/issues/193).

> [!NOTE]
> Example project is located in the [`build_std`](build_std) folder.
Rust ships pre-built copies of the standard library (`libstd`) with its toolchains. This means
Expand Down Expand Up @@ -239,6 +242,7 @@ On macOS, the final stripped binary size is reduced to 30KB.

![Minimum Rust: Nightly](https://img.shields.io/badge/Minimum%20Rust%20Version-nightly-orange.svg)

> [!NOTE]
> Example projects are located in the [`no_main`](no_main) folder.
Up until this point, we haven't restricted what utilities we used from `libstd`. In this section
Expand Down Expand Up @@ -271,6 +275,7 @@ On macOS, the final stripped binary is reduced to 8KB.

![Minimum Rust: 1.30](https://img.shields.io/badge/Minimum%20Rust%20Version-1.30-brightgreen.svg)

> [!NOTE]
> Example projects are located in the [`no_std`](no_std) folder.
Up until this point, our application was using the Rust standard library, `libstd`. `libstd`
Expand Down Expand Up @@ -307,8 +312,9 @@ fn my_panic(_info: &core::panic::PanicInfo) -> ! {

# Compress the binary

Up until this point, all size-reducing techniques were Rust-specific. This section describes
a language-agnostic binary packing tool that is an option to reduce binary size further.
> [!NOTE]
> Up until this point, all size-reducing techniques were Rust-specific. This section describes
> a language-agnostic binary packing tool that is an option to reduce binary size further.
[UPX](https://github.com/upx/upx) is a powerful tool for creating a self-contained, compressed
binary with no addition runtime requirements. It claims to typically reduce binary size by 50-70%,
Expand All @@ -318,8 +324,9 @@ but the actual result depends on your executable.
$ upx --best --lzma target/release/min-sized-rust
```

It should be noted that there have been times that UPX-packed binaries have flagged
heuristic-based anti-virus software because malware often uses UPX.
> [!WARNING]
> There have been times that UPX-packed binaries have flagged heuristic-based antivirus software
> because malware often uses UPX.
# Tools

Expand Down

0 comments on commit af259fc

Please sign in to comment.