I've already applied common suggestions
[profile.release]
opt-level = 'z'
lto = true
panic = 'abort'
And still my 400 lines of code rust application takes 334k after stripping with statically linked musl libc.
I've read that statically linked musl should take as less as 10KB.
cargo bloat -n 30 --release --target x86_64-unknown-linux-musl
Finished release [optimized] target(s) in 0.02s
Analyzing target/x86_64-unknown-linux-musl/release/morr
File .text Size Crate Name
0.8% 5.3% 13.1KiB std std::process::Command::output
0.5% 3.4% 8.4KiB std _ZN9libunwind10CFI_ParserINS_17LocalAddressSpaceEE17parseInstructionsERS1_mmRKNS2_8CIE_InfoEmRPNS2_20PrologInfoStackEntryEiPNS2_10PrologInfoE
0.5% 3.3% 8.2KiB morr morr::main
0.5% 2.8% 7.0KiB std std::sync::once::Once::call_once::{{closure}}
0.4% 2.7% 6.7KiB crossterm <crossterm::event::source::unix::UnixInternalEventSource as crossterm::event::source::EventSource>::try_read
0.4% 2.3% 5.6KiB [Unknown] elf_add
0.3% 2.1% 5.3KiB [Unknown] dwarf_lookup_pc
0.3% 1.7% 4.2KiB std rustc_demangle::v0::Printer::print_type
0.3% 1.6% 4.0KiB std alloc::collections::btree::map::BTreeMap<K,V>::insert
0.3% 1.6% 4.0KiB std <backtrace::symbolize::SymbolName as core::fmt::Display>::fmt
0.3% 1.6% 4.0KiB [Unknown] elf_zlib_inflate_and_verify
0.2% 1.5% 3.8KiB std _ZN9libunwind17DwarfInstructionsINS_17LocalAddressSpaceENS_16Registers_x86_64EE13stepWithDwarfERS1_mmRS2_
0.2% 1.4% 3.4KiB std rustc_demangle::try_demangle
0.2% 1.3% 3.1KiB morr morr::draw
0.2% 1.2% 2.9KiB [Unknown] fmt_fp
0.2% 1.1% 2.8KiB std _ZN9libunwind17DwarfInstructionsINS_17LocalAddressSpaceENS_16Registers_x86_64EE18evaluateExpressionEmRS1_RKS2_m
0.2% 1.0% 2.5KiB crossterm alloc::sync::Arc<T>::drop_slow
0.2% 1.0% 2.5KiB std std::sys_common::backtrace::output_filename
0.2% 1.0% 2.5KiB std __rdos_backtrace_dwarf_add
0.2% 1.0% 2.5KiB [Unknown] printf_core
0.1% 0.9% 2.3KiB mio mio::poll::Poll::poll
0.1% 0.9% 2.2KiB std _ZN9libunwind14EHHeaderParserINS_17LocalAddressSpaceEE7findFDEERS1_mmjPNS_10CFI_ParserIS1_E8FDE_InfoEPNS5_8CIE_InfoE
0.1% 0.9% 2.2KiB std core::str::pattern::StrSearcher::new
0.1% 0.9% 2.2KiB std rustc_demangle::v0::Printer::print_path
0.1% 0.9% 2.1KiB [Unknown] read_function_entry
0.1% 0.8% 2.0KiB crossterm crossterm::terminal::sys::unix::tput_value
0.1% 0.8% 1.9KiB std _ZN9libunwind10CFI_ParserINS_17LocalAddressSpaceEE8parseCIEERS1_mPNS2_8CIE_InfoE
0.1% 0.7% 1.7KiB std std::sync::once::Once::call_inner
0.1% 0.6% 1.6KiB signal_hook alloc::collections::btree::map::BTreeMap<K,V>::insert
0.1% 0.6% 1.6KiB std std::panicking::rust_panic_with_hook
8.3% 51.6% 128.0KiB And 895 smaller methods. Use -n N to show more.
16.1% 100.0% 248.0KiB .text section size, the file size is 1.5MiB
It's implementation of less utility in rust. source code
I want to know the purpose of each byte in the binary. Cargo bloat doesn't answer that quesiton.