From 9051cb173feecbd41de5c5c9f4d9f36bd18f9283 Mon Sep 17 00:00:00 2001 From: Ivan Mikushin Date: Wed, 20 Nov 2024 15:48:45 -0800 Subject: [PATCH 1/2] Strip the RISC-V ELF binary Reduces the size of produced binaries by more than 2x. --- crates/build/src/command/utils.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crates/build/src/command/utils.rs b/crates/build/src/command/utils.rs index ba5ec28532..c5c4754a5e 100644 --- a/crates/build/src/command/utils.rs +++ b/crates/build/src/command/utils.rs @@ -51,7 +51,8 @@ pub(crate) fn get_program_build_args(args: &BuildArgs) -> Vec { /// Rust flags for compilation of C libraries. pub(crate) fn get_rust_compiler_flags(args: &BuildArgs) -> String { let rust_flags = - ["-C", "passes=loweratomic", "-C", "link-arg=-Ttext=0x00200800", "-C", "panic=abort"]; + ["-C", "passes=loweratomic", "-C", "link-arg=-Ttext=0x00200800", "-C", "panic=abort", + "-C", "strip=symbols", "-C", "opt-level=z"]; let rust_flags: Vec<_> = rust_flags.into_iter().chain(args.rustflags.iter().map(String::as_str)).collect(); rust_flags.join("\x1f") From dfa520c57bd8661b362fe6b290a9bb2d7d60ad0e Mon Sep 17 00:00:00 2001 From: Ivan Mikushin Date: Wed, 20 Nov 2024 16:41:45 -0800 Subject: [PATCH 2/2] cargo fmt --- crates/build/src/command/utils.rs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/crates/build/src/command/utils.rs b/crates/build/src/command/utils.rs index c5c4754a5e..c89ebcff5d 100644 --- a/crates/build/src/command/utils.rs +++ b/crates/build/src/command/utils.rs @@ -50,9 +50,18 @@ pub(crate) fn get_program_build_args(args: &BuildArgs) -> Vec { /// Rust flags for compilation of C libraries. pub(crate) fn get_rust_compiler_flags(args: &BuildArgs) -> String { - let rust_flags = - ["-C", "passes=loweratomic", "-C", "link-arg=-Ttext=0x00200800", "-C", "panic=abort", - "-C", "strip=symbols", "-C", "opt-level=z"]; + let rust_flags = [ + "-C", + "passes=loweratomic", + "-C", + "link-arg=-Ttext=0x00200800", + "-C", + "panic=abort", + "-C", + "strip=symbols", + "-C", + "opt-level=z", + ]; let rust_flags: Vec<_> = rust_flags.into_iter().chain(args.rustflags.iter().map(String::as_str)).collect(); rust_flags.join("\x1f")