From 04c63879b8ef3f4d2c570e9ac4cd36b174aab31d Mon Sep 17 00:00:00 2001 From: guirish Date: Wed, 7 Aug 2019 09:04:05 -0400 Subject: [PATCH] Added support for crossbuilding s390x binaries and images --- Makefile | 24 ++++++++++++++++++++++-- build/Dockerfile | 16 ++++++++-------- 2 files changed, 30 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index 60bd6c9f..64cab385 100644 --- a/Makefile +++ b/Makefile @@ -17,8 +17,8 @@ QEMU_VERSION=v2.7.0 # A list of all supported architectures here. Should be named as Go is naming platforms # All supported architectures must have an "ifeq" block below that customizes the parameters -ALL_ARCHITECTURES=amd64 arm arm64 ppc64le -ML_PLATFORMS=linux/amd64,linux/arm,linux/arm64,linux/ppc64le +ALL_ARCHITECTURES=amd64 arm arm64 ppc64le s390x +ML_PLATFORMS=linux/amd64,linux/arm,linux/arm64,linux/ppc64le,linux/s390x ifeq ($(ARCH),amd64) # The architecture to use when downloading the docker binary @@ -97,6 +97,26 @@ ifeq ($(ARCH),ppc64le) # Tell the gcc linker to search for libpcap here CGO_LDFLAGS="-L/usr/local/lib/$(CC)" endif +ifeq ($(ARCH),s390x) +# The architecture to use when downloading the docker binary + WEAVEEXEC_DOCKER_ARCH?=s390x + +# Using the (semi-)official alpine image + ALPINE_BASEIMAGE?=s390x/alpine:3.6 + +# s390x images have the -s390x suffix, for instance weaveworks/weave-s390x:latest + ARCH_EXT?=-s390x + +# The name of the gcc binary + CC=s390x-linux-gnu-gcc + +# The architecture name to use when downloading a prebuilt QEMU binary + QEMUARCH=s390x + +# In the weaveworks/build image; libpcap libraries for s390x are placed here +# Tell the gcc linker to search for libpcap here + CGO_LDFLAGS="-L/usr/local/lib/$(CC)" +endif # The name of the user that this Makefile should produce image artifacts for. Can/should be overridden DOCKERHUB_USER?=weaveworks diff --git a/build/Dockerfile b/build/Dockerfile index 06416766..1c511535 100644 --- a/build/Dockerfile +++ b/build/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.10.1-stretch +FROM golang:1.12.7-buster # Support Raspberry Pi 2 and newer ENV GOARM 7 @@ -7,25 +7,25 @@ ENV GOARM 7 ENV DEB_CROSSPLATFORMS \ armhf \ arm64 \ - ppc64el + ppc64el \ + s390x # The go platforms we are supporting to cross-compile ENV GO_CROSSPLATFORMS \ linux/arm \ linux/arm64 \ - linux/ppc64le + linux/ppc64le \ + linux/s390x # The names of the gcc cross-compilers we have installed ENV GCC_CROSSCOMPILERS \ arm-linux-gnueabihf \ aarch64-linux-gnu \ - powerpc64le-linux-gnu + powerpc64le-linux-gnu \ + s390x-linux-gnu -# Temporarily add the Debian repositories, because we're going to install gcc cross-compilers from there # Install the build-essential and crossbuild-essential-ARCH packages -RUN echo "deb http://emdebian.org/tools/debian/ jessie main" > /etc/apt/sources.list.d/cgocrosscompiling.list \ - && curl http://emdebian.org/tools/debian/emdebian-toolchain-archive.key | apt-key add - \ - && for platform in ${DEB_CROSSPLATFORMS}; do dpkg --add-architecture $platform; done \ +RUN for platform in ${DEB_CROSSPLATFORMS}; do dpkg --add-architecture $platform; done \ && apt-get update \ && apt-get install -y build-essential \ && for platform in ${DEB_CROSSPLATFORMS}; do apt-get install -y crossbuild-essential-${platform}; done \