Skip to content
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

chore: re-enable swift on arm64 #351

Merged
merged 1 commit into from
Jul 12, 2024
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
46 changes: 17 additions & 29 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -251,15 +251,10 @@ RUN xx-verify /out/usr/bin/protoc-gen-rust-grpc

FROM swift:${SWIFT_IMAGE_VERSION} AS grpc_swift
ARG TARGETOS TARGETARCH GRPC_SWIFT_VERSION
RUN <<EOF
mkdir -p /protoc-gen-swift
# Skip arm64 build due to https://forums.swift.org/t/build-crash-when-building-in-qemu-using-new-swift-5-6-arm64-image/56090/
# TODO: Remove this conditional once fixed
if [ "${TARGETARCH}" = "arm64" ]; then
echo "Skipping arm64 build due to error in Swift toolchain"
exit 0
fi
apt-get update
RUN mkdir -p /protoc-gen-swift && \
mkdir -p /grpc-swift
RUN rm /var/lib/dpkg/info/libc-bin.* && \
apt-get update && \
apt-get install -y \
build-essential \
curl \
Expand All @@ -268,18 +263,18 @@ RUN <<EOF
patchelf \
unzip \
zlib1g-dev
RUN curl -sSL https://api.github.com/repos/grpc/grpc-swift/tarball/${GRPC_SWIFT_VERSION} | tar xz --strip 1 -C /grpc-swift
WORKDIR /grpc-swift
RUN <<EOF
case ${TARGETARCH} in
"amd64") SWIFT_LIB_DIR=/lib64 && SWIFT_LINKER=ld-${TARGETOS}-x86-64.so.2 ;;
"arm64") SWIFT_LIB_DIR=/lib && SWIFT_LINKER=ld-${TARGETOS}-aarch64.so.1 ;;
*) echo "ERROR: Machine arch ${TARGETARCH} not supported." ;;
esac
mkdir -p /grpc-swift
curl -sSL https://api.github.com/repos/grpc/grpc-swift/tarball/${GRPC_SWIFT_VERSION} | tar xz --strip 1 -C /grpc-swift
cd /grpc-swift
make
make plugins
install -Ds /grpc-swift/protoc-gen-swift /protoc-gen-swift/protoc-gen-swift
install -Ds /grpc-swift/protoc-gen-grpc-swift /protoc-gen-swift/protoc-gen-grpc-swift
swift build -c release --product protoc-gen-swift
swift build -c release --product protoc-gen-grpc-swift
install -Ds /grpc-swift/.build/release/protoc-gen-swift /protoc-gen-swift/protoc-gen-swift
install -Ds /grpc-swift/.build/release/protoc-gen-grpc-swift /protoc-gen-swift/protoc-gen-grpc-swift
cp ${SWIFT_LIB_DIR}/${SWIFT_LINKER} \
$(ldd /protoc-gen-swift/protoc-gen-swift /protoc-gen-swift/protoc-gen-grpc-swift | awk '{print $3}' | grep /lib | sort | uniq) \
/protoc-gen-swift/
Expand Down Expand Up @@ -333,7 +328,6 @@ RUN apk add --no-cache \
python3 \
unzip \
zip

ARG TARGETARCH
ARG PROTOC_GEN_JS_VERSION
ARG CPPFLAGS=-std=c++17
Expand Down Expand Up @@ -443,9 +437,9 @@ RUN ln -s /usr/bin/grpc_cpp_plugin /usr/bin/protoc-gen-grpc-cpp && \
ln -s /usr/bin/grpc_python_plugin /usr/bin/protoc-gen-grpc-python && \
ln -s /usr/bin/grpc_ruby_plugin /usr/bin/protoc-gen-grpc-ruby && \
ln -s /usr/bin/protoc-gen-go-grpc /usr/bin/protoc-gen-grpc-go && \
ln -s /usr/bin/protoc-gen-rust-grpc /usr/bin/protoc-gen-grpc-rust
# ln -s /protoc-gen-swift/protoc-gen-grpc-swift /usr/bin/protoc-gen-grpc-swift && \
# ln -s /protoc-gen-swift/protoc-gen-swift /usr/bin/protoc-gen-swift
ln -s /usr/bin/protoc-gen-rust-grpc /usr/bin/protoc-gen-grpc-rust && \
ln -s /protoc-gen-swift/protoc-gen-grpc-swift /usr/bin/protoc-gen-grpc-swift && \
ln -s /protoc-gen-swift/protoc-gen-swift /usr/bin/protoc-gen-swift
COPY protoc-wrapper /usr/bin/protoc-wrapper
RUN mkdir -p /test && \
protoc-wrapper \
Expand All @@ -466,35 +460,29 @@ RUN mkdir -p /test && \
--grpc-python_out=/test \
--grpc-ruby_out=/test \
--grpc-rust_out=/test \
--grpc-swift_out=/test \
--grpc-web_out=import_style=commonjs,mode=grpcwebtext:/test \
--java_out=/test \
--js_out=import_style=commonjs:/test \
--jsonschema_out=/test \
--lint_out=/test \
--nanopb_out=/test \
--php_out=/test \
--python_out=/test \
--ruby_out=/test \
--rust_out=experimental-codegen=enabled,kernel=cpp:/test \
--swift_out=/test \
--ts_out=/test \
--validate_out=lang=go:/test \
google/protobuf/any.proto
RUN protoc-wrapper \
--gogo_out=/test \
google/protobuf/any.proto
ARG TARGETARCH
RUN <<EOF
if ! [ "${TARGETARCH}" = "arm64" ]; then
ln -s /protoc-gen-swift/protoc-gen-grpc-swift /usr/bin/protoc-gen-grpc-swift
ln -s /protoc-gen-swift/protoc-gen-swift /usr/bin/protoc-gen-swift
fi
EOF
RUN <<EOF
if ! [ "${TARGETARCH}" = "arm64" ]; then
protoc-wrapper \
--grpc-swift_out=/test \
--js_out=import_style=commonjs:/test \
--scala_out=/test \
--swift_out=/test \
google/protobuf/any.proto
fi
EOF
Expand Down
2 changes: 1 addition & 1 deletion deps.list
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ GO_IMAGE_VERSION=1.22.4-alpine3.20
GOOGLE_API_VERSION=7976ffadc0f21ee9149708c0c97ef000e15de1eb
GRPC_GATEWAY_VERSION=v2.20.0
GRPC_RUST_VERSION=v0.8.3
GRPC_SWIFT_VERSION=1.21.0
GRPC_SWIFT_VERSION=1.23.0
GRPC_WEB_VERSION=1.5.0
NODE_IMAGE_VERSION=22.3.0-alpine3.20
PROTOC_GEN_DART_VERSION=v21.1.2
Expand Down
Loading