Commit 1b2e1c2d58

1b2e1c2d58cd97ed15ac611f1eaf73d2ea0103a8

parent: d11f0ef40d

Unregistered key

Ulyssa <git@ulyssa.dev> · 2026-08-18 00:46 UTC
committer: <noreply@github.com>

Document how to build size-optimized binaries in the README (#644)

Layout: unified · split

Cargo.toml +9
@@ -18,6 +18,9 @@ build = "build.rs"
18default = ["bundled", "desktop"] 18default = ["bundled", "desktop"]
19bundled = ["matrix-sdk/bundled-sqlite"] 19bundled = ["matrix-sdk/bundled-sqlite"]
20desktop = ["dep:notify-rust", "modalkit/clipboard"] 20desktop = ["dep:notify-rust", "modalkit/clipboard"]
21max_level_warn = ["tracing/max_level_warn"]
22max_level_error = ["tracing/max_level_error"]
23max_level_off = ["tracing/max_level_off"]
21 24
22[build-dependencies.vergen-gitcl] 25[build-dependencies.vergen-gitcl]
23version = "9" 26version = "9"
@@ -108,6 +111,12 @@ inherits = "release"
108incremental = false 111incremental = false
109lto = true 112lto = true
110 113
114[profile.release-light]
115inherits = "release-lto"
116opt-level = "z"
117strip = true
118panic = "abort"
119
111[package.metadata.deb] 120[package.metadata.deb]
112section = "net" 121section = "net"
113license-file = ["LICENSE", "0"] 122license-file = ["LICENSE", "0"]
README.md +23
@@ -60,6 +60,29 @@ containing the sources (ie: from a git clone):
60cargo install --locked --path . 60cargo install --locked --path .
61``` 61```
62 62
63If you're willing to wait longer on the build, you can use the `release-lto`
64profile to enable link-time optimization:
65
66```
67cargo install --profile release-lto --locked --path .
68```
69
70If you would prefer to optimize for a smaller binary, you can use the
71`release-light` profile, which will do LTO, optimize code generation
72for smaller output, and strip the binary. The `max_level_error` feature
73will also make sure that any `tracing` logs below the error level have
74their strings removed during compile-time, so that you only get `error`
75logs.
76
77```
78cargo install --profile release-light --features max_level_error --path .
79```
80
81Add `--no-default-features` if you want to skip desktop integration (e.g.
82clipboard and notifications support) and you would like to link against
83your system's OpenSSL and SQLite instead of using rustls and a bundled
84SQLite.
85
63## Installation (via `crates.io`) 86## Installation (via `crates.io`)
64 87
65Install Rust (1.83.0 or above) and Cargo, and then run: 88Install Rust (1.83.0 or above) and Cargo, and then run:
src/config.rs +7 −1
@@ -63,6 +63,12 @@ const DEFAULT_ENABLE_TITLE: bool = true;
63const DEFAULT_ENC_INDICATOR_LOC: EncryptionIndicatorLocation = EncryptionIndicatorLocation::PROMPT; 63const DEFAULT_ENC_INDICATOR_LOC: EncryptionIndicatorLocation = EncryptionIndicatorLocation::PROMPT;
64const DEFAULT_REQ_TIMEOUT: u64 = 120; 64const DEFAULT_REQ_TIMEOUT: u64 = 120;
65 65
66const DEFAULT_LOG_LEVEL: &str = if cfg!(feature = "max_level_error") {
67 "error"
68} else {
69 "warn"
70};
71
66const COLORS: [Color; 13] = [ 72const COLORS: [Color; 13] = [
67 Color::Blue, 73 Color::Blue,
68 Color::Cyan, 74 Color::Cyan,
@@ -940,7 +946,7 @@ impl Tunables {
940 users: self.users.unwrap_or_default(), 946 users: self.users.unwrap_or_default(),
941 947
942 default_markup: self.default_markup.unwrap_or_default(), 948 default_markup: self.default_markup.unwrap_or_default(),
943 log_level: self.log_level.unwrap_or_else(|| "warn".to_string()), 949 log_level: self.log_level.unwrap_or_else(|| DEFAULT_LOG_LEVEL.to_owned()),
944 max_log_files: self.max_log_files.unwrap_or(7), 950 max_log_files: self.max_log_files.unwrap_or(7),
945 message_shortcode_display: self.message_shortcode_display.unwrap_or(false), 951 message_shortcode_display: self.message_shortcode_display.unwrap_or(false),
946 normal_after_send: self.normal_after_send.unwrap_or(false), 952 normal_after_send: self.normal_after_send.unwrap_or(false),
src/windows/room/chat.rs +1
@@ -945,6 +945,7 @@ impl Editable<ProgramContext, ProgramStore, IambInfo> for ChatState {
945 // Run command again. 945 // Run command again.
946 delegate!(self, w => w.editor_command(act, ctx, store)) 946 delegate!(self, w => w.editor_command(act, ctx, store))
947 }, 947 },
948 #[cfg(feature = "desktop")]
948 Err(EditError::Register(RegisterError::ClipboardImage(data))) => { 949 Err(EditError::Register(RegisterError::ClipboardImage(data))) => {
949 let info = store.application.rooms.get_or_default(self.id().to_owned()); 950 let info = store.application.rooms.get_or_default(self.id().to_owned());
950 let prompt = if self.tbox.get().is_blank() && self.get_reply_to(info).is_none() { 951 let prompt = if self.tbox.get().is_blank() && self.get_reply_to(info).is_none() {