Skip to content

[go1.24] Fix s390x dynamic loader symlink #673

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
cmd/bin
images/.qemu-user-static.created
images/calico-go-build/bin
34 changes: 0 additions & 34 deletions .semaphore/promotions/qemu-user-static.yml

This file was deleted.

4 changes: 0 additions & 4 deletions .semaphore/semaphore.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,6 @@ promotions:
pipeline_file: promotions/calico-go-build.yml
auto_promote:
when: "branch = 'master' OR tag =~ '^1\\.\\d+\\.\\d-llvm\\d+\\.\\d\\.\\d-k8s1\\.\\d+\\.\\d'"
- name: Publish calico/qemu-user-static image
pipeline_file: promotions/qemu-user-static.yml
auto_promote:
when: "branch = 'master' OR tag =~ '^1\\.\\d+\\.\\d-llvm\\d+\\.\\d\\.\\d-k8s1\\.\\d+\\.\\d'"

blocks:
- name: calico/go-build image
Expand Down
2 changes: 1 addition & 1 deletion Makefile.common
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ endif
# This is only needed when running non-native binaries.
register:
ifneq ($(BUILDARCH),$(ARCH))
docker run --rm --privileged multiarch/qemu-user-static:register || true
docker run --privileged --rm tonistiigi/binfmt --install all || true
endif

# If this is a release, also tag and push additional images.
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ For example, if you registered the `s390x` emulator at `/usr/bin/qemu-s390x-stat
To register emulators, we run:

```bash
docker run -it --rm --privileged multiarch/qemu-user-static:register
docker run --privileged --rm tonistiigi/binfmt --install all
```

or simply
Expand All @@ -69,7 +69,7 @@ To _run_ a binary from a different architecture, you need to use `binfmt` and `q
Register `qemu-*-static` for all supported processors except the current one using the following command:

```bash
docker run --rm --privileged multiarch/qemu-user-static:register
docker run --privileged --rm tonistiigi/binfmt --install all
```

If a cross built binary is executed in the go-build container qemu-static will automatically be used.
3 changes: 2 additions & 1 deletion cmd/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ build: semvalidator-build-$(ARCH)

.PHONY: semvalidator-build-$(ARCH)
semvalidator-build-$(ARCH): semvalidator/main.go
CGO_ENABLED=0 go build -o bin/semvalidator-$(ARCH) -v -buildvcs=false -ldflags "-s -w" semvalidator/main.go
CGO_ENABLED=0 GOOS=linux GOARCH=$(ARCH) \
go build -o bin/semvalidator-$(ARCH) -v -buildvcs=false -ldflags "-s -w" semvalidator/main.go

.PHONY: clean
clean:
Expand Down
27 changes: 4 additions & 23 deletions images/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,11 @@ VERSION_TAG ?= latest
CALICO_BASE ?= base
CALICO_GO_BUILD ?= go-build

QEMU_USER_STATIC ?= $(DEV_REGISTRIES)/qemu-user-static
QEMU_USER_STATIC_IMAGE_CREATED = .qemu-user-static.created

.PHONY: image
image: qemu-user-static-image calico-base-image calico-go-build-image
image: calico-base-image calico-go-build-image

.PHONY: image-all
image-all: qemu-user-static-image calico-base-image-all calico-go-build-image-all

# Holder image for all qemu-*-static binaries Calico supports.
# It only builds for linux/amd64 platform.
.PHONY: qemu-user-static-image
qemu-user-static-image: $(QEMU_USER_STATIC_IMAGE_CREATED)
$(QEMU_USER_STATIC_IMAGE_CREATED):
docker buildx build $(DOCKER_PROGRESS) --load --platform=linux/amd64 --pull \
-t $(QEMU_USER_STATIC):latest \
-f qemu-user-static/Dockerfile qemu-user-static/
touch $@

.PHONY: qemu-user-static-cd
qemu-user-static-cd: qemu-user-static-image
docker push $(QEMU_USER_STATIC):latest
image-all: calico-base-image-all calico-go-build-image-all

# Base image for all calico components.

Expand All @@ -44,7 +27,7 @@ else ifeq ($(ARCH),s390)
endif

