From 880ef756b76a09d9c8f1ef2b4994265ebb2a1bc8 Mon Sep 17 00:00:00 2001 From: Tianon Gravi Date: Sat, 8 Mar 2025 00:54:03 -0800 Subject: [PATCH] Fix static build + CGO Signed-off-by: Tianon Gravi --- scripts/build/.variables | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/build/.variables b/scripts/build/.variables index c42d305a3b1d..d37c945893c6 100755 --- a/scripts/build/.variables +++ b/scripts/build/.variables @@ -96,11 +96,11 @@ if test -n "${PLATFORM}"; then GO_LDFLAGS="$GO_LDFLAGS -X \"github.com/docker/cli/cli/version.PlatformName=${PLATFORM}\"" fi if [ "$CGO_ENABLED" = "1" ] && [ "$GO_LINKMODE" = "static" ] && [ "$(go env GOOS)" = "linux" ]; then - GO_LDFLAGS="$GO_LDFLAGS -extldflags -static" + GO_LDFLAGS="$GO_LDFLAGS -linkmode external -extldflags -static" fi if [ "$CGO_ENABLED" = "1" ] && [ "$GO_LINKMODE" = "static" ]; then - # compiling statically with CGO enabled requires osusergo to be set. - GO_BUILDTAGS="$GO_BUILDTAGS osusergo" + # compiling statically with CGO enabled requires osusergo and netgo to be set. + GO_BUILDTAGS="$GO_BUILDTAGS osusergo netgo" fi if [ -n "$GO_STRIP" ]; then # if stripping enabled and building with llvm < 12 against darwin/amd64