Can’t build the 5.9.2 compiler: calling a private constructor of class 'clang::StmtIterator'

i am getting an error when trying to compile the toolchain at the swift-5.9.2-RELEASE tag:

5919.0 <unknown>:0: error: calling a private constructor of class 'clang::StmtIterator'
5919.0 /swift-project/llvm-project/clang/include/clang/AST/StmtIterator.h:137:3: note: declared private here
5919.0   StmtIterator(const StmtIteratorBase &RHS)
5919.0   ^
5919.0 <unknown>:0: error: calling a private constructor of class 'clang::StmtIterator'
5919.0 /swift-project/llvm-project/clang/include/clang/AST/StmtIterator.h:137:3: note: declared private here
5919.0   StmtIterator(const StmtIteratorBase &RHS)
5919.0   ^
5919.0 error: fatalError
5919.0 ninja: build stopped: subcommand failed.

it seems that at least one other person has run into this issue but they did not find a solution.

the dockerfile is doing this:

RUN mkdir /swift-project
WORKDIR /swift-project

RUN git clone --depth 1 --branch swift-5.9.2-RELEASE https://github.com/apple/swift

WORKDIR /swift-project/swift

RUN utils/update-checkout --clone --tag swift-5.9.2-RELEASE

what is going on here? how did the CI ever manage to build the toolchain?

in the linked issue, it was suggested to give up on 5.9 and build 5.10 instead. i have already been able to build 5.10, but the 5.10 toochain is experimental and contains many bugs that make it unusable for our purposes. so i really need to be able to build the 5.9 toolchain.

Is it possible it only works on the CI because it builds the 5.9.2 compiler with an older prebuilt Swift 5.8.1 toolchain?

1 Like

good catch! i was using a 5.9.2 Amazon Linux 2 compiler and when i modified the dockerfile to use 5.8.1 instead, the compilation succeeded, although the docker build as a whole still ended up failing at the end due to some inexplicable Foundation test failures:

7214.2 99% tests passed, 3 tests failed out of 1998
7214.2 
7214.2 Total Test time (real) = 118.42 sec
7214.2 
7214.2 The following tests FAILED:
7214.2 	595 - TestFoundation.TestFileManager-test_isReadableFile (Failed)
7214.2 	596 - TestFoundation.TestFileManager-test_isWritableFile (Failed)
7214.2 	598 - TestFoundation.TestFileManager-test_isDeletableFile (Failed)

as i have no need for Foundation on Amazon Linux 2023, i presume a skip-test-foundation will be enough to resolve the issue. (still, it was infuriating to have to restart the whole build, as utils/build-script is a single command from docker’s perspective.)

i really hope this will not be necessary in the future. it seems it would require a lot of determination to use swift on the server…