.PHONY: calico-base-image
calico-base-image: register qemu-user-static-image
calico-base-image: register
$(DOCKER_BUILD) --build-arg LDSONAME=$(LDSONAME) -t $(CALICO_BASE):latest-$(ARCH) -f calico-base/Dockerfile calico-base/
$(MAKE) BUILD_IMAGES=$(CALICO_BASE) retag-build-images-with-registries VALIDARCHES=$(ARCH) IMAGETAG=latest

Expand All @@ -65,7 +48,7 @@ build:
cp ../cmd/bin/semvalidator-$(ARCH) calico-go-build/bin/semvalidator-$(ARCH)

.PHONY: calico-go-build-image
calico-go-build-image: register qemu-user-static-image build
calico-go-build-image: register build
$(DOCKER_BUILD) -t $(CALICO_GO_BUILD):latest-$(ARCH) -f calico-go-build/Dockerfile calico-go-build/
$(MAKE) BUILD_IMAGES=$(CALICO_GO_BUILD) retag-build-images-with-registries VALIDARCHES=$(ARCH) IMAGETAG=$(VERSION_TAG)

Expand All @@ -84,8 +67,6 @@ push-calico-go-build-manifests: var-require-one-of-CONFIRM-DRYRUN var-require-al

.PHONY: clean
clean:
rm -f $(QEMU_USER_STATIC_IMAGE_CREATED)
rm -fr calico-go-build/bin
-docker image rm -f $$(docker images $(CALICO_BASE) -a -q)
-docker image rm -f $$(docker images $(CALICO_GO_BUILD) -a -q)
-docker image rm -f $$(docker images $(QEMU_USER_STATIC) -a -q)
15 changes: 10 additions & 5 deletions images/calico-base/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
FROM --platform=linux/amd64 calico/qemu-user-static:latest AS qemu

FROM registry.access.redhat.com/ubi8/ubi-minimal:latest AS ubi

ARG LDSONAME

COPY --from=qemu /usr/bin/qemu-*-static /usr/bin/
ARG TARGETARCH

RUN microdnf upgrade -y

Expand All @@ -13,12 +10,16 @@ RUN microdnf upgrade -y
RUN mkdir -p /rootfs/lib64 /rootfs/etc

# Copy dynamic loader and symbolic links.
# Note: The dynamic loader name and links might be different in a future release.
# For s390x architecture, modify the /lib/${LDSONAME} symlink to ../lib64/${LDSONAME}
# instead of /usr/lib64 as the /usr/lib64 directory is not included in our base.
RUN cp /lib64/ld-2.28.so /rootfs/lib64/ld-2.28.so
RUN set -eux; \
cp -a /lib64/${LDSONAME} /rootfs/lib64/${LDSONAME}; \
if [ -f /lib/${LDSONAME} ]; then \
mkdir -p /rootfs/lib && cp -a /lib/${LDSONAME} /rootfs/lib/${LDSONAME}; \
if [ "${TARGETARCH}" = "s390x" ]; then \
ln -sf ../lib64/${LDSONAME} /rootfs/lib/${LDSONAME}; \
fi \
fi

# Required external C dependencies for CGO builds.
Expand All @@ -42,6 +43,10 @@ FROM scratch AS source

COPY --from=ubi /rootfs /

# Verify if glibc can be properly loaded.
# This check ensures that the dynamic loader and symbolic links are copied correctly.
RUN ["/lib64/libc.so.6"]

# tmp.tar has a /tmp with the correct permissions 01777.
ADD tmp.tar /

Expand Down
6 changes: 0 additions & 6 deletions images/calico-go-build/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ ARG TARGETARCH=${TARGETARCH}

FROM calico/bpftool:v7.4.0 AS bpftool

FROM --platform=amd64 calico/qemu-user-static:latest AS qemu

FROM registry.access.redhat.com/ubi8/ubi:latest AS ubi

ARG TARGETARCH
Expand All @@ -16,10 +14,6 @@ ARG YQ_VERSION=v4.45.1

ENV PATH=/usr/local/go/bin:$PATH

# Enable non-native runs on amd64 architecture hosts
# Supported qemu-user-static arch files are copied in Makefile `download-qemu` target
COPY --from=qemu /usr/bin/qemu-*-static /usr/bin

# Install system dependencies
RUN dnf upgrade -y && dnf install -y \
autoconf \
Expand Down
14 changes: 0 additions & 14 deletions images/qemu-user-static/Dockerfile

This file was deleted.

Loading