Giter Club home page Giter Club logo

binary-size's People

Contributors

ee7 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

binary-size's Issues

Use `sstrip` for better stripping and other notes

I recently discovered an interesting tool - sstrip, see https://man.archlinux.org/man/community/elfkickers/sstrip.1.en
https://www.muppetlabs.com/~breadbox/software/elfkickers.html

sudo pacman -S elfkickers

It's a better strip that strips everything that isn't needed for the binary to run.

Also, FYI, -s for the C compiler is worse than using strip, so it should always be done.

Default repo (I don't have musl-* stuff):

 98.2 KiB 
 67.3 KiB -d:release
 39.6 KiB -d:release --passC:-flto --passL:-flto
 34.5 KiB -d:release --passC:-flto --passL:-flto --passL:-s
 26.5 KiB -d:release --passC:-flto --passL:-flto --passL:-s --opt:size
  6.1 KiB -d:release --opt:size --panics:on -d:useMalloc --os:any -d:posix -d:noSignalHandler --cc=clang --clang.exe='/home/dian/Projects/NimExperiments/binary-size/zigcc' --clang.linkerexe='/home/dian/Projects/NimExperiments/binary-size/zigcc' --passC:'-flto -target x86_64-linux-musl' --passL:'-flto -target x86_64-linux-musl'

Use the strip command in the code for all compilers, not just zig cc:

 82.4 KiB 
 58.4 KiB -d:release
 34.4 KiB -d:release --passC:-flto --passL:-flto
 34.4 KiB -d:release --passC:-flto --passL:-flto --passL:-s
 26.4 KiB -d:release --passC:-flto --passL:-flto --passL:-s --opt:size
  6.1 KiB -d:release --opt:size --panics:on -d:useMalloc --os:any -d:posix -d:noSignalHandler --cc=clang --clang.exe='/home/dian/Projects/NimExperiments/binary-size/zigcc' --clang.linkerexe='/home/dian/Projects/NimExperiments/binary-size/zigcc' --passC:'-flto -target x86_64-linux-musl' --passL:'-flto -target x86_64-linux-musl'

Use sstrip -z {filename} instead:

80.3 KiB 
56.3 KiB -d:release
32.3 KiB -d:release --passC:-flto --passL:-flto
32.3 KiB -d:release --passC:-flto --passL:-flto --passL:-s
24.3 KiB -d:release --passC:-flto --passL:-flto --passL:-s --opt:size
 5.3 KiB -d:release --opt:size --panics:on -d:useMalloc --os:any -d:posix -d:noSignalHandler --cc=clang --clang.exe='/home/dian/Projects/NimExperiments/binary-size/zigcc' --clang.linkerexe='/home/dian/Projects/NimExperiments/binary-size/zigcc' --passC:'-flto -target x86_64-linux-musl' --passL:'-flto -target x86_64-linux-musl'

As you can see, it saves ~1KB for zig cc and ~2KB for other compilers, for free :)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.