Skip to content

Commit a5a4919

Browse files
committed
fix(docker): work around ldconfig segfault under QEMU arm64 emulation
ldconfig crashes (exit 139) on GitHub Actions when cross-compiling arm64 images via QEMU user-space emulation. Two fixes: 1. Both Dockerfiles: temporarily replace ldconfig with a no-op before apt-get install, then restore it after. This prevents libc-bin's post-install script from triggering the crash. 2. runtime/Dockerfile: use ENV LD_LIBRARY_PATH=/usr/lib/swift/linux instead of running ldconfig explicitly, avoiding the crash entirely for that step. Revert the qemu-v10.2.1 version pin in docker.yml — the Dockerfile changes make the QEMU version irrelevant.
1 parent 43ffdf9 commit a5a4919

3 files changed

Lines changed: 35 additions & 4 deletions

File tree

.github/workflows/docker.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,6 @@ jobs:
4242

4343
- name: Set up QEMU
4444
uses: docker/setup-qemu-action@v3
45-
with:
46-
image: tonistiigi/binfmt:qemu-v10.2.1
4745

4846
- name: Set up Docker Buildx
4947
uses: docker/setup-buildx-action@v3

docker/buildsystem/Dockerfile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,16 @@ LABEL org.opencontainers.image.description="Build environment for compiling ARO
1616
LABEL org.opencontainers.image.source="https://github.com/arolang/aro"
1717
LABEL org.opencontainers.image.vendor="ARO Language"
1818

19+
# When cross-compiling for arm64 via QEMU on GitHub Actions, ldconfig segfaults
20+
# under user-space emulation (exit 139). Replace it with a no-op for the duration
21+
# of apt-get, then restore the real binary afterwards.
22+
ARG TARGETARCH
23+
RUN if [ "$TARGETARCH" = "arm64" ]; then \
24+
mv /sbin/ldconfig /sbin/ldconfig.real-bak 2>/dev/null || true; \
25+
printf '#!/bin/sh\n' > /sbin/ldconfig; \
26+
chmod +x /sbin/ldconfig; \
27+
fi
28+
1929
# Install build dependencies including LLVM 20
2030
RUN apt-get update && apt-get install -y --no-install-recommends \
2131
libcurl4-openssl-dev \
@@ -34,6 +44,11 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
3444
&& ln -sf /usr/bin/clang-20 /usr/bin/clang \
3545
&& rm -rf /var/lib/apt/lists/*
3646

47+
# Restore the real ldconfig after apt-get (was replaced for QEMU arm64 compatibility)
48+
RUN if [ -f /sbin/ldconfig.real-bak ]; then \
49+
mv /sbin/ldconfig.real-bak /sbin/ldconfig && ldconfig; \
50+
fi
51+
3752
# Create pkg-config file for LLVM
3853
RUN mkdir -p /usr/lib/pkgconfig && \
3954
printf '%s\n' \

docker/runtime/Dockerfile

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,16 @@ LABEL org.opencontainers.image.description="Minimal runtime environment for ARO
2222
LABEL org.opencontainers.image.source="https://github.com/arolang/aro"
2323
LABEL org.opencontainers.image.vendor="ARO Language"
2424

25+
# When cross-compiling for arm64 via QEMU on GitHub Actions, ldconfig segfaults
26+
# under user-space emulation (exit 139). Replace it with a no-op for the duration
27+
# of apt-get, then restore the real binary afterwards.
28+
ARG TARGETARCH
29+
RUN if [ "$TARGETARCH" = "arm64" ]; then \
30+
mv /sbin/ldconfig /sbin/ldconfig.real-bak 2>/dev/null || true; \
31+
printf '#!/bin/sh\n' > /sbin/ldconfig; \
32+
chmod +x /sbin/ldconfig; \
33+
fi
34+
2535
# Install minimal runtime dependencies
2636
RUN apt-get update && apt-get install -y --no-install-recommends \
2737
libcurl4 \
@@ -32,12 +42,20 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
3242
libxml2 \
3343
&& rm -rf /var/lib/apt/lists/*
3444

45+
# Restore the real ldconfig after apt-get (was replaced for QEMU arm64 compatibility)
46+
RUN if [ -f /sbin/ldconfig.real-bak ]; then \
47+
mv /sbin/ldconfig.real-bak /sbin/ldconfig; \
48+
fi
49+
3550
# Copy Swift runtime libraries from the Swift image
3651
# We use a multi-stage approach to keep the image minimal
3752
COPY --from=swift:6.2-jammy /usr/lib/swift/linux/*.so /usr/lib/swift/linux/
3853

39-
# Configure the dynamic linker to find Swift libraries
40-
RUN echo "/usr/lib/swift/linux" > /etc/ld.so.conf.d/swift.conf && ldconfig
54+
# Configure the dynamic linker to find Swift libraries.
55+
# Use ENV rather than running ldconfig to avoid QEMU arm64 emulation issues
56+
# during cross-compilation. LD_LIBRARY_PATH is respected by all Swift binaries.
57+
RUN echo "/usr/lib/swift/linux" > /etc/ld.so.conf.d/swift.conf
58+
ENV LD_LIBRARY_PATH=/usr/lib/swift/linux
4159

4260
# Create non-root user for running applications
4361
RUN useradd -m -s /bin/bash aro

0 commit comments

Comments
 (0)