tstack / lnav

Log file navigator
http://lnav.org
BSD 2-Clause "Simplified" License
7.93k stars 315 forks source link

Compiled binary size is huge #650

Open torkelrogstad opened 5 years ago

torkelrogstad commented 5 years ago

I want to have lnav accessible on a Docker container based on Alpine Linux. There's no binary available for Linux, so I built it myself, using this Dockerfile:

https://gist.github.com/torkelrogstad/afa9e106b6e075ca4ed8f9b78a1a39bd

I end up with an exectuable that's 77.5M big! That's huge, seeing as my local lnav is only 2.7M:

$ ls -lah `which lnav`
-rwxr-xr-x 1 2,7M jan.  14 21:01 /usr/bin/lnav

Do you have any idea what's causing this huge difference, and is there anything I can do to shrink it?

UPDATE:

I just compiled this on my local machine (Ubuntu) as well, and I ended up with a 75M binary. So it appears this is not only an Alpine issue.

Freaky commented 5 years ago

Try ./configure --disable-static.

romain-dartigues commented 5 years ago

@torkelrogstad < my issue #666 is related to yours; if you don't want it to be dynamic (which could squeeze some mebibytes by not keeping all the files of the libs), you should strip it.

The binary my patch produced was 49MiB, just doing a strip src/lnav (or install -s src/lnav /usr/local/bin/lnav) bring it down to 7 MiB.

Even the stripped static version can be reduced to 3.1 MiB with gzip, so packing it with https://upx.github.io/ should bring good results.