@@ -248,13 +248,18 @@ RUN xx-cargo --config profile.release.strip=true build --release
248248RUN install -D /grpc-rust/target/$(xx-cargo --print-target-triple)/release/protoc-gen-rust-grpc /out/usr/bin/protoc-gen-rust-grpc
249249RUN xx-verify /out/usr/bin/protoc-gen-rust-grpc
250250
251-
251+ # Skip arm64 build due to https://forums.swift.org/t/build-crash-when-building-in-qemu-using-new-swift-5-6-arm64-image/56090/
252+ # TODO: Set up cross compile https://swiftinit.org/articles/cross-compiling-x86_64-linux-to-aarch64-linux
252253FROM swift:${SWIFT_IMAGE_VERSION} AS grpc_swift
253254ARG TARGETOS TARGETARCH GRPC_SWIFT_VERSION
254- RUN mkdir -p /protoc-gen-swift && \
255- mkdir -p /grpc-swift
256- RUN rm /var/lib/dpkg/info/libc-bin.* && \
257- apt-get update && \
255+ RUN <<EOF
256+ mkdir -p /protoc-gen-swift
257+ if [ "${TARGETARCH}" = "arm64" ]; then
258+ echo "Skipping arm64 build due to error in Swift toolchain"
259+ exit 0
260+ fi
261+ rm /var/lib/dpkg/info/libc-bin.*
262+ apt-get update
258263 apt-get install -y \
259264 build-essential \
260265 curl \
@@ -263,14 +268,14 @@ RUN rm /var/lib/dpkg/info/libc-bin.* && \
263268 patchelf \
264269 unzip \
265270 zlib1g-dev
266- RUN curl -sSL https://api.github.com/repos/grpc/grpc-swift/tarball/${GRPC_SWIFT_VERSION} | tar xz --strip 1 -C /grpc-swift
267- WORKDIR /grpc-swift
268- RUN <<EOF
269271 case ${TARGETARCH} in
270272 "amd64" ) SWIFT_LIB_DIR=/lib64 && SWIFT_LINKER=ld-${TARGETOS}-x86-64.so.2 ;;
271273 "arm64" ) SWIFT_LIB_DIR=/lib && SWIFT_LINKER=ld-${TARGETOS}-aarch64.so.1 ;;
272274 *) echo "ERROR: Machine arch ${TARGETARCH} not supported." ;;
273275 esac
276+ mkdir -p /grpc-swift
277+ curl -sSL https://api.github.com/repos/grpc/grpc-swift/tarball/${GRPC_SWIFT_VERSION} | tar xz --strip 1 -C /grpc-swift
278+ cd /grpc-swift
274279 swift build -c release --product protoc-gen-swift
275280 swift build -c release --product protoc-gen-grpc-swift
276281 install -Ds /grpc-swift/.build/release/protoc-gen-swift /protoc-gen-swift/protoc-gen-swift
@@ -409,9 +414,7 @@ RUN ln -s /usr/bin/grpc_cpp_plugin /usr/bin/protoc-gen-grpc-cpp && \
409414 ln -s /usr/bin/grpc_python_plugin /usr/bin/protoc-gen-grpc-python && \
410415 ln -s /usr/bin/grpc_ruby_plugin /usr/bin/protoc-gen-grpc-ruby && \
411416 ln -s /usr/bin/protoc-gen-go-grpc /usr/bin/protoc-gen-grpc-go && \
412- ln -s /usr/bin/protoc-gen-rust-grpc /usr/bin/protoc-gen-grpc-rust && \
413- ln -s /protoc-gen-swift/protoc-gen-grpc-swift /usr/bin/protoc-gen-grpc-swift && \
414- ln -s /protoc-gen-swift/protoc-gen-swift /usr/bin/protoc-gen-swift
417+ ln -s /usr/bin/protoc-gen-rust-grpc /usr/bin/protoc-gen-grpc-rust
415418COPY protoc-wrapper /usr/bin/protoc-wrapper
416419RUN mkdir -p /test && \
417420 protoc-wrapper \
@@ -432,7 +435,6 @@ RUN mkdir -p /test && \
432435 --grpc-python_out=/test \
433436 --grpc-ruby_out=/test \
434437 --grpc-rust_out=/test \
435- --grpc-swift_out=/test \
436438 --grpc-web_out=import_style=commonjs,mode=grpcwebtext:/test \
437439 --java_out=/test \
438440 --js_out=import_style=commonjs:/test \
@@ -443,18 +445,25 @@ RUN mkdir -p /test && \
443445 --python_out=/test \
444446 --ruby_out=/test \
445447 --rust_out=experimental-codegen=enabled,kernel=cpp:/test \
446- --swift_out=/test \
447448 --ts_out=/test \
448449 --validate_out=lang=go:/test \
449450 google/protobuf/any.proto
450451RUN protoc-wrapper \
451452 --gogo_out=/test \
452453 google/protobuf/any.proto
453454ARG TARGETARCH
455+ RUN <<EOF
456+ if ! [ "${TARGETARCH}" = "arm64" ]; then
457+ ln -s /protoc-gen-swift/protoc-gen-grpc-swift /usr/bin/protoc-gen-grpc-swift
458+ ln -s /protoc-gen-swift/protoc-gen-swift /usr/bin/protoc-gen-swift
459+ fi
460+ EOF
454461RUN <<EOF
455462 if ! [ "${TARGETARCH}" = "arm64" ]; then
456463 protoc-wrapper \
464+ --grpc-swift_out=/test \
457465 --scala_out=/test \
466+ --swift_out=/test \
458467 google/protobuf/any.proto
459468 fi
460469EOF
0 commit comments