From 6b042c3e6d405bc55e6cdd7628f898434d02d5af Mon Sep 17 00:00:00 2001 From: Kir Kolyshkin Date: Thu, 7 Dec 2017 17:49:40 -0800 Subject: [PATCH] install-containerd-static: use netgo buildtag MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When compiling containerd binaries statically, linker rightfully complains: + make BUILDTAGS=static_build 'EXTRA_FLAGS=-buildmode pie' 'EXTRA_LDFLAGS=-extldflags "-fno-PIC -static"' 🇩 bin/ctr # github.com/containerd/containerd/cmd/ctr /tmp/go-link-343047789/000000.o: In function `_cgo_b0c710f30cfd_C2func_getaddrinfo': /tmp/go-build/net/_obj/cgo-gcc-prolog:46: warning: Using 'getaddrinfo' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking The same error appears for ctr, containerd, and containerd-stress binaries. The fix is to use Go's own DNS resolver functions, rather than glibc's getaddrinfo() -- this option is turned on by `netgo` build tag. See https://golang.org/pkg/net/ (look for "Name Resolution") for more details. Signed-off-by: Kir Kolyshkin Upstream-commit: 7368ef96c89fd4f6879addf5214c4a09889a05be Component: engine --- components/engine/hack/dockerfile/install-binaries.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/engine/hack/dockerfile/install-binaries.sh b/components/engine/hack/dockerfile/install-binaries.sh index 160ff1a1da..ed97ce58b8 100755 --- a/components/engine/hack/dockerfile/install-binaries.sh +++ b/components/engine/hack/dockerfile/install-binaries.sh @@ -48,7 +48,7 @@ install_containerd_static() { git checkout -q "$CONTAINERD_COMMIT" ( export GOPATH - make BUILDTAGS='static_build' EXTRA_FLAGS="-buildmode pie" EXTRA_LDFLAGS='-extldflags "-fno-PIC -static"' + make BUILDTAGS='static_build netgo' EXTRA_FLAGS="-buildmode pie" EXTRA_LDFLAGS='-extldflags "-fno-PIC -static"' ) cp bin/containerd /usr/local/bin/docker-containerd cp bin/containerd-shim /usr/local/bin/docker-containerd-shim