Merge pull request #3490 from thaJeztah/fix_osusergo

scripts/build: make sure osusergo is set for static with CGO enabled
This commit is contained in:
Sebastiaan van Stijn 2022-03-26 17:00:05 +01:00 committed by GitHub
commit 0b266ba0d8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 0 deletions

View File

@ -73,6 +73,10 @@ fi
if [ "$CGO_ENABLED" = "1" ] && [ "$GO_LINKMODE" = "static" ] && [ "$(go env GOOS)" = "linux" ]; then
LDFLAGS="$LDFLAGS -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"
fi
if [ -n "$GO_STRIP" ]; then
LDFLAGS="$LDFLAGS -s"
fi