Merge pull request #44853 from crazy-max/rm-install-suffix

hack: remove -installsuffix build flag
This commit is contained in:
Sebastiaan van Stijn 2023-01-20 18:25:50 +01:00 committed by GitHub
commit abdf23c6c0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 14 additions and 31 deletions

View file

@ -108,19 +108,8 @@ if [ -z "$DOCKER_DEBUG" ]; then
LDFLAGS='-w'
fi
LDFLAGS_STATIC=''
EXTLDFLAGS_STATIC='-static'
# ORIG_BUILDFLAGS is necessary for the cross target which cannot always build
# with options like -race.
ORIG_BUILDFLAGS=(-tags "netgo osusergo static_build $DOCKER_BUILDTAGS" -installsuffix netgo)
# see https://github.com/golang/go/issues/9369#issuecomment-69864440 for why -installsuffix is necessary here
BUILDFLAGS=(${BUILDFLAGS} "${ORIG_BUILDFLAGS[@]}")
LDFLAGS_STATIC_DOCKER="
$LDFLAGS_STATIC
-extldflags \"$EXTLDFLAGS_STATIC\"
"
BUILDFLAGS=(${BUILDFLAGS} -tags "netgo osusergo static_build $DOCKER_BUILDTAGS")
LDFLAGS_STATIC="-extldflags -static"
if [ "$(uname -s)" = 'FreeBSD' ]; then
# Tell cgo the compiler is Clang, not GCC

View file

@ -63,15 +63,10 @@ source "${MAKEDIR}/.go-autogen"
fi
echo "Building $([ "$DOCKER_STATIC" = "1" ] && echo "static" || echo "dynamic") $DEST/$BINARY_FULLNAME ($PLATFORM_NAME)..."
go build \
-o "$DEST/$BINARY_FULLNAME" \
"${BUILDFLAGS[@]}" \
-ldflags "
$LDFLAGS
$LDFLAGS_STATIC_DOCKER
$DOCKER_LDFLAGS
" \
${GO_PACKAGE}
if [ -n "$DOCKER_DEBUG" ]; then
set -x
fi
go build -o "$DEST/$BINARY_FULLNAME" "${BUILDFLAGS[@]}" -ldflags "$LDFLAGS $LDFLAGS_STATIC $DOCKER_LDFLAGS" ${GO_PACKAGE}
)
echo "Created binary: $DEST/$BINARY_FULLNAME"

View file

@ -1,13 +1,12 @@
#!/usr/bin/env bash
LDFLAGS="${LDFLAGS} \
-X \"github.com/docker/docker/dockerversion.Version=${VERSION}\" \
-X \"github.com/docker/docker/dockerversion.GitCommit=${GITCOMMIT}\" \
-X \"github.com/docker/docker/dockerversion.BuildTime=${BUILDTIME}\" \
-X \"github.com/docker/docker/dockerversion.PlatformName=${PLATFORM}\" \
-X \"github.com/docker/docker/dockerversion.ProductName=${PRODUCT}\" \
-X \"github.com/docker/docker/dockerversion.DefaultProductLicense=${DEFAULT_PRODUCT_LICENSE}\" \
"
-X \"github.com/docker/docker/dockerversion.Version=${VERSION}\" \
-X \"github.com/docker/docker/dockerversion.GitCommit=${GITCOMMIT}\" \
-X \"github.com/docker/docker/dockerversion.BuildTime=${BUILDTIME}\" \
-X \"github.com/docker/docker/dockerversion.PlatformName=${PLATFORM}\" \
-X \"github.com/docker/docker/dockerversion.ProductName=${PRODUCT}\" \
-X \"github.com/docker/docker/dockerversion.DefaultProductLicense=${DEFAULT_PRODUCT_LICENSE}\" "
# Compile the Windows resources into the sources
if [ "$(go env GOOS)" = "windows" ]; then

View file

@ -4,7 +4,7 @@ set -e
[ -z "$KEEPDEST" ] && rm -rf "$DEST"
(
export LDFLAGS_STATIC_DOCKER=''
export LDFLAGS_STATIC=''
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

View file

@ -3,7 +3,7 @@
set -e
(
export LDFLAGS_STATIC_DOCKER=''
export LDFLAGS_STATIC=''
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