From 169636b46b369aea786ac27ba8aae10604b04670 Mon Sep 17 00:00:00 2001 From: graelo Date: Wed, 1 Jun 2022 08:48:58 +0200 Subject: [PATCH] feat: better release mode --- Cargo.toml | 23 +++++++++++++++++++++++ Makefile | 2 ++ 2 files changed, 25 insertions(+) create mode 100644 Makefile diff --git a/Cargo.toml b/Cargo.toml index 0400146..270fe11 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -25,3 +25,26 @@ path = "src/bin/copyrat.rs" [[bin]] name = "tmux-copyrat" path = "src/bin/tmux_copyrat.rs" + +[profile.release] +# Enable link-time optimization (LTO). It’s a kind of whole-program or +# inter-module optimization as it runs as the very last step when linking the +# different parts of your binary together. You can think of it as allowing +# better inlining across dependency boundaries (but it’s of course more +# complicated that that). +# +# Rust can use multiple linker flavors, and the one we want is “optimize across +# all crates”, which is called “fat”. To set this, add the lto flag to your +# profile: +lto = "fat" + +# To speed up compile times, Rust tries to split your crates into small chunks +# and compile as many in parallel as possible. The downside is that there’s +# less opportunities for the compiler to optimize code across these chunks. So, +# let’s tell it to do one chunk per crate: +codegen-units = 1 + +# Rust by default uses stack unwinding (on the most common platforms). That +# costs performance, so let’s skip stack traces and the ability to catch panics +# for reduced code size and better cache usage: +panic = "abort" diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..5eb0597 --- /dev/null +++ b/Makefile @@ -0,0 +1,2 @@ +release: + RUSTFLAGS="-Ctarget-cpu=native" cargo build --release