From 4d8f9212ca71a0f87bd28624105ce3258819c1d9 Mon Sep 17 00:00:00 2001 From: Huang Qi Date: Sun, 19 Jan 2025 11:26:07 +0800 Subject: [PATCH] rust/hello: Optimize the build flags Summary: - Added `codegen-units = 1` and `opt-level = 'z'` to the release profile in `Cargo.toml` - These changes optimize the build for minimal binary size Impact: - Reduces the final binary size by ~7% (244316 -> 228380 bytes) - Improves resource utilization for embedded systems - No functional changes to the application behavior Signed-off-by: Huang Qi --- examples/rust/hello/Cargo.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/rust/hello/Cargo.toml b/examples/rust/hello/Cargo.toml index d6cba821792..0741516b909 100644 --- a/examples/rust/hello/Cargo.toml +++ b/examples/rust/hello/Cargo.toml @@ -9,11 +9,11 @@ crate-type = ["staticlib"] [profile.dev] panic = "abort" -# Special hanlding for the panic! macro, can be removed once -# the libstd port for NuttX is complete. [profile.release] panic = "abort" lto = true +codegen-units = 1 +opt-level = 'z' [dependencies] serde = { version = "1.0", features = ["derive"] }