hack: do not set buildmode pie for statically linked binary
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
parent
e37985f590
commit
347a5f68da
4 changed files with 16 additions and 13 deletions
|
@ -582,8 +582,8 @@ RUN --mount=type=bind,target=. \
|
||||||
target=$([ "$DOCKER_STATIC" = "1" ] && echo "binary" || echo "dynbinary")
|
target=$([ "$DOCKER_STATIC" = "1" ] && echo "binary" || echo "dynbinary")
|
||||||
xx-go --wrap
|
xx-go --wrap
|
||||||
./hack/make.sh $target
|
./hack/make.sh $target
|
||||||
xx-verify /tmp/bundles/${target}-daemon/dockerd$([ "$(xx-info os)" = "windows" ] && echo ".exe")
|
xx-verify $([ "$DOCKER_STATIC" = "1" ] && echo "--static") /tmp/bundles/${target}-daemon/dockerd$([ "$(xx-info os)" = "windows" ] && echo ".exe")
|
||||||
xx-verify /tmp/bundles/${target}-daemon/docker-proxy$([ "$(xx-info os)" = "windows" ] && echo ".exe")
|
xx-verify $([ "$DOCKER_STATIC" = "1" ] && echo "--static") /tmp/bundles/${target}-daemon/docker-proxy$([ "$(xx-info os)" = "windows" ] && echo ".exe")
|
||||||
mkdir /build
|
mkdir /build
|
||||||
mv /tmp/bundles/${target}-daemon/* /build/
|
mv /tmp/bundles/${target}-daemon/* /build/
|
||||||
EOT
|
EOT
|
||||||
|
|
|
@ -73,15 +73,17 @@ source "${MAKEDIR}/.go-autogen"
|
||||||
|
|
||||||
# -buildmode=pie is not supported on Windows and Linux on mips, riscv64 and ppc64be.
|
# -buildmode=pie is not supported on Windows and Linux on mips, riscv64 and ppc64be.
|
||||||
# https://github.com/golang/go/blob/77aa209b386a184e7f4b44938f2a05a1b5c5a3cf/src/cmd/internal/sys/supported.go#L89-L99
|
# https://github.com/golang/go/blob/77aa209b386a184e7f4b44938f2a05a1b5c5a3cf/src/cmd/internal/sys/supported.go#L89-L99
|
||||||
case "$(go env GOOS)/$(go env GOARCH)" in
|
if ! [ "$DOCKER_STATIC" = "1" ]; then
|
||||||
windows/* | linux/mips* | linux/riscv* | linux/ppc64) ;;
|
case "$(go env GOOS)/$(go env GOARCH)" in
|
||||||
# TODO remove windows in Go 1.15+: https://github.com/golang/go/commit/95f382139043059a2a0780ba577b53893408f7e4
|
windows/* | linux/mips* | linux/riscv* | linux/ppc64) ;;
|
||||||
# TODO remove riscv64 in Go 1.16+: https://github.com/golang/go/commit/8eb846fd37eb7bded8a1cf6932be2c59069863e5
|
# TODO remove windows in Go 1.15+: https://github.com/golang/go/commit/95f382139043059a2a0780ba577b53893408f7e4
|
||||||
|
# TODO remove riscv64 in Go 1.16+: https://github.com/golang/go/commit/8eb846fd37eb7bded8a1cf6932be2c59069863e5
|
||||||
*)
|
|
||||||
BUILDFLAGS+=("-buildmode=pie")
|
*)
|
||||||
;;
|
BUILDFLAGS+=("-buildmode=pie")
|
||||||
esac
|
;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
|
||||||
# only necessary for non-sandboxed invocation where TARGETPLATFORM is empty
|
# only necessary for non-sandboxed invocation where TARGETPLATFORM is empty
|
||||||
PLATFORM_NAME=$TARGETPLATFORM
|
PLATFORM_NAME=$TARGETPLATFORM
|
||||||
|
@ -94,7 +96,7 @@ source "${MAKEDIR}/.go-autogen"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Building $DEST/$BINARY_FULLNAME ($PLATFORM_NAME)..."
|
echo "Building $([ "$DOCKER_STATIC" = "1" ] && echo "static" || echo "dynamic") $DEST/$BINARY_FULLNAME ($PLATFORM_NAME)..."
|
||||||
go build \
|
go build \
|
||||||
-o "$DEST/$BINARY_FULLNAME" \
|
-o "$DEST/$BINARY_FULLNAME" \
|
||||||
"${BUILDFLAGS[@]}" \
|
"${BUILDFLAGS[@]}" \
|
||||||
|
|
|
@ -4,6 +4,7 @@ set -e
|
||||||
[ -z "$KEEPDEST" ] && rm -rf "$DEST"
|
[ -z "$KEEPDEST" ] && rm -rf "$DEST"
|
||||||
|
|
||||||
(
|
(
|
||||||
|
DOCKER_STATIC=1
|
||||||
GO_PACKAGE='github.com/docker/docker/cmd/dockerd'
|
GO_PACKAGE='github.com/docker/docker/cmd/dockerd'
|
||||||
BINARY_NAME='dockerd'
|
BINARY_NAME='dockerd'
|
||||||
source "${MAKEDIR}/.binary"
|
source "${MAKEDIR}/.binary"
|
||||||
|
|
|
@ -5,8 +5,8 @@ set -e
|
||||||
(
|
(
|
||||||
export CGO_ENABLED=0
|
export CGO_ENABLED=0
|
||||||
|
|
||||||
|
DOCKER_STATIC=1
|
||||||
GO_PACKAGE='github.com/docker/docker/cmd/docker-proxy'
|
GO_PACKAGE='github.com/docker/docker/cmd/docker-proxy'
|
||||||
BINARY_NAME='docker-proxy'
|
BINARY_NAME='docker-proxy'
|
||||||
|
|
||||||
source "${MAKEDIR}/.binary"
|
source "${MAKEDIR}/.binary"
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in a new issue