Skip to content

Instantly share code, notes, and snippets.

@KodrAus
Last active March 2, 2017 21:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KodrAus/9f3607abdebb77a9786ef25180b46ffd to your computer and use it in GitHub Desktop.
Save KodrAus/9f3607abdebb77a9786ef25180b46ffd to your computer and use it in GitHub Desktop.
Debug Rust Binary Size

Debug Rust binary size on Linux:

nm -S target/release/my-binary \
  | awk '{
           print $4 |& "rustfilt";
           "rustfilt" |& getline id;
           sub(/::h[0-9a-f]{16}$/, "", id);
           sums[id] += strtonum("0x"$2);
           counts[id] += 1
         }
         END{
           for (id in sums) {
             printf "%8s %4s  %s\n", sums[id], counts[id], id
           }
         }' \
  | sort -nr \
  | head -16

See: https://users.rust-lang.org/t/command-to-debug-binary-size/9440

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment