Re: The Case for Rust (in the base system)

From: Charlie Li <vishwin_at_freebsd.org>
Date: Sun, 21 Jan 2024 04:24:49 UTC
Warner Losh wrote:
> Why is the rust binary so much larger? Are the rust runtime and 
> dependencies statically linked?
> 
tl;dr yes: https://doc.rust-lang.org/reference/linkage.html

At least in ports, we're generally not packaging anything other than 
--crate-type=bin (executable). Individual crates are free to set output 
crate types, especially when producing an executable, but most will 
leave the crate_type attribute unspecified in Cargo.toml to let 
rustc/cargo perform the most appropriate actions. In this case, a series 
of rlibs are produced for the final link into an executable.

Someone did up an explainer on size minimisation: 
https://github.com/johnthagen/min-sized-rust

In ports, we already use the Release profile, strip symbols, enable LTO 
when not unsafe and set the Rust equivalent of -O2 (default in Release 
profile is -O3).

-- 
Charlie Li
...nope, still don't have an exit line.