D
D
dollar2019-04-04 06:42:35
Rust
dollar, 2019-04-04 06:42:35

Why is the minimum app size so big?

I'm trying to compile "dummy":

fn main() {
}

The result is an application of 127 kilobytes .
I understand if I used a function that is in some library, and Rust would include this library in its entirety in the exe. Although it would also look sad. But there are no challenges here at all! What is there that is valuable in the file, without which you can not do?
There should be no garbage collector, no virtual machine, nothing like that.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
T
Tyranron, 2019-04-04
@dollar

A hackneyed topic that has already been raised and studied more than once. It is enough to do: https://www.google.com/search?q=rust+binary+size and immediately get to the Rustlog article: Why is a Rust executable large? . A highly recommended read, even though it's a little outdated (Rust no longer uses jemalloc by default), it's covered in great detail.
In short, then your binary gets:
1. If it was not collected in release mode, then debug symbols.
2. Allocator, or code-glue for the system allocator.
3. Code for panic unwinding (including libbacktrace).
4. Parts of Rust's libstd, even if you don't use them.
If the task is to minimize the Rust binary (for any embedded, for example), then they usually do it #![no_std], use mini-allocators , do it panic = abortand go to other hardships.

G
grinat, 2019-04-04
@grinat

In gou, in my opinion, 2mb min size, in an application compiled by android studio, where the size is still important, at least 3.7mb comes out. So sho 120kb in our times is a good result for a helo word.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question