Invoking swift/utils/build-script fails bin/clang-ast-dump with Undefined symbols for architecture arm64

I'm trying to build swift-syntax on M1 without Rosetta. Here's the steps I did:

  1. Followed the SSH guidelines from GettingStarted.md.
  2. brew install cmake ninja sccache.
  3. sccache --start-server
  4. Ninja build utils/build-script --skip-build-benchmarks \ --skip-ios --skip-watchos --skip-tvos --swift-darwin-supported-archs "$(uname -m)" \ --sccache --release-debuginfo --swift-disable-dead-stripping --test.

This builds Swift compiler just fine and I can run tests. Now, back to swift-syntax/CONTRIBUTING.md, here's what I did:

  1. Installed the recent Trunk Swift Toolchain.
  2. export TOOLCHAINS=swift.
  3. xcrun --find swift. echo: /Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2022-08-30-a.xctoolchain/usr/bin/swift.
  4. swift-syntax/build-script.py build --toolchain /Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2022-08-30-a.xctoolchain/usr.
  5. Run the tests: swift/utils/build-script --swiftsyntax --swiftpm --llbuild -t --skip-test-cmark --skip-test-swift --skip-test-llbuild --skip-test-swiftpm.

Here's the failing output:

[3153/4517][ 69%][644.787s] Linking CXX executable bin/clang-ast-dump
FAILED: bin/clang-ast-dump
: && /Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2022-08-30-a.xctoolchain/usr/bin/clang++ -Wno-unknown-warning-option -Werror=unguarded-availability-new -arch arm64 -target arm64-apple-macosx -g -fPIC -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough -Wcovered-switch-default -Wno-class-memaccess -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment -Wstring-conversion -Wmisleading-indentation -index-store-path "/Users/mennabah/projects/os/swift-project/build/Ninja-DebugAssert/llvm-macosx-arm64/IndexStore" -fdiagnostics-color -fno-common -Woverloaded-virtual -Wno-nested-anon-types -g -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk -mmacosx-version-min=10.9 -Wl,-search_paths_first -Wl,-headerpad_max_install_names  tools/clang/lib/Tooling/DumpTool/CMakeFiles/clang-ast-dump.dir/ASTSrcLocProcessor.cpp.o tools/clang/lib/Tooling/DumpTool/CMakeFiles/clang-ast-dump.dir/ClangSrcLocDump.cpp.o -o bin/clang-ast-dump  -Wl,-rpath,@loader_path/../lib  lib/libLLVMOption.a  lib/libLLVMFrontendOpenMP.a  lib/libLLVMSupport.a  lib/libclangAST.a  lib/libclangASTMatchers.a  lib/libclangBasic.a  lib/libclangDriver.a  lib/libclangFrontend.a  lib/libclangSerialization.a  lib/libclangToolingCore.a  lib/libclangDriver.a  lib/libLLVMWindowsDriver.a  lib/libLLVMOption.a  lib/libclangCAS.a  lib/libLLVMCAS.a  lib/libclangParse.a  lib/libclangSema.a  lib/libclangAPINotes.a  lib/libclangEdit.a  lib/libclangAnalysis.a  lib/libclangASTMatchers.a  lib/libclangAST.a  lib/libLLVMFrontendOpenMP.a  lib/libLLVMScalarOpts.a  lib/libLLVMAggressiveInstCombine.a  lib/libLLVMInstCombine.a  lib/libLLVMTransformUtils.a  lib/libLLVMAnalysis.a  lib/libLLVMProfileData.a  lib/libLLVMSymbolize.a  lib/libLLVMDebugInfoPDB.a  lib/libLLVMDebugInfoMSF.a  lib/libLLVMDebugInfoDWARF.a  lib/libLLVMObject.a  lib/libLLVMMCParser.a  lib/libLLVMMC.a  lib/libLLVMDebugInfoCodeView.a  lib/libLLVMTextAPI.a  lib/libLLVMBitReader.a  lib/libLLVMCore.a  lib/libLLVMBinaryFormat.a  lib/libLLVMRemarks.a  lib/libLLVMBitstreamReader.a  lib/libclangRewrite.a  lib/libclangLex.a  lib/libclangBasic.a  lib/libLLVMSupport.a  -lm  /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk/usr/lib/libz.tbd  /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk/usr/lib/libcurses.tbd  lib/libLLVMDemangle.a && :
Undefined symbols for architecture arm64:
  "(anonymous namespace)::OnDiskActionCache::FilePrefix", referenced from:
      (anonymous namespace)::OnDiskActionCache::create(llvm::cas::ObjectStore&, llvm::StringRef) in libLLVMCAS.a(ActionCaches.cpp.o)
  "(anonymous namespace)::OnDiskActionCache::ActionCacheFile", referenced from:
      (anonymous namespace)::OnDiskActionCache::create(llvm::cas::ObjectStore&, llvm::StringRef) in libLLVMCAS.a(ActionCaches.cpp.o)
ld: symbol(s) not found for architecture arm64
clang-13: error: linker command failed with exit code 1 (use -v to see invocation)
[3162/4517][ 70%][647.552s] Building CXX object tools/clang/lib/Tooling/Transformer/CMakeFiles/obj.clangTransformer.dir/Stencil.cpp.o
ninja: build stopped: subcommand failed.
ERROR: command terminated with a non-zero exit status 1, aborting

Might be helpful:

$ echo $TOOLCHAINS
swift

$ xcrun --find swift
/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2022-08-30-a.xctoolchain/usr/bin/swift

$ cmake --version
cmake version 3.24.1

CMake suite maintained and supported by Kitware (kitware.com/cmake).

$ python3 --version
Python 3.10.6

$ ninja --version
1.11.1

$ sccache --version
sccache 0.3.0

This is a temporary breakage on development branch which is fixed already. Please update the source (mainly llvm-project) to the latest and rebuild. Sorry for the inconvenience .

I've got that built with an updated source. Many thanks @cachemeifyoucan!