Size of executable file

#1

I just discovered rClone and have been testing with the linux x86_64 binary executable. All is working as expected but I notice that the executable file is huge… just under 17MB in size. Why is it so large? If I were to build rClone from source would it be possible to create a smaller executable binary?

Thanks
DAK.

#2

I hadn’t noticed the rclone binary had got so big! I guess it does support 20 cloud providers and have 36 commands with 102 options so there is quite a lot of it! rclone has about 55k lines of code and its libraries probably contribute the same again at least.

I use the -s flag when building the release binaries which strips the debug symbols making it 17MB rather than 26 MB. I don’t think you’ll get it much smaller than that unfortunately even if you compile it yourself.

Most of the fat in the rclone binary are symbols for making tracebacks which aren’t normally needed so won’t be loaded into memory.

If you really want a smaller executable, then you can use upx on rclone…

$ ls -l rclone
-rwxrwxr-x 1 ncw ncw 26973574 Oct  3 21:24 rclone
$ go build -ldflags="-s -w"
$ ls -l rclone
-rwxrwxr-x 1 ncw ncw 17215520 Oct  3 21:27 rclone
$ upx --brute rclone
                       Ultimate Packer for eXecutables
                          Copyright (C) 1996 - 2013
UPX 3.91        Markus Oberhumer, Laszlo Molnar & John Reiser   Sep 30th 2013

        File size         Ratio      Format      Name
   --------------------   ------   -----------   -----------
  17215520 ->   3979272   23.11%  linux/ElfAMD   rclone                        

Packed 1 file.
$ ls -l rclone
-rwxrwxr-x 1 ncw ncw 3979272 Oct  3 21:27 rclone

Though the larger rclone binary won’t be loaded into memory, whereas I think upx will decompress the whole thing so it may use more memory paradoxically! It also uses about 0.3S to decompress.

It is fairly easy to build rclone without commands and cloud providers, just edit fs/all/all.go and cmd/all/all.go and comment out things you don’t want.

#3

Thanks, will look at packing the file. I had speculated that maybe rclone was statically linking a bunch of libraries so that the binary was self contained. But maybe it could be built with dynamic linking if you know that the target environment will have those libraries available. The reason I’m asking is because I have an embedded system environment (gateway/router) that it would be useful to have rclone on, and of course in those environments smaller is better.

Thanks
DAK