Help compiling Swift in Docker container


I am trying to get started with Swift development and was flowing the contribution setup guide.

There is a section about building on a linux machine, with a link to linux dependencies (listed in the respective Dockerfiles).

I copied that file and used it (plus the linked code in the guide to install sccache) to create a container. Once in the container, I verified that all the dependencies --version commands output values (and that make was >3.19.6) and started the sccache server. I then ran the build command:
utils/build-script --release-debuginfo --skip-early-swift-driver --skip-early-swiftsyntax

Everything progresses ok until:

[221/1355][ 16%][17.306s] Building CXX object SwiftCompilerSources/CMakeFiles/importedHeaderDependencies.dir/HeaderDependencies.cpp.o
FAILED: SwiftCompilerSources/CMakeFiles/importedHeaderDependencies.dir/HeaderDependencies.cpp.o

(Full build output)
(Dumped hashes)

(Start of error output)

Any ideas on what might be the issue here would be super helpful! I would love to start contributing :smile: Thanks!

I personally find that sccache doesn't work really well in Docker. Recently I saw errors that I could resolve by removing --sccache from my build-script invocation, they happened on the same file, but exact error messages were significantly different. You can also skip SwiftCompilerSources altogether by passing --bootstrapping=off.

1 Like

Thanks so much! It worked with --bootstrapping=off, and luckily building with sccache does work. Really appreciate the help!

1 Like