Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

78MB hugo binary is full of paths and urls #12406

Closed
berthubert opened this issue Apr 21, 2024 · 6 comments
Closed

78MB hugo binary is full of paths and urls #12406

berthubert opened this issue Apr 21, 2024 · 6 comments

Comments

@berthubert
Copy link

Hi, many thanks for Hugo (hugo v0.125.2-4e483f5d4abae136c4312d397a55e9e1d39148df linux/amd64 BuildDate=2024-04-20T15:29:44Z VendorInfo=gohugoio)

I just checked the binary version I downloaded from github, and it is huge. Furthermore, it contains 42181 github.com urls and thousands of long paths.

I wonder if "strip" is finding everything it needs to in the hugo binary release. Running strip myself does not decrease the binary size.

$ du -h hugo
79M	hugo
$ strings -a -n 10 hugo  | grep -c github
42181
$ strings -a -n 10 hugo  | grep -c /root/
2412
$ strings -a -n 10 hugo  | grep -c /usr/local/
794

Does this issue reproduce with the latest release?

Yes

@bep
Copy link
Member

bep commented Apr 22, 2024

I just checked the binary version I downloaded from github, and it is huge. Furthermore, it contains 42181 github.com urls and thousands of long paths.

It stores the dependency information which I guess can explain some of the bove.

@bep bep added this to the v0.126.0 milestone Apr 22, 2024
@bep bep modified the milestones: v0.126.0, v0.127.0 May 15, 2024
@bep bep modified the milestones: v0.127.0, v0.128.0 Jun 8, 2024
@bep bep modified the milestones: v0.128.0, v0.129.0 Jun 21, 2024
@lyind
Copy link
Contributor

lyind commented Jul 12, 2024

Sounds more like an issue to be filed in https://github.com/golang/go (if at all)

@bep
Copy link
Member

bep commented Jul 12, 2024

I'm closing this, this needs to be improve upstream. If there are some build flags that I dont't know of that could improve this, please open a PR with changes in:

https://github.com/gohugoio/hugo/blob/master/hugoreleaser.toml

@bep bep closed this as completed Jul 12, 2024
@retsplines
Copy link

Seems like the dependency/module information isn't going away (see golang/go#50501 (comment)) but potentially the baked-in build paths can be cleaned up with the -trimpath compiler argument.

@berthubert
Copy link
Author

It appears there are 180 dependencies in the Hugo binary:

$ strings -n 10 ./hugo | grep -i github | grep ^dep -c
180

Many of the other github.com instances in the binary might in fact be paths, so -trimpath could well be very useful to try.

@mark-kubacki
Copy link

mark-kubacki commented Jul 12, 2024

You’d get the count of built-in dependencies using go version -m like this:

# go version -m hugo | grep -e '^\s*dep' | wc -l
143

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants