Browse code

ldmode=pie is not supported for the mips arch reference: https://github.com/docker/cli/pull/2507 https://github.com/containerd/containerd/commit/4c99c81326f4026fb8c0b8c5e10542205d99c321

Signed-off-by: Xiaodong Liu <liuxiaodong@loongson.cn>

Xiaodong Liu authored on 2020/05/21 10:23:00
Showing 10 changed files
... ...
@@ -13,7 +13,7 @@ install_containerd() (
13 13
 	git checkout -q "$CONTAINERD_COMMIT"
14 14
 
15 15
 	export BUILDTAGS='netgo osusergo static_build'
16
-	export EXTRA_FLAGS='-buildmode=pie'
16
+	export EXTRA_FLAGS=${GO_BUILDMODE}
17 17
 	export EXTRA_LDFLAGS='-extldflags "-fno-PIC -static"'
18 18
 
19 19
 	# Reset build flags to nothing if we want a dynbinary
... ...
@@ -26,5 +26,5 @@ build_dockercli() {
26 26
 	git checkout -q "v$DOCKERCLI_VERSION"
27 27
 	mkdir -p "$GOPATH/src/github.com/docker"
28 28
 	mv components/cli "$GOPATH/src/github.com/docker/cli"
29
-	go build -buildmode=pie -o "${PREFIX}/docker" "github.com/docker/cli/cmd/docker"
29
+	go build ${GO_BUILDMODE} -o "${PREFIX}/docker" "github.com/docker/cli/cmd/docker"
30 30
 }
... ...
@@ -13,7 +13,7 @@ install_golangci_lint() {
13 13
 	commitDate="$(git show -s --format=%cd)"
14 14
 
15 15
 	go build \
16
-		-buildmode=pie \
16
+		${GO_BUILDMODE} \
17 17
 		-ldflags "-s -w -X \"main.version=${version}\" -X \"main.commit=${commit}\" -X \"main.date=${commitDate}\"" \
18 18
 		-o "${PREFIX}/golangci-lint" "github.com/golangci/golangci-lint/cmd/golangci-lint"
19 19
 }
... ...
@@ -6,6 +6,6 @@ install_gotestsum() (
6 6
 	set -e
7 7
 	export GO111MODULE=on
8 8
 	go get -d "gotest.tools/gotestsum@${GOTESTSUM_COMMIT}"
9
-	go build -buildmode=pie -o "${PREFIX}/gotestsum" 'gotest.tools/gotestsum'
9
+	go build ${GO_BUILDMODE} -o "${PREFIX}/gotestsum" 'gotest.tools/gotestsum'
10 10
 
11 11
 )
... ...
@@ -15,6 +15,15 @@ if [ -z "$TMP_GOPATH" ]; then
15 15
 else
16 16
 	export GOPATH="$TMP_GOPATH"
17 17
 fi
18
+case "$(go env GOARCH)" in
19
+	mips* | ppc64)
20
+		# pie build mode is not supported on mips architectures
21
+		export GO_BUILDMODE=""
22
+		;;
23
+	*)
24
+		export GO_BUILDMODE="-buildmode=pie"
25
+		;;
26
+esac
18 27
 
19 28
 dir="$(dirname $0)"
20 29
 
... ...
@@ -23,7 +23,7 @@ install_proxy() {
23 23
 
24 24
 install_proxy_dynamic() {
25 25
 	export PROXY_LDFLAGS="-linkmode=external" install_proxy
26
-	export BUILD_MODE="-buildmode=pie"
26
+	export BUILD_MODE=${GO_BUILDMODE}
27 27
 	_install_proxy
28 28
 }
29 29
 
... ...
@@ -21,7 +21,7 @@ install_rootlesskit() {
21 21
 
22 22
 install_rootlesskit_dynamic() {
23 23
 	export ROOTLESSKIT_LDFLAGS="-linkmode=external" install_rootlesskit
24
-	export BUILD_MODE="-buildmode=pie"
24
+	export BUILD_MODE=${GO_BUILDMODE}
25 25
 	_install_rootlesskit
26 26
 }
27 27
 
... ...
@@ -7,5 +7,5 @@ install_shfmt() {
7 7
 	git clone https://github.com/mvdan/sh.git "$GOPATH/src/github.com/mvdan/sh"
8 8
 	cd "$GOPATH/src/github.com/mvdan/sh" || exit 1
9 9
 	git checkout -q "$SHFMT_COMMIT"
10
-	GO111MODULE=on go build -buildmode=pie -v -o "${PREFIX}/shfmt" ./cmd/shfmt
10
+	GO111MODULE=on go build ${GO_BUILDMODE} -v -o "${PREFIX}/shfmt" ./cmd/shfmt
11 11
 }
... ...
@@ -8,5 +8,5 @@ install_tomlv() {
8 8
 	echo "Install tomlv version $TOMLV_COMMIT"
9 9
 	git clone https://github.com/BurntSushi/toml.git "$GOPATH/src/github.com/BurntSushi/toml"
10 10
 	cd "$GOPATH/src/github.com/BurntSushi/toml" && git checkout -q "$TOMLV_COMMIT"
11
-	go build -v -buildmode=pie -o "${PREFIX}/tomlv" "github.com/BurntSushi/toml/cmd/tomlv"
11
+	go build -v ${GO_BUILDMODE} -o "${PREFIX}/tomlv" "github.com/BurntSushi/toml/cmd/tomlv"
12 12
 }
... ...
@@ -7,5 +7,5 @@ install_vndr() {
7 7
 	git clone https://github.com/LK4D4/vndr.git "$GOPATH/src/github.com/LK4D4/vndr"
8 8
 	cd "$GOPATH/src/github.com/LK4D4/vndr" || exit 1
9 9
 	git checkout -q "$VNDR_COMMIT"
10
-	go build -buildmode=pie -v -o "${PREFIX}/vndr" .
10
+	go build ${GO_BUILDMODE} -v -o "${PREFIX}/vndr" .
11 11
 }