Missing include/c++/12/bits/stl_iterator_base_funcs.h when building the toolchain

I've been trying to build a trunk toolchain on Ubuntu 22.04, and it keeps failing with the error

missing '#include "gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/stl_iterator_base_funcs.h"'; 'distance' must be declared before it is used

when compiling swift/include/swift/Basic/StableHasher.h, which is then followed by various

redefinition of '*_iterator_tag'

The build is started using utils/build-script --release-debuginfo --skip-early-swift-driver --skip-early-swiftsyntax --clean.

The full build-script output is here.

The output from update-checkout --dump-hashes is here.

System configuration:

  • x86-64
  • Ubuntu 22.04.2 LTS
  • cmake 2.26.3
  • ninja 1.11.1
  • clang 17 (from the development branch of LLVM apt repository)
    • also tried clang 15 (by passing in --extra-cmake-options="-DCMAKE_C_COMPILER=/usr/bin/clang-15 -DCMAKE_CXX_COMPILER=/usr/bin/clang++-15")
  • no host Swift toolchain