4 ms·
How big are the executables when compiled, especially compared to the C versions? I hope it's not Rust version 2 MB, C version 6 KB.
by acqq 11y ago
How big are the executables when compiled, especially compared to the C versions?
I hope it's not Rust version 2 MB, C version 6 KB.
- steveklabnik 11y agoWell, that would be a statically linked Rust version vs a dynamically linked C version. Either of those languages can produce binaries of either size. Statically link a MUSL libc and it'll be bigger than 6kb, dynamically link the rust code and use the system allocator instead of jemalloc and it'll be smaller than 2MB. (Or rather, it should be, I haven't literally tried it. The smallest known Rust executable is 151 bytes.)
- acqq 11y agoThat's what I wanted to hear, could really the mentioned in Rust implemented coreutils be compiled and linked equivalently to C or not and can we see the resulting sizes? Not "if I don't use any library I can get the 151 byte binary" but exactly these coreutils that are presented. It gives a good idea if the replacements can actually be comparable replacements. The second part is then to compare the number of features implemented and the behavior.
- jabl 11y agoBy default Rust statically links the Rust runtime library, so yeah, 2 MB is roughly it. You can get around it by linking dynamically, and uutils also supports busybox style single binary + links installation (that is, check argv[0] (or whatever the equivalent in Rust is) for which code to run).