From d92405543f4662b5a48753360bac6c10ed64f8c2 Mon Sep 17 00:00:00 2001 From: Jan Schintag <43986265+jschintag@users.noreply.github.com> Date: Mon, 22 May 2023 20:52:16 +0200 Subject: [PATCH] MULTIARCH-3441: Enable builds for s390x (#1) - Update the .goreleaser.yaml to include s390x - Update the cross build for s390x - Link gcc to s390x-linux-gnu-gcc binary On s390x go compiler seems to expect the gcc binary at s390x-linux-gnu-gcc binary. However on rhel it is not installed there. Signed-off-by: Jan Schintag --- .goreleaser.yaml | 1 + Dockerfile | 10 ++++++++-- Makefile | 16 ++++++++++------ 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 077e3274a..34df5c317 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -12,6 +12,7 @@ builds: goarch: - amd64 - ppc64le + - s390x env: - CGO_ENABLED=1 flags: diff --git a/Dockerfile b/Dockerfile index c7683f71b..bbaa7ca76 100644 --- a/Dockerfile +++ b/Dockerfile @@ -27,8 +27,14 @@ RUN set -ex \ && GO_VERSION=go1.19.5 \ && curl -sL https://golang.org/dl/${GO_VERSION}.linux-${ARCH}.tar.gz \ | tar xzvf - --directory /usr/local/ \ - && /usr/local/go/bin/go version \ - && ln -f /usr/local/go/bin/go /usr/bin/go + && /usr/local/go/bin/go version + +################################################################################# +# Link gcc to /usr/bin/s390x-linux-gnu-gcc as go requires it on s390x +RUN ARCH=$(arch | sed 's|x86_64|amd64|g') \ + && [ "${ARCH}" == "s390x" ] \ + && ln /usr/bin/gcc /usr/bin/s390x-linux-gnu-gcc \ + || echo "Not running on s390x, skip linking gcc binary" WORKDIR /build ENTRYPOINT ["make"] diff --git a/Makefile b/Makefile index 886af506e..fcb22fdff 100644 --- a/Makefile +++ b/Makefile @@ -35,7 +35,11 @@ cross-build-linux-ppc64le: +@GOOS=linux GOARCH=ppc64le $(MAKE) "$(GO_BUILD_FLAGS)" --no-print-directory build GO_BUILD_BINDIR=$(GO_BUILD_BINDIR)/linux-ppc64le .PHONY: cross-build-linux-ppc64le -cross-build: cross-build-linux-amd64 cross-build-linux-ppc64le +cross-build-linux-s390x: + +@GOOS=linux GOARCH=s390x $(MAKE) "$(GO_BUILD_FLAGS)" --no-print-directory build GO_BUILD_BINDIR=$(GO_BUILD_BINDIR)/linux-s390x +.PHONY: cross-build-linux-s390x + +cross-build: cross-build-linux-amd64 cross-build-linux-ppc64le cross-build-linux-s390x .PHONY: cross-build hack-build: clean @@ -75,12 +79,12 @@ publish-catalog: @cd test/operator && make .PHONY: publish-catalog -format: +format: $(GO) fmt ./pkg/... $(GO) fmt ./cmd/... .PHONY: format -vet: - $(GO) vet $(GO_BUILD_FLAGS) ./pkg/... - $(GO) vet $(GO_BUILD_FLAGS) ./cmd/... -.PHONY: vet \ No newline at end of file +vet: + $(GO) vet $(GO_BUILD_FLAGS) ./pkg/... + $(GO) vet $(GO_BUILD_FLAGS) ./cmd/... +.PHONY: vet