ee7 / binary-size Goto Github PK
View Code? Open in Web Editor NEWMeasuring the size of Nim hello-world executables. This repo was created mainly as a citation for https://nim-lang.org/blog/2022/12/21/version-20-rc.html
License: MIT License
Measuring the size of Nim hello-world executables. This repo was created mainly as a citation for https://nim-lang.org/blog/2022/12/21/version-20-rc.html
License: MIT License
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 :)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.