Skip to content

Commit

Permalink
Add more code-size optimization flags. (#55)
Browse files Browse the repository at this point in the history
Add -Zfmt-debug=none and -Zbuild-std-features=optimize_for_size,
which were recently added to [min-sized-rust].

[min-sized-rust]: https://github.com/johnthagen/min-sized-rust
  • Loading branch information
sunfishcode authored Nov 27, 2024
1 parent 96a123f commit fdb280d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion example-crates/hello-world-small/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ It uses the [workaround to support -Zbuild-std], and can be built with
a command like this:

```console
$ RUSTFLAGS="-Z location-detail=none -C relocation-model=static -Ctarget-feature=+crt-static" cargo +nightly run -Z build-std=std,panic_abort -Z build-std-features=panic_immediate_abort --target x86_64-unknown-linux-gnu --release
$ RUSTFLAGS="-Z location-detail=none -Zfmt-debug=none -C relocation-model=static -Ctarget-feature=+crt-static" cargo +nightly run -Z build-std=std,panic_abort -Z build-std-features=panic_immediate_abort,optimize_for_size --target x86_64-unknown-linux-gnu --release
```

This applies all the techniques described on the [min-sized-rust] page
Expand Down
4 changes: 2 additions & 2 deletions tests/example_crates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,11 @@ fn example_crate_hello_world_small() {
&[
"--release",
"-Zbuild-std=std,panic_abort",
"-Zbuild-std-features=panic_immediate_abort",
"-Zbuild-std-features=panic_immediate_abort,optimize_for_size",
],
&[(
"RUSTFLAGS",
"-Zlocation-detail=none -Crelocation-model=static -Ctarget-feature=+crt-static",
"-Zlocation-detail=none -Zfmt-debug=none -Crelocation-model=static -Ctarget-feature=+crt-static",
)],
"Hello, world!\n",
"",
Expand Down

0 comments on commit fdb280d

Please sign in to comment.