Преглед изворни кода

Build docker with gccgo, requires host to contain gccgo 5.0

Addresses #9207
Signed-off-by: Srini Brahmaroutu <srbrahma@us.ibm.com>
Srini Brahmaroutu пре 10 година
родитељ
комит
ec92e84b85
4 измењених фајлова са 79 додато и 1 уклоњено
  1. 29 0
      hack/make/.dockerinit-gccgo
  2. 1 1
      hack/make/.integration-daemon-start
  3. 23 0
      hack/make/dyngccgo
  4. 26 0
      hack/make/gccgo

+ 29 - 0
hack/make/.dockerinit-gccgo

@@ -0,0 +1,29 @@
+#!/bin/bash
+set -e
+
+IAMSTATIC="true"
+source "$(dirname "$BASH_SOURCE")/.go-autogen"
+
+go build --compiler=gccgo \
+	-o "$DEST/dockerinit-$VERSION" \
+	"${BUILDFLAGS[@]}" \
+	--gccgoflags "
+		-g
+		-Wl,--no-export-dynamic
+		$EXTLDFLAGS_STATIC_DOCKER
+	" \
+	./dockerinit
+
+echo "Created binary: $DEST/dockerinit-$VERSION"
+ln -sf "dockerinit-$VERSION" "$DEST/dockerinit"
+
+sha1sum=
+if command -v sha1sum &> /dev/null; then
+	sha1sum=sha1sum
+else
+	echo >&2 'error: cannot find sha1sum command or equivalent'
+	exit 1
+fi
+
+# sha1 our new dockerinit to ensure separate docker and dockerinit always run in a perfect pair compiled for one another
+export DOCKER_INITSHA1="$($sha1sum $DEST/dockerinit-$VERSION | cut -d' ' -f1)"

+ 1 - 1
hack/make/.integration-daemon-start

@@ -2,7 +2,7 @@
 
 # see test-integration-cli for example usage of this script
 
-export PATH="$DEST/../binary:$DEST/../dynbinary:$PATH"
+export PATH="$DEST/../binary:$DEST/../dynbinary:$DEST/../gccgo:$PATH"
 
 if ! command -v docker &> /dev/null; then
 	echo >&2 'error: binary or dynbinary must be run before .integration-daemon-start'

+ 23 - 0
hack/make/dyngccgo

@@ -0,0 +1,23 @@
+#!/bin/bash
+set -e 
+
+DEST=$1
+
+if [ -z "$DOCKER_CLIENTONLY" ]; then
+	source "$(dirname "$BASH_SOURCE")/.dockerinit-gccgo"
+	
+	hash_files "$DEST/dockerinit-$VERSION"
+else
+	# DOCKER_CLIENTONLY must be truthy, so we don't need to bother with dockerinit :)
+	export DOCKER_INITSHA1=""
+fi
+# DOCKER_INITSHA1 is exported so that other bundlescripts can easily access it later without recalculating it
+
+(
+	export IAMSTATIC="false"
+	export EXTLDFLAGS_STATIC_DOCKER=''
+	export LDFLAGS_STATIC_DOCKER=''
+	export BUILDFLAGS=( "${BUILDFLAGS[@]/netgo /}" ) # disable netgo, since we don't need it for a dynamic binary
+	export BUILDFLAGS=( "${BUILDFLAGS[@]/static_build /}" ) # we're not building a "static" binary here
+	source "$(dirname "$BASH_SOURCE")/gccgo"
+)

+ 26 - 0
hack/make/gccgo

@@ -0,0 +1,26 @@
+#!/bin/bash
+set -e
+
+DEST=$1
+BINARY_NAME="docker-$VERSION"
+BINARY_EXTENSION="$(binary_extension)"
+BINARY_FULLNAME="$BINARY_NAME$BINARY_EXTENSION"
+
+source "$(dirname "$BASH_SOURCE")/.go-autogen"
+
+go build --compiler=gccgo \
+	-o "$DEST/$BINARY_FULLNAME" \
+	"${BUILDFLAGS[@]}" \
+	--gccgoflags "
+		-g
+		$EXTLDFLAGS_STATIC_DOCKER
+		-Wl,--no-export-dynamic
+		-ldl
+	" \
+	./docker
+
+
+echo "Created binary: $DEST/$BINARY_FULLNAME"
+ln -sf "$BINARY_FULLNAME" "$DEST/docker$BINARY_EXTENSION"
+
+hash_files "$DEST/$BINARY_FULLNAME"