-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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
build: release linux-amd64-nocgo statically linked binaries for Alpine users? #18773
Comments
Dup of #18243? |
@mvdan I'm not strictly sure that's the case? It may be related though. What I'm suggesting is that the Go binary distributed via (https://golang.org/dl/) itself is statically linked. Once Go is installed a number of flags are needed to produce distributable static binaries from source written in Go but that is a different issue. |
I'm not sure either; but both seem to be around the linker and the output is the same. |
Static linking multithreaded programs (I.e. all Go programs) against glibc
has known problems:
1. The program still needs matching glibc version at runtime for nss.
2. There are known glibc issues with statically linking glibc programs.
We shouldn't distribute known bad binaries. One workaround is perhaps add a
bin/go.nocgo program that is built with the nocgo build tag.
|
Pasting Ian's comment on #19365 (where they were asking the same thing):
|
@ianlancetaylor, we can automate the creation of static binaries in x/build/cmd/release as a new build configuration. In fact, we already have the That doesn't mean we should do it necessarily, but I wouldn't include:
... in our decision making progress. |
This sounds good from a process standpoint, but minux's comment and the quote from Ian above worry me. What's the use case, here? From my experience building Docker images for Google Cloud, the binary releases include a lot of crud that most people building Docker images don't need. For example, the "tour" binary is included. If you build from scratch, you get Go, and only Go. Maybe that's just better? |
Ping @ianlancetaylor and @rsc for a decision here. |
I'm fine with adding a -nocgo (or a better name might be -static) option for binary builds, as long as it's not the default. |
It's unclear how many Alpine users would use the download. Do we know? What's the full set of linux-*-nocgo that we'd want to post? Just amd64? arm? I don't really want to double our Linux distribution count. It seems like we would want a strong indication of demand here. |
Duplicate of #57007? If so, this can be closed. |
Duplicate of #57007 |
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (
go version
)?Go 1.7.4
What operating system and processor architecture are you using (
go env
)?What did you do?
If possible, provide a recipe for reproducing the error.
A complete runnable program is good.
A link on play.golang.org is best.
The Go binary for ARM is built against libc instead of as a static binary, so when I try to run the Go binary on an Alpine Linux system I get an error (below)
I put together a Dockerfile which reproduces the issue on an ARMv6/7 board such as an RPi 2/3 - the below Dockerfile is +/- the same as the Official Docker golang image with the base image changed to an ARM compatible layer.
What did you expect to see?
Go to function the same way as when I download the binary to a Debian-based system (which includes libc).
Having spoken to @justincormack from Docker we thought it would be good to have a statically-linked binary available so that using Golang on Alpine Linux does not need a complete re-build against musl.
What did you see instead?
The text was updated successfully, but these errors were encountered: