Added support for crossbuilding s390x binaries and images

This commit is contained in:
guirish committed 2019-08-07 09:04:05 -04:00
1 parent b05c5f63c8
commit 04c63879b8
2 files changed
+30 -10

No files matched your search

+22 -2
View File
@@ -17,8 +17,8 @@ QEMU_VERSION=v2.7.0
# A list of all supported architectures here. Should be named as Go is naming platforms # 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 supported architectures must have an "ifeq" block below that customizes the parameters
ALL_ARCHITECTURES=amd64 arm arm64 ppc64le ALL_ARCHITECTURES=amd64 arm arm64 ppc64le s390x
ML_PLATFORMS=linux/amd64,linux/arm,linux/arm64,linux/ppc64le ML_PLATFORMS=linux/amd64,linux/arm,linux/arm64,linux/ppc64le,linux/s390x
ifeq ($(ARCH),amd64) ifeq ($(ARCH),amd64)
# The architecture to use when downloading the docker binary # 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 # Tell the gcc linker to search for libpcap here
CGO_LDFLAGS="-L/usr/local/lib/$(CC)" CGO_LDFLAGS="-L/usr/local/lib/$(CC)"
endif 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 # The name of the user that this Makefile should produce image artifacts for. Can/should be overridden
DOCKERHUB_USER?=weaveworks DOCKERHUB_USER?=weaveworks
+8 -8
View File
@@ -1,4 +1,4 @@
FROM golang:1.10.1-stretch FROM golang:1.12.7-buster
# Support Raspberry Pi 2 and newer # Support Raspberry Pi 2 and newer
ENV GOARM 7 ENV GOARM 7
@@ -7,25 +7,25 @@ ENV GOARM 7
ENV DEB_CROSSPLATFORMS \ ENV DEB_CROSSPLATFORMS \
armhf \ armhf \
arm64 \ arm64 \
ppc64el ppc64el \
s390x
# The go platforms we are supporting to cross-compile # The go platforms we are supporting to cross-compile
ENV GO_CROSSPLATFORMS \ ENV GO_CROSSPLATFORMS \
linux/arm \ linux/arm \
linux/arm64 \ linux/arm64 \
linux/ppc64le linux/ppc64le \
linux/s390x
# The names of the gcc cross-compilers we have installed # The names of the gcc cross-compilers we have installed
ENV GCC_CROSSCOMPILERS \ ENV GCC_CROSSCOMPILERS \
arm-linux-gnueabihf \ arm-linux-gnueabihf \
aarch64-linux-gnu \ 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 # 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 \ RUN for platform in ${DEB_CROSSPLATFORMS}; do dpkg --add-architecture $platform; done \
&& curl http://emdebian.org/tools/debian/emdebian-toolchain-archive.key | apt-key add - \
&& for platform in ${DEB_CROSSPLATFORMS}; do dpkg --add-architecture $platform; done \
&& apt-get update \ && apt-get update \
&& apt-get install -y build-essential \ && apt-get install -y build-essential \
&& for platform in ${DEB_CROSSPLATFORMS}; do apt-get install -y crossbuild-essential-${platform}; done \ && for platform in ${DEB_CROSSPLATFORMS}; do apt-get install -y crossbuild-essential-${platform}; done \