Hello! I'm trying to update the rvolosatovs/protoc
Docker image to add arm64 support. This image contains Google protobuf support for a number of languages, including Swift. To build a multiarch image, I depend on the newly released swift:5.6-focal
image, since it is one of the only Swift Docker images with arm64 support. I need to build grpc-swift in this section of my Dockerfile in order to run successfully build the protoc image:
FROM swift:5.6-focal as swift_builder
RUN apt-get update && \
apt-get install -y unzip patchelf libnghttp2-dev curl libssl-dev zlib1g-dev build-essential
RUN mkdir -p /grpc-swift && \
curl -sSL https://api.github.com/repos/grpc/grpc-swift/tarball/1.7.1 | tar xz --strip 1 -C /grpc-swift && \
cd /grpc-swift && make && make plugins && \
...
This runs successfully on native linux/arm64 and linux/amd64. However, when I am building in QEMU with --platform=linux/arm64,linux/amd64
on an x86_64 processor, building grpc-swift fails every time with make: *** [Makefile:25: all] Error 1
. I added the -v
switch to the grpc-swift swift build
command, but it turns out the point of failure is different every time. It will eventually always fail at this point:
/usr/bin/swiftc -module-name NIOConcurrencyHelpers -incremental -emit-dependencies -emit-module -emit-module-path /grpc-swift/.build/aarch64-unknown-linux-gnu/debug/NIOConcurrencyHelpers.swiftmodule -output-file-map /grpc-swift/.build/aarch64-unknown-linux-gnu/debug/NIOConcurrencyHelpers.build/output-file-map.json -parse-as-library -c /grpc-swift/.build/checkouts/swift-nio/Sources/NIOConcurrencyHelpers/NIOAtomic.swift /grpc-swift/.build/checkouts/swift-nio/Sources/NIOConcurrencyHelpers/atomics.swift /grpc-swift/.build/checkouts/swift-nio/Sources/NIOConcurrencyHelpers/lock.swift -I /grpc-swift/.build/aarch64-unknown-linux-gnu/debug -target aarch64-unknown-linux-gnu -swift-version 5 -enable-batch-mode -index-store-path /grpc-swift/.build/aarch64-unknown-linux-gnu/debug/index/store -Onone -enable-testing -g -j8 -DSWIFT_PACKAGE -DDEBUG -Xcc -fmodule-map-file=/grpc-swift/.build/aarch64-unknown-linux-gnu/debug/CNIOAtomics.build/module.modulemap -Xcc -I -Xcc /grpc-swift/.build/checkouts/swift-nio/Sources/CNIOAtomics/include -module-cache-path /grpc-swift/.build/aarch64-unknown-linux-gnu/debug/ModuleCache -parseable-output -parse-as-library -color-diagnostics
make: *** [Makefile:25: all] Error 1
I'm asking here first because I suspect the problem is with the build environment rather than the grpc-swift package. But I'm a little bit at a loss of how to debug this further, since I'm not at all familiar with Swift. Could this be a memory corruption problem? Or something in QEMU? How can I get more verbose compiler output on the cause of the error? Can anyone else try compiling this code (or their own code) in the latest Swift image while emulating arm64 on amd64? You can enter the image build environment like this:
docker run --platform linux/arm64 -it swift:5.6-focal bash
And then run the above build instructions, or your own. I have reproduced this on 3 machines so far, I'd be curious if other Swift code also fails. The reason it is important to be able to run like this is that most CI runners are using x86, so we must build multiarch images on this arch.