From efc5df577382e4990c16348f4db4b55563d9177e Mon Sep 17 00:00:00 2001 From: Kir Kolyshkin Date: Fri, 8 Dec 2017 15:56:13 -0800 Subject: [PATCH] BUILDING.md: add netgo for static build 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 /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 --- BUILDING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BUILDING.md b/BUILDING.md index f3ad6137b..f432b4db5 100644 --- a/BUILDING.md +++ b/BUILDING.md @@ -84,7 +84,7 @@ You can build static binaries by providing a few variables to `make`: ```sudo make EXTRA_FLAGS="-buildmode pie" \ EXTRA_LDFLAGS='-extldflags "-fno-PIC -static"' \ - BUILDTAGS="static_build" + BUILDTAGS="static_build netgo" ``` > *Note*: