Skip to content

Commit 3a8ae92

Browse files
committed
Fix static build + CGO
Signed-off-by: Tianon Gravi <[email protected]>
1 parent 4218cf0 commit 3a8ae92

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

scripts/build/.variables

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,11 @@ if test -n "${PLATFORM}"; then
9696
GO_LDFLAGS="$GO_LDFLAGS -X \"github.com/docker/cli/cli/version.PlatformName=${PLATFORM}\""
9797
fi
9898
if [ "$CGO_ENABLED" = "1" ] && [ "$GO_LINKMODE" = "static" ] && [ "$(go env GOOS)" = "linux" ]; then
99-
GO_LDFLAGS="$GO_LDFLAGS -extldflags -static"
99+
GO_LDFLAGS="$GO_LDFLAGS -linkmode external -extldflags -static"
100100
fi
101101
if [ "$CGO_ENABLED" = "1" ] && [ "$GO_LINKMODE" = "static" ]; then
102-
# compiling statically with CGO enabled requires osusergo to be set.
103-
GO_BUILDTAGS="$GO_BUILDTAGS osusergo"
102+
# compiling statically with CGO enabled requires osusergo and netgo to be set.
103+
GO_BUILDTAGS="$GO_BUILDTAGS osusergo netgo"
104104
fi
105105
if [ -n "$GO_STRIP" ]; then
106106
# if stripping enabled and building with llvm < 12 against darwin/amd64

0 commit comments

Comments
 (0)