Swift build for linux/amd64 fails with strange error

242 views Asked by At

I have a swift app with the following dependencies:

    .package(url: "https://github.com/apple/swift-nio.git", .upToNextMajor(from: "2.41.1")),
    .package(url: "https://github.com/apple/swift-crypto.git", .upToNextMajor(from: "2.1.0"))

Building it locally to run in a docker container works. This is the command I use for that:

docker build -t <image-name>:v1 .

Given I am building on an M1 macbook, deploying the above to azure does not work, since it is built for arm64 arch. However, when I attempt to build for linux/amd64, the code fails. This is the docker command I am using:

docker build --platform=linux/amd64 -t <image-name>:v1 .

I have tried with buildx, but the failure is similar:

docker buildx build --platform=linux/amd64 -t <image-name>:v1 .

The command I use to build the app for production is this:

RUN swift build -c release --static-swift-stdlib

Here is a snippet of the error message I am getting:

#0 35.45 warning: 'build': 'Build' was identified as an executable target given the presence of a 'main.swift' file. Starting with tools version 5.4.0 executable targets should be declared as 'executableTarget()'
#0 35.67 Building for production...
#0 36.08 [0/422] Compiling _AtomicsShims.c
#0 36.28 [1/422] Compiling CNIOWindows shim.c
#0 36.48 [2/422] Compiling CNIOWindows WSAStartup.c
#0 36.51 error: command Compiling CNIOLinux shim.c failed: failed to poll (Interrupted system call)
...
#0 44.33 remark: Incremental compilation has been disabled: it is not compatible with 
whole module optimization
#0 44.34 error: command Compiling Swift Module 'NIOConcurrencyHelpers' (5 sources) failed: failed to poll (Interrupted system call)
#0 47.29 error: command Compiling CCryptoBoringSSL crypto/x509v3/v3_skey.c failed: failed to poll (Interrupted system call)
#0 47.64 error: command Compiling CCryptoBoringSSL crypto/x509v3/v3_purp.c failed: failed to poll (Interrupted system call)
0

There are 0 answers