*: switch to -buildmode=pie

Go has supported PIC builds for a while now, and given the security
benefits of using PIC binaries we should really enable them. There also
appears to be some indication that non-PIC builds have been interacting
oddly on ppc64le (the linker cannot load some shared libraries), and
using PIC builds appears to solve this problem.

Signed-off-by: Aleksa Sarai <asarai@suse.de>
Upstream-commit: 1f4e37cf4bd2f73dc5257d791cc4dba294ddd156
Component: engine
This commit is contained in:
Aleksa Sarai
2017-11-11 21:59:49 +11:00
parent d94b0d4775
commit 8fc8b79463
10 changed files with 33 additions and 28 deletions
@@ -60,7 +60,7 @@ install_proxy() {
git clone https://github.com/docker/libnetwork.git "$GOPATH/src/github.com/docker/libnetwork"
cd "$GOPATH/src/github.com/docker/libnetwork"
git checkout -q "$LIBNETWORK_COMMIT"
go build -ldflags="$PROXY_LDFLAGS" -o /usr/local/bin/docker-proxy github.com/docker/libnetwork/cmd/proxy
go build -buildmode=pie -ldflags="$PROXY_LDFLAGS" -o /usr/local/bin/docker-proxy github.com/docker/libnetwork/cmd/proxy
}
install_dockercli() {
@@ -89,7 +89,7 @@ build_dockercli() {
git checkout -q "v$DOCKERCLI_VERSION"
mkdir -p "$GOPATH/src/github.com/docker"
mv components/cli "$GOPATH/src/github.com/docker/cli"
go build -o /usr/local/bin/docker github.com/docker/cli/cmd/docker
go build -buildmode=pie -o /usr/local/bin/docker github.com/docker/cli/cmd/docker
}
install_gometalinter() {
@@ -97,7 +97,7 @@ install_gometalinter() {
go get -d github.com/alecthomas/gometalinter
cd "$GOPATH/src/github.com/alecthomas/gometalinter"
git checkout -q "$GOMETALINTER_COMMIT"
go build -o /usr/local/bin/gometalinter github.com/alecthomas/gometalinter
go build -buildmode=pie -o /usr/local/bin/gometalinter github.com/alecthomas/gometalinter
GOBIN=/usr/local/bin gometalinter --install
}
@@ -108,7 +108,7 @@ do
echo "Install tomlv version $TOMLV_COMMIT"
git clone https://github.com/BurntSushi/toml.git "$GOPATH/src/github.com/BurntSushi/toml"
cd "$GOPATH/src/github.com/BurntSushi/toml" && git checkout -q "$TOMLV_COMMIT"
go build -v -o /usr/local/bin/tomlv github.com/BurntSushi/toml/cmd/tomlv
go build -buildmode=pie -v -o /usr/local/bin/tomlv github.com/BurntSushi/toml/cmd/tomlv
;;
runc)
@@ -157,7 +157,7 @@ do
git clone https://github.com/LK4D4/vndr.git "$GOPATH/src/github.com/LK4D4/vndr"
cd "$GOPATH/src/github.com/LK4D4/vndr"
git checkout -q "$VNDR_COMMIT"
go build -v -o /usr/local/bin/vndr .
go build -buildmode=pie -v -o /usr/local/bin/vndr .
;;
dockercli)
@@ -2,5 +2,5 @@
# Please refer to the top-level Makefile for the worker image.
FROM golang:1.7
ADD . /go/src/github.com/docker/docker/hack/integration-cli-on-swarm/agent
RUN go build -o /master github.com/docker/docker/hack/integration-cli-on-swarm/agent/master
RUN go build -buildmode=pie -o /master github.com/docker/docker/hack/integration-cli-on-swarm/agent/master
ENTRYPOINT ["/master"]
+5
View File
@@ -50,6 +50,11 @@ if [ "$(go env GOOS)/$(go env GOARCH)" != "$(go env GOHOSTOS)/$(go env GOHOSTARC
esac
fi
# -buildmode=pie is not supported on Windows.
if [ "$(go env GOOS)" != "windows" ]; then
BUILDFLAGS+=( "-buildmode=pie" )
fi
echo "Building: $DEST/$BINARY_FULLNAME"
go build \
-o "$DEST/$BINARY_FULLNAME" \