Browse code

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

hack: remove -installsuffix build flag

Sebastiaan van Stijn authored on 2023/01/21 02:25:50
Showing 5 changed files
... ...
@@ -108,19 +108,8 @@ if [ -z "$DOCKER_DEBUG" ]; then
108 108
 	LDFLAGS='-w'
109 109
 fi
110 110
 
111
-LDFLAGS_STATIC=''
112
-EXTLDFLAGS_STATIC='-static'
113
-# ORIG_BUILDFLAGS is necessary for the cross target which cannot always build
114
-# with options like -race.
115
-ORIG_BUILDFLAGS=(-tags "netgo osusergo static_build $DOCKER_BUILDTAGS" -installsuffix netgo)
116
-# see https://github.com/golang/go/issues/9369#issuecomment-69864440 for why -installsuffix is necessary here
117
-
118
-BUILDFLAGS=(${BUILDFLAGS} "${ORIG_BUILDFLAGS[@]}")
119
-
120
-LDFLAGS_STATIC_DOCKER="
121
-	$LDFLAGS_STATIC
122
-	-extldflags \"$EXTLDFLAGS_STATIC\"
123
-"
111
+BUILDFLAGS=(${BUILDFLAGS} -tags "netgo osusergo static_build $DOCKER_BUILDTAGS")
112
+LDFLAGS_STATIC="-extldflags -static"
124 113
 
125 114
 if [ "$(uname -s)" = 'FreeBSD' ]; then
126 115
 	# Tell cgo the compiler is Clang, not GCC
... ...
@@ -63,15 +63,10 @@ source "${MAKEDIR}/.go-autogen"
63 63
 	fi
64 64
 
65 65
 	echo "Building $([ "$DOCKER_STATIC" = "1" ] && echo "static" || echo "dynamic") $DEST/$BINARY_FULLNAME ($PLATFORM_NAME)..."
66
-	go build \
67
-		-o "$DEST/$BINARY_FULLNAME" \
68
-		"${BUILDFLAGS[@]}" \
69
-		-ldflags "
70
-		$LDFLAGS
71
-		$LDFLAGS_STATIC_DOCKER
72
-		$DOCKER_LDFLAGS
73
-	" \
74
-		${GO_PACKAGE}
66
+	if [ -n "$DOCKER_DEBUG" ]; then
67
+		set -x
68
+	fi
69
+	go build -o "$DEST/$BINARY_FULLNAME" "${BUILDFLAGS[@]}" -ldflags "$LDFLAGS $LDFLAGS_STATIC $DOCKER_LDFLAGS" ${GO_PACKAGE}
75 70
 )
76 71
 
77 72
 echo "Created binary: $DEST/$BINARY_FULLNAME"
... ...
@@ -1,13 +1,12 @@
1 1
 #!/usr/bin/env bash
2 2
 
3 3
 LDFLAGS="${LDFLAGS} \
4
-	-X \"github.com/docker/docker/dockerversion.Version=${VERSION}\" \
5
-	-X \"github.com/docker/docker/dockerversion.GitCommit=${GITCOMMIT}\" \
6
-	-X \"github.com/docker/docker/dockerversion.BuildTime=${BUILDTIME}\" \
7
-	-X \"github.com/docker/docker/dockerversion.PlatformName=${PLATFORM}\" \
8
-	-X \"github.com/docker/docker/dockerversion.ProductName=${PRODUCT}\" \
9
-	-X \"github.com/docker/docker/dockerversion.DefaultProductLicense=${DEFAULT_PRODUCT_LICENSE}\" \
10
-"
4
+-X \"github.com/docker/docker/dockerversion.Version=${VERSION}\" \
5
+-X \"github.com/docker/docker/dockerversion.GitCommit=${GITCOMMIT}\" \
6
+-X \"github.com/docker/docker/dockerversion.BuildTime=${BUILDTIME}\" \
7
+-X \"github.com/docker/docker/dockerversion.PlatformName=${PLATFORM}\" \
8
+-X \"github.com/docker/docker/dockerversion.ProductName=${PRODUCT}\" \
9
+-X \"github.com/docker/docker/dockerversion.DefaultProductLicense=${DEFAULT_PRODUCT_LICENSE}\" "
11 10
 
12 11
 # Compile the Windows resources into the sources
13 12
 if [ "$(go env GOOS)" = "windows" ]; then
... ...
@@ -4,7 +4,7 @@ set -e
4 4
 [ -z "$KEEPDEST" ] && rm -rf "$DEST"
5 5
 
6 6
 (
7
-	export LDFLAGS_STATIC_DOCKER=''
7
+	export LDFLAGS_STATIC=''
8 8
 	export BUILDFLAGS=("${BUILDFLAGS[@]/netgo /}")        # disable netgo, since we don't need it for a dynamic binary
9 9
 	export BUILDFLAGS=("${BUILDFLAGS[@]/osusergo /}")     # ditto for osusergo
10 10
 	export BUILDFLAGS=("${BUILDFLAGS[@]/static_build /}") # we're not building a "static" binary here
... ...
@@ -3,7 +3,7 @@
3 3
 set -e
4 4
 
5 5
 (
6
-	export LDFLAGS_STATIC_DOCKER=''
6
+	export LDFLAGS_STATIC=''
7 7
 	export BUILDFLAGS=("${BUILDFLAGS[@]/netgo /}")        # disable netgo, since we don't need it for a dynamic binary
8 8
 	export BUILDFLAGS=("${BUILDFLAGS[@]/osusergo /}")     # ditto for osusergo
9 9
 	export BUILDFLAGS=("${BUILDFLAGS[@]/static_build /}") # we're not building a "static" binary here