Skip to content

Commit

Permalink
Add osusergo build tar for static binaries
Browse files Browse the repository at this point in the history
Go 1.11 includes a fix to os/user to be working in a static binary
(fixing golang/go#23265). The fix requires
`osusergo` build tag to be set for static binaries, which is what
this commit adds (also for containerd).

[v2: sort build tags alphabetically]

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
  • Loading branch information
kolyshkin committed Jul 19, 2018
1 parent 7f91801 commit 70cdb1c
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion hack/dockerfile/install/containerd.installer
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ install_containerd() {

(

export BUILDTAGS='static_build netgo'
export BUILDTAGS='netgo osusergo static_build'
export EXTRA_FLAGS='-buildmode=pie'
export EXTRA_LDFLAGS='-extldflags "-fno-PIC -static"'

Expand Down
2 changes: 1 addition & 1 deletion hack/make.sh
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ LDFLAGS_STATIC=''
EXTLDFLAGS_STATIC='-static'
# ORIG_BUILDFLAGS is necessary for the cross target which cannot always build
# with options like -race.
ORIG_BUILDFLAGS=( -tags "autogen netgo static_build $DOCKER_BUILDTAGS" -installsuffix netgo )
ORIG_BUILDFLAGS=( -tags "autogen netgo osusergo static_build $DOCKER_BUILDTAGS" -installsuffix netgo )
# see https://github.com/golang/go/issues/9369#issuecomment-69864440 for why -installsuffix is necessary here

# When $DOCKER_INCREMENTAL_BINARY is set in the environment, enable incremental
Expand Down
1 change: 1 addition & 0 deletions hack/make/dynbinary-daemon
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ set -e
export IAMSTATIC='false'
export LDFLAGS_STATIC_DOCKER=''
export BUILDFLAGS=( "${BUILDFLAGS[@]/netgo /}" ) # disable netgo, since we don't need it for a dynamic binary
export BUILDFLAGS=( "${BUILDFLAGS[@]/osusergo /}" ) # ditto for osusergo
export BUILDFLAGS=( "${BUILDFLAGS[@]/static_build /}" ) # we're not building a "static" binary here
source "${MAKEDIR}/.binary"
)

0 comments on commit 70cdb1c

Please sign in to comment.