summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris <[email protected]>2023-12-18 21:46:53 +0100
committerGitHub <[email protected]>2023-12-18 21:46:53 +0100
commit3337594d60d9a43ba76d03fd92672023806585af (patch)
tree08794393783a8e621be6cfed2bf950876fb905a4
parent2daa8be1f15d0ab4397101c570a2bf9875da1349 (diff)
downloadvaultwarden-3337594d60d9a43ba76d03fd92672023806585af.tar.gz
vaultwarden-3337594d60d9a43ba76d03fd92672023806585af.zip
Add additional build target which optimizes for size (#4096)
OpenWRT is a project which builds and distributes firmware for embedded devies like routers, access points, and so on. These devices are usually very limited in terms of storage. Therefore, optimizing binaries for size at the cost of execution speed is usually desired. This PR adds an additional build-target, namely "release-micro", which implements several parameters which optimize in favor of binary size. The following parameters were chosen: - opt-level "z": Optimize for size with disabled loop vectorization - strip "symbols": Strip debuginfo and symbols from binary - lto "fat": Enable link-time optimizations across all crates - codegen-units 1: Disable parallelization of code generation to allow for additional optimizations - panic "abort": Abort on Panic() instead of unwinding All these build parameters significantly reduce the binary size from >40MB to <15MB - the actual amount depends on the target architecture. We would like to upstream this new build target to keep our build environment simple. Other projects which deploy vaultwarden on size-constrained environments may benefit from this change too. Signed-off-by: Christian Lachner <[email protected]>
-rw-r--r--Cargo.toml9
1 files changed, 9 insertions, 0 deletions
diff --git a/Cargo.toml b/Cargo.toml
index 8e14c40d..ea9e8742 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -180,3 +180,12 @@ split-debuginfo = "unpacked"
# This is a huge speed improvement during testing
[profile.dev.package.argon2]
opt-level = 3
+
+# Optimize for size
+[profile.release-micro]
+inherits = "release"
+opt-level = "z"
+strip = "symbols"
+lto = "fat"
+codegen-units = 1
+panic = "abort"