What is the problem you are having with rclone?
I want to reduce binary size when build from source.
Current i got a 98MB binary when run go install github.com/rclone/rclone@latest
, which is near 2x than official release.
Then i try cd rclone && make
, got a 65MB binary file , which is still a little big.
I found the difference between mine and officical release is go/linking: dynamic
, official release is go/linking: static
Any suggestions are appreciated.
followed document : Install
Run the command 'rclone version' and share the full output of the command.
rclone v1.63.1
- os/version: ubuntu 23.04 (64 bit)
- os/kernel: 6.2.0-26-generic (x86_64)
- os/type: linux
- os/arch: amd64
- go/version: go1.20.7
- go/linking: dynamic
- go/tags: none
by default it contains all debug symbols.
I guess you do not need them in your "release"
go build -ldflags="-s -w"
I just executed these commands, and it seems to have helped a bit.
But file size still remain 63MB. The current official file size is 50MB.
There are some other optimisations included in the official release. Maybe it is good idea to document how to build official release version.
1 Like
what about:
go build -trimpath -ldflags="-s -w"
62 MB after add ‘-trimpath'
Before i post this topic i looked through the official GitHub Action YAML file and didn't find any special tricks.
Maybe i am missed something.
Let's see maybe somebody else can point us into right direction
Yeah.
Thank you very much for your reply !
There are some docs here:
ncw
(Nick Craig-Wood)
12
Try this
CGO_ENABLED=0 go build -ldflags="-s"
It should get you most of the way there
Note that if you want to reduce binary size further, comment out backends in backend/all/all.go
that you don't need and commands in cmd/all/all.go
1 Like
This works! binary file size now same as officical.
Thank you !
1 Like
system
(system)
Closed
14
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.