Skip to content

Commit 0b266ba

Browse files
authored
Merge pull request #3490 from thaJeztah/fix_osusergo
scripts/build: make sure osusergo is set for static with CGO enabled
2 parents a23dc4f + e20572d commit 0b266ba

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

scripts/build/.variables

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,10 @@ fi
7373
if [ "$CGO_ENABLED" = "1" ] && [ "$GO_LINKMODE" = "static" ] && [ "$(go env GOOS)" = "linux" ]; then
7474
LDFLAGS="$LDFLAGS -extldflags -static"
7575
fi
76+
if [ "$CGO_ENABLED" = "1" ] && [ "$GO_LINKMODE" = "static" ]; then
77+
# compiling statically with CGO enabled requires osusergo to be set.
78+
GO_BUILDTAGS="$GO_BUILDTAGS osusergo"
79+
fi
7680
if [ -n "$GO_STRIP" ]; then
7781
LDFLAGS="$LDFLAGS -s"
7882
fi

0 commit comments

Comments
 (0)