From bd0a5eb4b7df0c9ce731277a97cdb21cfdbdb9fb Mon Sep 17 00:00:00 2001 From: Jonathan Schwender <55576758+jschwe@users.noreply.github.com> Date: Tue, 2 Jul 2024 15:05:24 +0200 Subject: [PATCH] Add production-stripped cargo profile (#32651) * Add production-stripped cargo profile Stripping the binary significantly reduces the size significantly (in my tests to about 1/3 of the original size). Enabling lto and setting `codegen-units = 1` allows further size optimizations at the cost of increased compile-time. Probably not everyone wants a stripped binary, since it makes backtraces less useful. Signed-off-by: Jonathan Schwender * Move lto and cgu option to production profile Signed-off-by: Jonathan Schwender --------- Signed-off-by: Jonathan Schwender --- Cargo.toml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index 8a61c064e5d..2de83648326 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -152,6 +152,12 @@ debug-assertions = true [profile.production] inherits = "release" debug-assertions = false +lto = "thin" +codegen-units = 1 + +[profile.production-stripped] +inherits = "production" +strip = true [patch.crates-io] # If you need to temporarily test Servo with a local fork of some upstream