|
|
Log in / Subscribe / Register

Rewriting the GNU Coreutils in Rust

Rewriting the GNU Coreutils in Rust

Posted Jun 9, 2021 21:34 UTC (Wed) by Cyberax (✭ supporter ✭, #52523)
In reply to: Rewriting the GNU Coreutils in Rust by ccchips
Parent article: Rewriting the GNU Coreutils in Rust

You're looking at a static binary with all the debug info. If you strip the debug info then the size would be around 300kb:

> cyberax@CybMac:/tmp$ rustc -O hello1.rs
> cyberax@CybMac:/tmp$ strip hello1 ; ls -la hello1
> -rwxr-xr-x 1 cyberax wheel 295880 9 июн 14:32 hello1

You can further reduce the size by using dynamic runtime:

> cyberax@CybMac:/tmp$ rustc -C prefer-dynamic -O hello1.rs
> cyberax@CybMac:/tmp$ ls -la hello1
> -rwxr-xr-x 1 cyberax wheel 50184 9 июн 14:29 hello1

In practice, if you are using a multicall binary then it would be BETTER to use the statically linked binary. This way the kernel will only need to cache this one binary and it will load much faster (no linking needed). This is especially helpful for scripts that invoke a lot of utilities.


to post comments

Rewriting the GNU Coreutils in Rust

Posted Jun 10, 2021 2:56 UTC (Thu) by ccchips (guest, #3222) [Link]

Thank you! I misread what happens when I strip the binary--over 10X smaller.


Copyright © 2026, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds