From 4a57ef12ad05353a914e068c7563a4400880fac4 Mon Sep 17 00:00:00 2001 From: Renato Westphal Date: Sat, 24 Feb 2024 16:54:56 -0300 Subject: [PATCH] build: add profile for small binary sizes This commit adds the "small" profile to Cargo.toml, optimized for small binary sizes. To use it, simply run: $ cargo build --profile=small Using this profile, the holod binary size shrinks to 12M on my machine, down from 21M with the default "release" profile. Signed-off-by: Renato Westphal --- Cargo.toml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 01a15879..a9527e92 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -79,5 +79,10 @@ unsafe_code = "forbid" too_many_arguments = "allow" [profile.release] -lto = true -codegen-units = 1 +lto = true # Enable link-time optimization for improved runtime performance +codegen-units = 1 # Set the number of codegen units to 1 to increase optimization opportunities + +[profile.small] +inherits = "release" # Inherit settings from the release profile +opt-level = "z" # Optimize for small binary size +strip = true # Strip symbols to further reduce binary size