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

Hugo binary no longer statically linked on Linux (starting 0.20.3) #3382

Closed
munnerz opened this Issue Apr 24, 2017 · 10 comments

Comments

Projects
None yet
5 participants
@munnerz
Contributor

munnerz commented Apr 24, 2017

Hi there

Since version 0.20.3, it appears the Hugo binary is no longer being statically linked.

This means when running Hugo within an alpine container, 'no such file or directory' is output (because the linked libraries are not present). I'm assuming this is to do with the transition to using goreleaser, as part of this issue: #3358

From a quick glance, it looks like goreleaser allows us to specify ld flags. etc for use when building, so this should be possible!

Thanks

@bep bep added the Bug label Apr 24, 2017

@bep

This comment has been minimized.

Show comment
Hide comment
@bep

bep Apr 24, 2017

Member

From a quick glance, it looks like goreleaser allows us to specify ld flags. etc for use when building, so this should be possible!

It would be even better if you could provide me with the correct ld flags/or a reference.

Member

bep commented Apr 24, 2017

From a quick glance, it looks like goreleaser allows us to specify ld flags. etc for use when building, so this should be possible!

It would be even better if you could provide me with the correct ld flags/or a reference.

@munnerz

This comment has been minimized.

Show comment
Hide comment
@munnerz

munnerz Apr 24, 2017

Contributor

@bep I've put in a pull request with #3384!

Contributor

munnerz commented Apr 24, 2017

@bep I've put in a pull request with #3384!

@bep

This comment has been minimized.

Show comment
Hide comment
@bep

bep Apr 24, 2017

Member

Thanks; I will check to see how Goxc handle this (which is what we replaced), to make sure I don't introduce even more mess.

Member

bep commented Apr 24, 2017

Thanks; I will check to see how Goxc handle this (which is what we replaced), to make sure I don't introduce even more mess.

@bep

This comment has been minimized.

Show comment
Hide comment
@bep

bep Apr 24, 2017

Member

Note to self:

New vs old Linux:

ELF 64-bit LSB  executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), stripped
ELF 64-bit LSB  executable, x86-64, version 1 (SYSV), statically linked, not stripped
Member

bep commented Apr 24, 2017

Note to self:

New vs old Linux:

ELF 64-bit LSB  executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), stripped
ELF 64-bit LSB  executable, x86-64, version 1 (SYSV), statically linked, not stripped

@bep bep closed this in #3384 Apr 24, 2017

bep added a commit that referenced this issue Apr 24, 2017

releaser: Fix statically linked binaries
In Hugo 0.20.3, the released binaries for Linux was no longer statically linked. This commit fixes that.

Fixes #3382

@bep bep reopened this Apr 24, 2017

@bep

This comment has been minimized.

Show comment
Hide comment
@bep

bep Apr 24, 2017

Member

I have released a new version, but I had to reopen this issue. A build on Linux still shows up as dynamically linked, so I built it on macOS, where everything is fine. We have to check into this some more.

Member

bep commented Apr 24, 2017

I have released a new version, but I had to reopen this issue. A build on Linux still shows up as dynamically linked, so I built it on macOS, where everything is fine. We have to check into this some more.

@ghost ghost referenced this issue Apr 25, 2017

Closed

spf13/hugo v0.20.4 released #5

@bep

This comment has been minimized.

Show comment
Hide comment
@bep

bep Apr 25, 2017

Member

So this works by doing it directly:

go build -ldflags '-s -w -linkmode external -extldflags "-static"'
 file ./hugo
./hugo: ELF 64-bit LSB  executable, x86-64, version 1 (GNU/Linux), statically linked, for GNU/Linux 2.6.24, BuildID[sha1]=38440bf812b499ce299409c4bb9c2042ff24f20c, stripped

I assume Goreleaser is doing some funky stuff ...

Member

bep commented Apr 25, 2017

So this works by doing it directly:

go build -ldflags '-s -w -linkmode external -extldflags "-static"'
 file ./hugo
./hugo: ELF 64-bit LSB  executable, x86-64, version 1 (GNU/Linux), statically linked, for GNU/Linux 2.6.24, BuildID[sha1]=38440bf812b499ce299409c4bb9c2042ff24f20c, stripped

I assume Goreleaser is doing some funky stuff ...

bep added a commit to bep/goreleaser that referenced this issue Apr 25, 2017

Fix ldflags key name in README
Which can lead to some hard-to-debug issues ...

See gohugoio/hugo#3382

@bep bep closed this in fd5109b Apr 25, 2017

@caarlos0

This comment has been minimized.

Show comment
Hide comment
@caarlos0

caarlos0 Apr 25, 2017

Contributor

I assume Goreleaser is doing some funky stuff ...

my bad, docs were inducing to error. Sorry. Thanks @bep for for the PR :)

Contributor

caarlos0 commented Apr 25, 2017

I assume Goreleaser is doing some funky stuff ...

my bad, docs were inducing to error. Sorry. Thanks @bep for for the PR :)

@dettmering

This comment has been minimized.

Show comment
Hide comment
@dettmering

dettmering Jul 18, 2018

@bep this now appears to happen with the extended version of hugo that includes SASS processing.

I can't run hugo extended on alpine anymore. The non-extended version works perfectly, though.

dettmering commented Jul 18, 2018

@bep this now appears to happen with the extended version of hugo that includes SASS processing.

I can't run hugo extended on alpine anymore. The non-extended version works perfectly, though.

@SR-G

This comment has been minimized.

Show comment
Hide comment
@SR-G

SR-G Aug 5, 2018

Same for me - this seems to be "by design choice" (as per said in other issues), but i would then need the list of expected dependencies (was not able to find that anywhere, neigher here or on the forum, if someone has the detailled informations related to this topic, thanks for providing them).

SR-G commented Aug 5, 2018

Same for me - this seems to be "by design choice" (as per said in other issues), but i would then need the list of expected dependencies (was not able to find that anywhere, neigher here or on the forum, if someone has the detailled informations related to this topic, thanks for providing them).

@dettmering

This comment has been minimized.

Show comment
Hide comment
@dettmering

dettmering Aug 7, 2018

I found a workaround by installing glibc: https://github.com/dettmering/hugo-build/blob/master/Dockerfile

Maybe this helps.

dettmering commented Aug 7, 2018

I found a workaround by installing glibc: https://github.com/dettmering/hugo-build/blob/master/Dockerfile

Maybe this helps.

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